[PATCH vkd3d 5/5] vkd3d-shader: Create descriptor array symbols for resources.
Henri Verbeet
hverbeet at gmail.com
Wed Jul 14 06:20:47 CDT 2021
On Fri, 9 Jul 2021 at 07:48, Conor McCarthy <cmccarthy at codeweavers.com> wrote:
> @@ -5724,6 +5729,9 @@ static void vkd3d_dxbc_compiler_emit_resource_declaration(struct vkd3d_dxbc_comp
> return;
> }
>
> + binding = vkd3d_dxbc_compiler_get_descriptor_binding(compiler, reg, &resource->range,
> + resource_type, false, &binding_base_idx);
> +
> if (compiler->ssbo_uavs && is_uav && resource_type == VKD3D_SHADER_RESOURCE_BUFFER)
> {
> uint32_t array_type_id, struct_id;
> @@ -5744,16 +5752,22 @@ static void vkd3d_dxbc_compiler_emit_resource_declaration(struct vkd3d_dxbc_comp
> {
> type_id = vkd3d_dxbc_compiler_get_image_type_id(compiler, reg, &resource->range,
> resource_type_info, sampled_type, structure_stride || raw, 0);
> +
> + if (binding.count != 1 || resource->range.last == ~0u)
> + {
> + contained_type_id = type_id;
> + type_id = vkd3d_spirv_get_op_type_array(builder, type_id,
> + vkd3d_dxbc_compiler_get_constant_uint(compiler, binding.count));
> + }
> }
>
I think we would need this for the "compiler->ssbo_uavs" case as well.
> ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, storage_class, type_id);
> - var_id = vkd3d_spirv_build_op_variable(builder, &builder->global_stream,
> - ptr_type_id, storage_class, 0);
>
> - vkd3d_dxbc_compiler_emit_descriptor_binding_for_reg(compiler, var_id, reg,
> - &resource->range, resource_type, false);
> -
> - vkd3d_dxbc_compiler_emit_register_debug_name(builder, var_id, reg);
> + array_data.contained_type_id = contained_type_id;
> + array_data.binding_base_idx = binding_base_idx;
> + array_data.storage_class = storage_class;
> + var_id = vkd3d_dxbc_compiler_get_resource_variable(compiler, &array_data, ptr_type_id, reg, &binding,
> + &array_symbol);
>
...but if we used vkd3d_dxbc_compiler_build_resource_variable() here,
it would simply handle it for us.
> if (is_uav)
> {
> @@ -5791,6 +5805,11 @@ static void vkd3d_dxbc_compiler_emit_resource_declaration(struct vkd3d_dxbc_comp
> storage_class = SpvStorageClassUniform;
> ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, storage_class, struct_id);
> }
> + else if (contained_type_id)
> + {
> + /* TODO: UAV counter arrays. */
> + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, storage_class, contained_type_id);
> + }
>
...and this change would more or less go away.
> @@ -7815,8 +7852,15 @@ static void vkd3d_dxbc_compiler_prepare_image(struct vkd3d_dxbc_compiler *compil
> - image->image_id = load ? vkd3d_spirv_build_op_load(builder,
> - image->image_type_id, image->id, SpvMemoryAccessMaskNone) : 0;
> + if (load)
> + {
> + image->image_id = vkd3d_spirv_build_op_load(builder,
> + image->image_type_id, image->id, SpvMemoryAccessMaskNone);
> + }
> + else
> + {
> + image->image_id = 0;
> + }
>
This seems like an unrelated formatting change.
More information about the wine-devel
mailing list