From: Mike Blumenkrantz Date: Fri, 4 Dec 2020 20:42:29 +0000 (-0500) Subject: zink: flatten binding numbers a bit X-Git-Tag: upstream/21.2.3~6425 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=84293f539549be4bb9c26f7279a4e05610fb6cef;p=platform%2Fupstream%2Fmesa.git zink: flatten binding numbers a bit now that descriptor types are split, we can just use the type-max values per stage as the increment instead of all type max values Reviewed-by: Adam Jackson Part-of: --- diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c index 3552bda..1a58d10 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c +++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c @@ -676,30 +676,25 @@ zink_binding(gl_shader_stage stage, VkDescriptorType type, int index) if (stage == MESA_SHADER_NONE) { unreachable("not supported"); } else { - uint32_t stage_offset = (uint32_t)stage * (PIPE_MAX_CONSTANT_BUFFERS + - PIPE_MAX_SAMPLERS + - PIPE_MAX_SHADER_BUFFERS + - PIPE_MAX_SHADER_IMAGES); - switch (type) { case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: assert(index < PIPE_MAX_CONSTANT_BUFFERS); - return stage_offset + index; + return (stage * PIPE_MAX_CONSTANT_BUFFERS) + index; case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: assert(index < PIPE_MAX_SAMPLERS); - return stage_offset + PIPE_MAX_CONSTANT_BUFFERS + index; + return (stage * PIPE_MAX_SAMPLERS) + index; case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: assert(index < PIPE_MAX_SHADER_BUFFERS); - return stage_offset + PIPE_MAX_CONSTANT_BUFFERS + PIPE_MAX_SHADER_SAMPLER_VIEWS + index; + return (stage * PIPE_MAX_SHADER_BUFFERS) + index; case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: assert(index < PIPE_MAX_SHADER_IMAGES); - return stage_offset + PIPE_MAX_CONSTANT_BUFFERS + PIPE_MAX_SHADER_SAMPLER_VIEWS + PIPE_MAX_SHADER_IMAGES + index; + return (stage * PIPE_MAX_SHADER_IMAGES) + index; default: unreachable("unexpected type");