Commit 504d1a45 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d/spirv: Hook up sm1 interface matching.

parent 1474f5cc
...@@ -13293,8 +13293,8 @@ then : ...@@ -13293,8 +13293,8 @@ then :
else $as_nop else $as_nop
: :
fi fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for vkd3d_shader_serialize_dxbc in MinGW -lvkd3d-shader" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for vkd3d_shader_build_varying_map in MinGW -lvkd3d-shader" >&5
printf %s "checking for vkd3d_shader_serialize_dxbc in MinGW -lvkd3d-shader... " >&6; } printf %s "checking for vkd3d_shader_build_varying_map in MinGW -lvkd3d-shader... " >&6; }
if test ${ac_cv_mingw_lib_vkd3d_shader+y} if test ${ac_cv_mingw_lib_vkd3d_shader+y}
then : then :
printf %s "(cached) " >&6 printf %s "(cached) " >&6
...@@ -13311,11 +13311,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ...@@ -13311,11 +13311,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* Override any GCC internal prototype to avoid an error. /* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */ builtin and then its argument prototype would still apply. */
char vkd3d_shader_serialize_dxbc (); char vkd3d_shader_build_varying_map ();
int int
main (void) main (void)
{ {
return vkd3d_shader_serialize_dxbc (); return vkd3d_shader_build_varying_map ();
; ;
return 0; return 0;
} }
......
...@@ -1161,7 +1161,7 @@ then ...@@ -1161,7 +1161,7 @@ then
if test "$ac_cv_mingw_header_vkd3d_h" = "yes" -a "$ac_cv_mingw_header_vkd3d_shader_h" = "yes" if test "$ac_cv_mingw_header_vkd3d_h" = "yes" -a "$ac_cv_mingw_header_vkd3d_shader_h" = "yes"
then then
WINE_CHECK_MINGW_LIB(vkd3d,vkd3d_set_log_callback,[:],[:],[$VKD3D_PE_LIBS]) WINE_CHECK_MINGW_LIB(vkd3d,vkd3d_set_log_callback,[:],[:],[$VKD3D_PE_LIBS])
WINE_CHECK_MINGW_LIB(vkd3d-shader,vkd3d_shader_serialize_dxbc,[:],[:],[$VKD3D_PE_LIBS]) WINE_CHECK_MINGW_LIB(vkd3d-shader,vkd3d_shader_build_varying_map,[:],[:],[$VKD3D_PE_LIBS])
if test "$ac_cv_mingw_lib_vkd3d" = "no" -o "$ac_cv_mingw_lib_vkd3d_shader" = "no" if test "$ac_cv_mingw_lib_vkd3d" = "no" -o "$ac_cv_mingw_lib_vkd3d_shader" = "no"
then then
VKD3D_PE_CFLAGS="" VKD3D_PE_CFLAGS=""
......
...@@ -53,12 +53,19 @@ struct shader_spirv_priv ...@@ -53,12 +53,19 @@ struct shader_spirv_priv
struct shader_spirv_resource_bindings bindings; struct shader_spirv_resource_bindings bindings;
}; };
#define MAX_SM1_INTER_STAGE_VARYINGS 12
struct shader_spirv_compile_arguments struct shader_spirv_compile_arguments
{ {
union union
{ {
struct struct
{ {
struct vkd3d_shader_varying_map varying_map[MAX_SM1_INTER_STAGE_VARYINGS];
unsigned int varying_count;
} vs;
struct
{
uint32_t alpha_swizzle; uint32_t alpha_swizzle;
unsigned int sample_count; unsigned int sample_count;
bool dual_source_blending; bool dual_source_blending;
...@@ -81,6 +88,7 @@ struct shader_spirv_graphics_program_vk ...@@ -81,6 +88,7 @@ struct shader_spirv_graphics_program_vk
SIZE_T variants_size, variant_count; SIZE_T variants_size, variant_count;
struct vkd3d_shader_scan_descriptor_info descriptor_info; struct vkd3d_shader_scan_descriptor_info descriptor_info;
struct vkd3d_shader_scan_signature_info signature_info;
}; };
struct shader_spirv_compute_program_vk struct shader_spirv_compute_program_vk
...@@ -95,6 +103,7 @@ struct shader_spirv_compute_program_vk ...@@ -95,6 +103,7 @@ struct shader_spirv_compute_program_vk
struct wined3d_shader_spirv_compile_args struct wined3d_shader_spirv_compile_args
{ {
struct vkd3d_shader_varying_map_info varying_map;
struct vkd3d_shader_spirv_target_info spirv_target; struct vkd3d_shader_spirv_target_info spirv_target;
struct vkd3d_shader_parameter sample_count; struct vkd3d_shader_parameter sample_count;
unsigned int ps_alpha_swizzle[WINED3D_MAX_RENDER_TARGETS]; unsigned int ps_alpha_swizzle[WINED3D_MAX_RENDER_TARGETS];
...@@ -155,6 +164,24 @@ static void shader_spirv_compile_arguments_init(struct shader_spirv_compile_argu ...@@ -155,6 +164,24 @@ static void shader_spirv_compile_arguments_init(struct shader_spirv_compile_argu
args->u.fs.dual_source_blending = state->blend_state && state->blend_state->dual_source; args->u.fs.dual_source_blending = state->blend_state && state->blend_state->dual_source;
break; break;
case WINED3D_SHADER_TYPE_VERTEX:
{
struct wined3d_shader *ps = state->shader[WINED3D_SHADER_TYPE_PIXEL];
if (ps)
{
struct shader_spirv_graphics_program_vk *vs_program = shader->backend_data;
struct shader_spirv_graphics_program_vk *ps_program = ps->backend_data;
if (ps_program->signature_info.input.element_count > ARRAY_SIZE(args->u.vs.varying_map))
ERR("Unexpected inter-stage varying count %u.\n", ps_program->signature_info.input.element_count);
if (shader->reg_maps.shader_version.major < 4)
vkd3d_shader_build_varying_map(&vs_program->signature_info.output,
&ps_program->signature_info.input, &args->u.vs.varying_count, args->u.vs.varying_map);
}
break;
}
default: default:
break; break;
} }
...@@ -162,7 +189,8 @@ static void shader_spirv_compile_arguments_init(struct shader_spirv_compile_argu ...@@ -162,7 +189,8 @@ static void shader_spirv_compile_arguments_init(struct shader_spirv_compile_argu
static void shader_spirv_init_compile_args(struct wined3d_shader_spirv_compile_args *args, static void shader_spirv_init_compile_args(struct wined3d_shader_spirv_compile_args *args,
struct vkd3d_shader_interface_info *vkd3d_interface, enum vkd3d_shader_spirv_environment environment, struct vkd3d_shader_interface_info *vkd3d_interface, enum vkd3d_shader_spirv_environment environment,
enum wined3d_shader_type shader_type, const struct shader_spirv_compile_arguments *compile_args) enum wined3d_shader_type shader_type, enum vkd3d_shader_source_type source_type,
const struct shader_spirv_compile_arguments *compile_args)
{ {
unsigned int i; unsigned int i;
...@@ -199,6 +227,18 @@ static void shader_spirv_init_compile_args(struct wined3d_shader_spirv_compile_a ...@@ -199,6 +227,18 @@ static void shader_spirv_init_compile_args(struct wined3d_shader_spirv_compile_a
args->spirv_target.output_swizzles = args->ps_alpha_swizzle; args->spirv_target.output_swizzles = args->ps_alpha_swizzle;
args->spirv_target.output_swizzle_count = ARRAY_SIZE(args->ps_alpha_swizzle); args->spirv_target.output_swizzle_count = ARRAY_SIZE(args->ps_alpha_swizzle);
} }
else if (shader_type == WINED3D_SHADER_TYPE_VERTEX)
{
if (source_type == VKD3D_SHADER_SOURCE_D3D_BYTECODE)
{
args->spirv_target.next = &args->varying_map;
args->varying_map.type = VKD3D_SHADER_STRUCTURE_TYPE_VARYING_MAP_INFO;
args->varying_map.next = vkd3d_interface;
args->varying_map.varying_map = compile_args->u.vs.varying_map;
args->varying_map.varying_count = compile_args->u.vs.varying_count;
}
}
} }
static void shader_spirv_init_shader_interface_vk(struct wined3d_shader_spirv_shader_interface *iface, static void shader_spirv_init_shader_interface_vk(struct wined3d_shader_spirv_shader_interface *iface,
...@@ -246,7 +286,7 @@ static VkShaderModule shader_spirv_compile_shader(struct wined3d_context_vk *con ...@@ -246,7 +286,7 @@ static VkShaderModule shader_spirv_compile_shader(struct wined3d_context_vk *con
shader_spirv_init_shader_interface_vk(&iface, bindings, so_desc); shader_spirv_init_shader_interface_vk(&iface, bindings, so_desc);
shader_spirv_init_compile_args(&compile_args, &iface.vkd3d_interface, shader_spirv_init_compile_args(&compile_args, &iface.vkd3d_interface,
VKD3D_SHADER_SPIRV_ENVIRONMENT_VULKAN_1_0, shader_type, args); VKD3D_SHADER_SPIRV_ENVIRONMENT_VULKAN_1_0, shader_type, source_type, args);
info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO; info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO;
info.next = &compile_args.spirv_target; info.next = &compile_args.spirv_target;
...@@ -687,7 +727,8 @@ static bool shader_spirv_resource_bindings_init(struct shader_spirv_resource_bin ...@@ -687,7 +727,8 @@ static bool shader_spirv_resource_bindings_init(struct shader_spirv_resource_bin
} }
static void shader_spirv_scan_shader(struct wined3d_shader *shader, static void shader_spirv_scan_shader(struct wined3d_shader *shader,
struct vkd3d_shader_scan_descriptor_info *descriptor_info) struct vkd3d_shader_scan_descriptor_info *descriptor_info,
struct vkd3d_shader_scan_signature_info *signature_info)
{ {
struct vkd3d_shader_compile_info info; struct vkd3d_shader_compile_info info;
char *messages; char *messages;
...@@ -696,6 +737,13 @@ static void shader_spirv_scan_shader(struct wined3d_shader *shader, ...@@ -696,6 +737,13 @@ static void shader_spirv_scan_shader(struct wined3d_shader *shader,
memset(descriptor_info, 0, sizeof(*descriptor_info)); memset(descriptor_info, 0, sizeof(*descriptor_info));
descriptor_info->type = VKD3D_SHADER_STRUCTURE_TYPE_SCAN_DESCRIPTOR_INFO; descriptor_info->type = VKD3D_SHADER_STRUCTURE_TYPE_SCAN_DESCRIPTOR_INFO;
if (signature_info)
{
memset(signature_info, 0, sizeof(*signature_info));
signature_info->type = VKD3D_SHADER_STRUCTURE_TYPE_SCAN_SIGNATURE_INFO;
descriptor_info->next = signature_info;
}
info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO; info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO;
info.next = descriptor_info; info.next = descriptor_info;
info.source.code = shader->byte_code; info.source.code = shader->byte_code;
...@@ -736,7 +784,7 @@ static void shader_spirv_precompile_compute(struct wined3d_shader *shader) ...@@ -736,7 +784,7 @@ static void shader_spirv_precompile_compute(struct wined3d_shader *shader)
shader->backend_data = program_vk; shader->backend_data = program_vk;
} }
shader_spirv_scan_shader(shader, &program_vk->descriptor_info); shader_spirv_scan_shader(shader, &program_vk->descriptor_info, NULL);
} }
static void shader_spirv_precompile(void *shader_priv, struct wined3d_shader *shader) static void shader_spirv_precompile(void *shader_priv, struct wined3d_shader *shader)
...@@ -758,7 +806,7 @@ static void shader_spirv_precompile(void *shader_priv, struct wined3d_shader *sh ...@@ -758,7 +806,7 @@ static void shader_spirv_precompile(void *shader_priv, struct wined3d_shader *sh
shader->backend_data = program_vk; shader->backend_data = program_vk;
} }
shader_spirv_scan_shader(shader, &program_vk->descriptor_info); shader_spirv_scan_shader(shader, &program_vk->descriptor_info, &program_vk->signature_info);
} }
static void shader_spirv_select(void *shader_priv, struct wined3d_context *context, static void shader_spirv_select(void *shader_priv, struct wined3d_context *context,
...@@ -967,6 +1015,7 @@ static void shader_spirv_destroy(struct wined3d_shader *shader) ...@@ -967,6 +1015,7 @@ static void shader_spirv_destroy(struct wined3d_shader *shader)
} }
heap_free(program_vk->variants); heap_free(program_vk->variants);
vkd3d_shader_free_scan_descriptor_info(&program_vk->descriptor_info); vkd3d_shader_free_scan_descriptor_info(&program_vk->descriptor_info);
vkd3d_shader_free_scan_signature_info(&program_vk->signature_info);
shader->backend_data = NULL; shader->backend_data = NULL;
heap_free(program_vk); heap_free(program_vk);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment