mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader: Add structure type fields to public API structures.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2f15b30e30
commit
f97b745ae7
@ -25,6 +25,15 @@ extern "C" {
|
|||||||
|
|
||||||
#define VKD3D_FORCE_32_BIT_ENUM(name) name##_FORCE_32BIT = 0x7fffffff
|
#define VKD3D_FORCE_32_BIT_ENUM(name) name##_FORCE_32BIT = 0x7fffffff
|
||||||
|
|
||||||
|
enum vkd3d_shader_structure_type
|
||||||
|
{
|
||||||
|
VKD3D_SHADER_STRUCTURE_TYPE_SHADER_INTERFACE,
|
||||||
|
VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_ARGUMENTS,
|
||||||
|
VKD3D_SHADER_STRUCTURE_TYPE_SCAN_INFO,
|
||||||
|
|
||||||
|
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_STRUCTURE_TYPE),
|
||||||
|
};
|
||||||
|
|
||||||
enum vkd3d_result
|
enum vkd3d_result
|
||||||
{
|
{
|
||||||
VKD3D_OK = 0,
|
VKD3D_OK = 0,
|
||||||
@ -130,6 +139,9 @@ struct vkd3d_shader_push_constant_buffer
|
|||||||
|
|
||||||
struct vkd3d_shader_interface
|
struct vkd3d_shader_interface
|
||||||
{
|
{
|
||||||
|
enum vkd3d_shader_structure_type type;
|
||||||
|
const void *next;
|
||||||
|
|
||||||
const struct vkd3d_shader_resource_binding *bindings;
|
const struct vkd3d_shader_resource_binding *bindings;
|
||||||
unsigned int binding_count;
|
unsigned int binding_count;
|
||||||
|
|
||||||
@ -160,8 +172,11 @@ enum vkd3d_shader_target
|
|||||||
|
|
||||||
struct vkd3d_shader_compile_arguments
|
struct vkd3d_shader_compile_arguments
|
||||||
{
|
{
|
||||||
|
enum vkd3d_shader_structure_type type;
|
||||||
|
const void *next;
|
||||||
|
|
||||||
enum vkd3d_shader_target target;
|
enum vkd3d_shader_target target;
|
||||||
unsigned int *output_swizzles;
|
const unsigned int *output_swizzles;
|
||||||
unsigned int output_swizzle_count;
|
unsigned int output_swizzle_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -366,6 +381,9 @@ int vkd3d_shader_serialize_root_signature(const struct vkd3d_root_signature_desc
|
|||||||
|
|
||||||
struct vkd3d_shader_scan_info
|
struct vkd3d_shader_scan_info
|
||||||
{
|
{
|
||||||
|
enum vkd3d_shader_structure_type type;
|
||||||
|
void *next;
|
||||||
|
|
||||||
unsigned int uav_read_mask : VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS;
|
unsigned int uav_read_mask : VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS;
|
||||||
unsigned int uav_counter_mask : VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS;
|
unsigned int uav_counter_mask : VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS;
|
||||||
unsigned int sampler_comparison_mode_mask;
|
unsigned int sampler_comparison_mode_mask;
|
||||||
|
@ -61,6 +61,12 @@ static int vkd3d_shader_validate_compile_args(const struct vkd3d_shader_compile_
|
|||||||
if (!compile_args)
|
if (!compile_args)
|
||||||
return VKD3D_OK;
|
return VKD3D_OK;
|
||||||
|
|
||||||
|
if (compile_args->type != VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_ARGUMENTS)
|
||||||
|
{
|
||||||
|
WARN("Invalid structure type %#x.\n", compile_args->type);
|
||||||
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
switch (compile_args->target)
|
switch (compile_args->target)
|
||||||
{
|
{
|
||||||
case VKD3D_SHADER_TARGET_SPIRV_OPENGL_4_5:
|
case VKD3D_SHADER_TARGET_SPIRV_OPENGL_4_5:
|
||||||
@ -88,9 +94,17 @@ int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc,
|
|||||||
TRACE("dxbc {%p, %zu}, spirv %p, compiler_options %#x, shader_interface %p, compile_args %p.\n",
|
TRACE("dxbc {%p, %zu}, spirv %p, compiler_options %#x, shader_interface %p, compile_args %p.\n",
|
||||||
dxbc->code, dxbc->size, spirv, compiler_options, shader_interface, compile_args);
|
dxbc->code, dxbc->size, spirv, compiler_options, shader_interface, compile_args);
|
||||||
|
|
||||||
|
if (shader_interface && shader_interface->type != VKD3D_SHADER_STRUCTURE_TYPE_SHADER_INTERFACE)
|
||||||
|
{
|
||||||
|
WARN("Invalid structure type %#x.\n", shader_interface->type);
|
||||||
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
if ((ret = vkd3d_shader_validate_compile_args(compile_args)) < 0)
|
if ((ret = vkd3d_shader_validate_compile_args(compile_args)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
scan_info.type = VKD3D_SHADER_STRUCTURE_TYPE_SCAN_INFO;
|
||||||
|
scan_info.next = NULL;
|
||||||
if ((ret = vkd3d_shader_scan_dxbc(dxbc, &scan_info)) < 0)
|
if ((ret = vkd3d_shader_scan_dxbc(dxbc, &scan_info)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -209,6 +223,12 @@ int vkd3d_shader_scan_dxbc(const struct vkd3d_shader_code *dxbc,
|
|||||||
|
|
||||||
TRACE("dxbc {%p, %zu}, scan_info %p.\n", dxbc->code, dxbc->size, scan_info);
|
TRACE("dxbc {%p, %zu}, scan_info %p.\n", dxbc->code, dxbc->size, scan_info);
|
||||||
|
|
||||||
|
if (scan_info->type != VKD3D_SHADER_STRUCTURE_TYPE_SCAN_INFO)
|
||||||
|
{
|
||||||
|
WARN("Invalid structure type %#x.\n", scan_info->type);
|
||||||
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
if ((ret = vkd3d_shader_parser_init(&parser, dxbc)) < 0)
|
if ((ret = vkd3d_shader_parser_init(&parser, dxbc)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -1439,6 +1439,8 @@ static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *st
|
|||||||
|
|
||||||
dxbc.code = desc->CS.pShaderBytecode;
|
dxbc.code = desc->CS.pShaderBytecode;
|
||||||
dxbc.size = desc->CS.BytecodeLength;
|
dxbc.size = desc->CS.BytecodeLength;
|
||||||
|
shader_info.type = VKD3D_SHADER_STRUCTURE_TYPE_SCAN_INFO;
|
||||||
|
shader_info.next = NULL;
|
||||||
if ((ret = vkd3d_shader_scan_dxbc(&dxbc, &shader_info)) < 0)
|
if ((ret = vkd3d_shader_scan_dxbc(&dxbc, &shader_info)) < 0)
|
||||||
{
|
{
|
||||||
WARN("Failed to scan shader bytecode, vkd3d result %d.\n", ret);
|
WARN("Failed to scan shader bytecode, vkd3d result %d.\n", ret);
|
||||||
@ -1452,6 +1454,8 @@ static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *st
|
|||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shader_interface.type = VKD3D_SHADER_STRUCTURE_TYPE_SHADER_INTERFACE;
|
||||||
|
shader_interface.next = NULL;
|
||||||
shader_interface.bindings = root_signature->descriptor_mapping;
|
shader_interface.bindings = root_signature->descriptor_mapping;
|
||||||
shader_interface.binding_count = root_signature->descriptor_count;
|
shader_interface.binding_count = root_signature->descriptor_count;
|
||||||
shader_interface.push_constant_buffers = root_signature->root_constants;
|
shader_interface.push_constant_buffers = root_signature->root_constants;
|
||||||
@ -2027,10 +2031,14 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
|
|||||||
}
|
}
|
||||||
graphics->attachment_count = graphics->rt_idx + rt_count;
|
graphics->attachment_count = graphics->rt_idx + rt_count;
|
||||||
|
|
||||||
|
ps_compile_args.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_ARGUMENTS;
|
||||||
|
ps_compile_args.next = NULL;
|
||||||
ps_compile_args.target = VKD3D_SHADER_TARGET_SPIRV_VULKAN_1_0;
|
ps_compile_args.target = VKD3D_SHADER_TARGET_SPIRV_VULKAN_1_0;
|
||||||
ps_compile_args.output_swizzles = ps_output_swizzle;
|
ps_compile_args.output_swizzles = ps_output_swizzle;
|
||||||
ps_compile_args.output_swizzle_count = rt_count;
|
ps_compile_args.output_swizzle_count = rt_count;
|
||||||
|
|
||||||
|
shader_interface.type = VKD3D_SHADER_STRUCTURE_TYPE_SHADER_INTERFACE;
|
||||||
|
shader_interface.next = NULL;
|
||||||
shader_interface.bindings = root_signature->descriptor_mapping;
|
shader_interface.bindings = root_signature->descriptor_mapping;
|
||||||
shader_interface.binding_count = root_signature->descriptor_count;
|
shader_interface.binding_count = root_signature->descriptor_count;
|
||||||
shader_interface.push_constant_buffers = root_signature->root_constants;
|
shader_interface.push_constant_buffers = root_signature->root_constants;
|
||||||
@ -2044,8 +2052,8 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
|
|||||||
for (i = 0; i < ARRAY_SIZE(shader_stages); ++i)
|
for (i = 0; i < ARRAY_SIZE(shader_stages); ++i)
|
||||||
{
|
{
|
||||||
const D3D12_SHADER_BYTECODE *b = (const void *)((uintptr_t)desc + shader_stages[i].offset);
|
const D3D12_SHADER_BYTECODE *b = (const void *)((uintptr_t)desc + shader_stages[i].offset);
|
||||||
|
struct vkd3d_shader_scan_info shader_info = {VKD3D_SHADER_STRUCTURE_TYPE_SCAN_INFO};
|
||||||
const struct vkd3d_shader_code dxbc = {b->pShaderBytecode, b->BytecodeLength};
|
const struct vkd3d_shader_code dxbc = {b->pShaderBytecode, b->BytecodeLength};
|
||||||
struct vkd3d_shader_scan_info shader_info;
|
|
||||||
|
|
||||||
if (!b->pShaderBytecode)
|
if (!b->pShaderBytecode)
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user