vkd3d-shader: Report descriptor resource types in vkd3d_shader_scan_dxbc().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2020-06-25 10:48:25 +04:30 committed by Alexandre Julliard
parent 25c0966b69
commit cf04ed68a7
3 changed files with 67 additions and 23 deletions

View File

@ -585,11 +585,41 @@ struct vkd3d_versioned_root_signature_desc
/* FIXME: Add support for 64 UAV bind slots. */
#define VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS 8
enum vkd3d_shader_resource_type
{
VKD3D_SHADER_RESOURCE_NONE = 0x0,
VKD3D_SHADER_RESOURCE_BUFFER = 0x1,
VKD3D_SHADER_RESOURCE_TEXTURE_1D = 0x2,
VKD3D_SHADER_RESOURCE_TEXTURE_2D = 0x3,
VKD3D_SHADER_RESOURCE_TEXTURE_2DMS = 0x4,
VKD3D_SHADER_RESOURCE_TEXTURE_3D = 0x5,
VKD3D_SHADER_RESOURCE_TEXTURE_CUBE = 0x6,
VKD3D_SHADER_RESOURCE_TEXTURE_1DARRAY = 0x7,
VKD3D_SHADER_RESOURCE_TEXTURE_2DARRAY = 0x8,
VKD3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY = 0x9,
VKD3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY = 0xa,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_RESOURCE_TYPE),
};
enum vkd3d_shader_resource_data_type
{
VKD3D_SHADER_RESOURCE_DATA_UNORM = 0x1,
VKD3D_SHADER_RESOURCE_DATA_SNORM = 0x2,
VKD3D_SHADER_RESOURCE_DATA_INT = 0x3,
VKD3D_SHADER_RESOURCE_DATA_UINT = 0x4,
VKD3D_SHADER_RESOURCE_DATA_FLOAT = 0x5,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_RESOURCE_DATA_TYPE),
};
struct vkd3d_shader_descriptor_info
{
enum vkd3d_shader_descriptor_type type;
unsigned int register_space;
unsigned int register_index;
enum vkd3d_shader_resource_type resource_type;
enum vkd3d_shader_resource_data_type resource_data_type;
unsigned int count;
};

View File

