fix image is not set in pipeline state object in metal renderer (#2780)

* always set pipeline state object 'm_bindingTypes' when argument is texture

* fix the typo error casue cash
This commit is contained in:
Kitchen 2022-04-22 11:11:37 +08:00 committed by GitHub
parent f6e0db1969
commit 2568ce7311
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2016,19 +2016,21 @@ namespace bgfx { namespace mtl
else if (arg.type == MTLArgumentTypeTexture)
{
const char* name = utf8String(arg.name);
const UniformRegInfo* info = s_renderMtl->m_uniformReg.find(name);
BX_WARN(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
if (NULL != info)
if (arg.index >= BGFX_CONFIG_MAX_TEXTURE_SAMPLERS)
{
if (arg.index >= BGFX_CONFIG_MAX_TEXTURE_SAMPLERS)
BX_WARN(false, "Binding index is too large %d max is %d. User defined uniform '%s' won't be set.", int(arg.index), BGFX_CONFIG_MAX_TEXTURE_SAMPLERS - 1, name);
}
else
{
ps->m_bindingTypes[arg.index] = fragmentBit ? PipelineStateMtl::BindToFragmentShader : PipelineStateMtl::BindToVertexShader;
const UniformRegInfo* info = s_renderMtl->m_uniformReg.find(name);
if (info)
{
BX_WARN(false, "Binding index is too large %d max is %d. User defined uniform '%s' won't be set.", int(arg.index), BGFX_CONFIG_MAX_TEXTURE_SAMPLERS - 1, name);
BX_TRACE("texture %s %d index:%d", name, info->m_handle, uint32_t(arg.index) );
}
else
{
ps->m_bindingTypes[arg.index] = fragmentBit ? PipelineStateMtl::BindToFragmentShader : PipelineStateMtl::BindToVertexShader;
BX_TRACE("texture %s %d index:%d", name, info->m_handle, uint32_t(arg.index) );
BX_TRACE("image %s index:%d", name, uint32_t(arg.index) );
}
}
}