mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-12-15 08:03:30 -08:00
vkd3d-shader/spirv: Clamp push constant CBV sizes to those of the push constant ranges backing them.
Otherwise invalid SPIR-V may be generated, because the CBV field in "push_cb_struct" may end up overlapping with a subsequent one.
This commit is contained in:
committed by
Henri Verbeet
parent
2903831f79
commit
7f377879fc
Notes:
Henri Verbeet
2025-11-12 15:31:45 +01:00
Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1826
@@ -6668,13 +6668,18 @@ static void spirv_compiler_emit_cbv_declaration(struct spirv_compiler *compiler,
|
||||
/* Push constant buffers are handled in
|
||||
* spirv_compiler_emit_push_constant_buffers().
|
||||
*/
|
||||
push_cb->reg = reg;
|
||||
push_cb->size = size;
|
||||
if (size_in_bytes > push_cb->pc.size)
|
||||
{
|
||||
WARN("Constant buffer size %u exceeds push constant size %u.\n",
|
||||
size_in_bytes, push_cb->pc.size);
|
||||
spirv_compiler_warning(compiler, VKD3D_SHADER_WARNING_SPV_INVALID_SIZE,
|
||||
"Constant buffer cb%u, space %u, has size %u which exceeds the push constant size %u.",
|
||||
push_cb->pc.register_index, push_cb->pc.register_space, size_in_bytes, push_cb->pc.size);
|
||||
size_in_bytes = push_cb->pc.size;
|
||||
size = align(size_in_bytes, VKD3D_VEC4_SIZE * sizeof(uint32_t));
|
||||
size /= VKD3D_VEC4_SIZE * sizeof(uint32_t);
|
||||
}
|
||||
|
||||
push_cb->reg = reg;
|
||||
push_cb->size = size;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user