@ -229,7 +229,8 @@ static void vkd3d_shader_scan_record_uav_counter(struct vkd3d_shader_scan_info *
}
static bool vkd3d_shader_scan_add_descriptor(struct vkd3d_shader_scan_context *context,
enum vkd3d_shader_descriptor_type type, unsigned int register_space, unsigned int register_index)
enum vkd3d_shader_descriptor_type type, unsigned int register_space, unsigned int register_index,
enum vkd3d_shader_resource_type resource_type, enum vkd3d_shader_resource_data_type resource_data_type)
{
struct vkd3d_shader_scan_info *scan_info = context->scan_info;
struct vkd3d_shader_descriptor_info *d;
@ -245,6 +246,8 @@ static bool vkd3d_shader_scan_add_descriptor(struct vkd3d_shader_scan_context *c
d->type = type;
d->register_space = register_space;
d->register_index = register_index;
d->resource_type = resource_type;
d->resource_data_type = resource_data_type;
d->count = 1;
++scan_info->descriptor_count;
@ -256,8 +259,8 @@ static void vkd3d_shader_scan_constant_buffer_declaration(struct vkd3d_shader_sc
{
const struct vkd3d_shader_constant_buffer *cb = &instruction->declaration.cb;
vkd3d_shader_scan_add_descriptor(context, VKD3D_SHADER_DESCRIPTOR_TYPE_CBV,
cb->register_space, cb->register_index);
vkd3d_shader_scan_add_descriptor(context, VKD3D_SHADER_DESCRIPTOR_TYPE_CBV, cb->register_space,
cb->register_index, VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_SHADER_RESOURCE_DATA_UINT);
}
static void vkd3d_shader_scan_input_declaration(struct vkd3d_shader_scan_info *scan_info,
@ -282,21 +285,45 @@ static void vkd3d_shader_scan_sampler_declaration(struct vkd3d_shader_scan_conte
scan_info->sampler_comparison_mode_mask |= 1u << sampler_index;
}
vkd3d_shader_scan_add_descriptor(context, VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER,
sampler->register_space, sampler->register_index);
vkd3d_shader_scan_add_descriptor(context, VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER, sampler->register_space,
sampler->register_index, VKD3D_SHADER_RESOURCE_NONE, VKD3D_SHADER_RESOURCE_DATA_UINT);
}
static void vkd3d_shader_scan_resource_declaration(struct vkd3d_shader_scan_context *context,
const struct vkd3d_shader_instruction *instruction)
{
const struct vkd3d_shader_semantic *semantic = &instruction->declaration.semantic;
enum vkd3d_shader_resource_data_type resource_data_type;
enum vkd3d_shader_descriptor_type type;
if (semantic->reg.reg.type == VKD3DSPR_UAV)
type = VKD3D_SHADER_DESCRIPTOR_TYPE_UAV;
else
type = VKD3D_SHADER_DESCRIPTOR_TYPE_SRV;
vkd3d_shader_scan_add_descriptor(context, type, semantic->register_space, semantic->register_index);
switch (semantic->resource_data_type)
{
case VKD3D_DATA_UNORM:
resource_data_type = VKD3D_SHADER_RESOURCE_DATA_UNORM;
break;
case VKD3D_DATA_SNORM:
resource_data_type = VKD3D_SHADER_RESOURCE_DATA_SNORM;
break;
case VKD3D_DATA_INT:
resource_data_type = VKD3D_SHADER_RESOURCE_DATA_INT;
break;
case VKD3D_DATA_UINT:
resource_data_type = VKD3D_SHADER_RESOURCE_DATA_UINT;
break;
case VKD3D_DATA_FLOAT:
resource_data_type = VKD3D_SHADER_RESOURCE_DATA_FLOAT;
break;
default:
ERR("Invalid resource data type %#x.\n", semantic->resource_data_type);
resource_data_type = VKD3D_SHADER_RESOURCE_DATA_FLOAT;
break;
}
vkd3d_shader_scan_add_descriptor(context, type, semantic->register_space,
semantic->register_index, semantic->resource_type, resource_data_type);
}
static void vkd3d_shader_scan_resource_declaration_raw(struct vkd3d_shader_scan_context *context,
@ -309,7 +336,8 @@ static void vkd3d_shader_scan_resource_declaration_raw(struct vkd3d_shader_scan_
type = VKD3D_SHADER_DESCRIPTOR_TYPE_UAV;
else
type = VKD3D_SHADER_DESCRIPTOR_TYPE_SRV;
vkd3d_shader_scan_add_descriptor(context, type, resource->register_space, resource->register_index);
vkd3d_shader_scan_add_descriptor(context, type, resource->register_space,
resource->register_index, VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_SHADER_RESOURCE_DATA_UINT);
}
static void vkd3d_shader_scan_resource_declaration_structured(struct vkd3d_shader_scan_context *context,
@ -322,7 +350,8 @@ static void vkd3d_shader_scan_resource_declaration_structured(struct vkd3d_shade
type = VKD3D_SHADER_DESCRIPTOR_TYPE_UAV;
else
type = VKD3D_SHADER_DESCRIPTOR_TYPE_SRV;
vkd3d_shader_scan_add_descriptor(context, type, resource->register_space, resource->register_index);
vkd3d_shader_scan_add_descriptor(context, type, resource->register_space,
resource->register_index, VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_SHADER_RESOURCE_DATA_UINT);
}
static void vkd3d_shader_scan_instruction(struct vkd3d_shader_scan_context *context,

View File

@ -361,21 +361,6 @@ enum vkd3d_shader_register_type
VKD3DSPR_INVALID = ~0u,
};
enum vkd3d_shader_resource_type
{
VKD3D_SHADER_RESOURCE_NONE,
VKD3D_SHADER_RESOURCE_BUFFER,
VKD3D_SHADER_RESOURCE_TEXTURE_1D,
VKD3D_SHADER_RESOURCE_TEXTURE_2D,
VKD3D_SHADER_RESOURCE_TEXTURE_2DMS,
VKD3D_SHADER_RESOURCE_TEXTURE_3D,
VKD3D_SHADER_RESOURCE_TEXTURE_CUBE,
VKD3D_SHADER_RESOURCE_TEXTURE_1DARRAY,
VKD3D_SHADER_RESOURCE_TEXTURE_2DARRAY,
VKD3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY,
VKD3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY,
};
enum vkd3d_data_type
{
VKD3D_DATA_FLOAT,