mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
1261 lines
56 KiB
Diff
1261 lines
56 KiB
Diff
From 06cbe6c7a5b6966c8e743aa08552e84190b16b09 Mon Sep 17 00:00:00 2001
|
|
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
|
|
Date: Tue, 3 Sep 2024 07:18:49 +1000
|
|
Subject: [PATCH] Updated vkd3d to 6d28cc131b0cad61c681aed6b9f6611a12b352d1.
|
|
|
|
---
|
|
libs/vkd3d/include/private/vkd3d_common.h | 2 +-
|
|
libs/vkd3d/libs/vkd3d-common/blob.c | 1 +
|
|
libs/vkd3d/libs/vkd3d-shader/checksum.c | 49 ++++---
|
|
libs/vkd3d/libs/vkd3d-shader/d3dbc.c | 40 +++---
|
|
libs/vkd3d/libs/vkd3d-shader/dxbc.c | 19 ++-
|
|
libs/vkd3d/libs/vkd3d-shader/fx.c | 95 ++++++------
|
|
libs/vkd3d/libs/vkd3d-shader/hlsl.h | 6 +-
|
|
libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c | 10 +-
|
|
libs/vkd3d/libs/vkd3d-shader/preproc.l | 1 +
|
|
libs/vkd3d/libs/vkd3d-shader/spirv.c | 66 ++++-----
|
|
libs/vkd3d/libs/vkd3d-shader/tpf.c | 136 +++++++++---------
|
|
.../libs/vkd3d-shader/vkd3d_shader_main.c | 107 ++++++++++----
|
|
.../libs/vkd3d-shader/vkd3d_shader_private.h | 9 +-
|
|
13 files changed, 316 insertions(+), 225 deletions(-)
|
|
|
|
diff --git a/libs/vkd3d/include/private/vkd3d_common.h b/libs/vkd3d/include/private/vkd3d_common.h
|
|
index 39145a97df1..c62dc00415f 100644
|
|
--- a/libs/vkd3d/include/private/vkd3d_common.h
|
|
+++ b/libs/vkd3d/include/private/vkd3d_common.h
|
|
@@ -273,7 +273,7 @@ static inline unsigned int vkd3d_popcount(unsigned int v)
|
|
{
|
|
#ifdef _MSC_VER
|
|
return __popcnt(v);
|
|
-#elif defined(__MINGW32__)
|
|
+#elif defined(HAVE_BUILTIN_POPCOUNT)
|
|
return __builtin_popcount(v);
|
|
#else
|
|
v -= (v >> 1) & 0x55555555;
|
|
diff --git a/libs/vkd3d/libs/vkd3d-common/blob.c b/libs/vkd3d/libs/vkd3d-common/blob.c
|
|
index f60ef7db769..c2c6ad67804 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-common/blob.c
|
|
+++ b/libs/vkd3d/libs/vkd3d-common/blob.c
|
|
@@ -20,6 +20,7 @@
|
|
#define WIDL_C_INLINE_WRAPPERS
|
|
#endif
|
|
#define COBJMACROS
|
|
+
|
|
#define CONST_VTABLE
|
|
#include "vkd3d.h"
|
|
#include "vkd3d_blob.h"
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/checksum.c b/libs/vkd3d/libs/vkd3d-shader/checksum.c
|
|
index d9560628c77..45de1c92513 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/checksum.c
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/checksum.c
|
|
@@ -33,6 +33,11 @@
|
|
* will fill a supplied 16-byte array with the digest.
|
|
*/
|
|
|
|
+/*
|
|
+ * DXBC uses a variation of the MD5 algorithm, which only changes the way
|
|
+ * the message is padded in the final step.
|
|
+ */
|
|
+
|
|
#include "vkd3d_shader_private.h"
|
|
|
|
#define DXBC_CHECKSUM_BLOCK_SIZE 64
|
|
@@ -230,10 +235,9 @@ static void md5_update(struct md5_ctx *ctx, const unsigned char *buf, unsigned i
|
|
memcpy(ctx->in, buf, len);
|
|
}
|
|
|
|
-static void dxbc_checksum_final(struct md5_ctx *ctx)
|
|
+static void md5_final(struct md5_ctx *ctx, enum vkd3d_md5_variant variant)
|
|
{
|
|
unsigned int padding;
|
|
- unsigned int length;
|
|
unsigned int count;
|
|
unsigned char *p;
|
|
|
|
@@ -260,7 +264,7 @@ static void dxbc_checksum_final(struct md5_ctx *ctx)
|
|
/* Now fill the next block */
|
|
memset(ctx->in, 0, DXBC_CHECKSUM_BLOCK_SIZE);
|
|
}
|
|
- else
|
|
+ else if (variant == VKD3D_MD5_DXBC)
|
|
{
|
|
/* Make place for bitcount at the beginning of the block */
|
|
memmove(&ctx->in[4], ctx->in, count);
|
|
@@ -268,33 +272,44 @@ static void dxbc_checksum_final(struct md5_ctx *ctx)
|
|
/* Pad block to 60 bytes */
|
|
memset(p + 4, 0, padding - 4);
|
|
}
|
|
+ else
|
|
+ {
|
|
+ /* Pad block to 56 bytes */
|
|
+ memset(p, 0, padding - 8);
|
|
+ }
|
|
|
|
/* Append length in bits and transform */
|
|
- length = ctx->i[0];
|
|
- memcpy(&ctx->in[0], &length, sizeof(length));
|
|
- byte_reverse(&ctx->in[4], 14);
|
|
- length = ctx->i[0] >> 2 | 0x1;
|
|
- memcpy(&ctx->in[DXBC_CHECKSUM_BLOCK_SIZE - 4], &length, sizeof(length));
|
|
+ if (variant == VKD3D_MD5_DXBC)
|
|
+ {
|
|
+ unsigned int length;
|
|
+
|
|
+ length = ctx->i[0];
|
|
+ memcpy(&ctx->in[0], &length, sizeof(length));
|
|
+ byte_reverse(&ctx->in[4], 14);
|
|
+ length = ctx->i[0] >> 2 | 0x1;
|
|
+ memcpy(&ctx->in[DXBC_CHECKSUM_BLOCK_SIZE - 4], &length, sizeof(length));
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ byte_reverse(ctx->in, 14);
|
|
+
|
|
+ ((unsigned int *)ctx->in)[14] = ctx->i[0];
|
|
+ ((unsigned int *)ctx->in)[15] = ctx->i[1];
|
|
+ }
|
|
|
|
md5_transform(ctx->buf, (unsigned int *)ctx->in);
|
|
byte_reverse((unsigned char *)ctx->buf, 4);
|
|
memcpy(ctx->digest, ctx->buf, 16);
|
|
}
|
|
|
|
-#define DXBC_CHECKSUM_SKIP_BYTE_COUNT 20
|
|
-
|
|
-void vkd3d_compute_dxbc_checksum(const void *dxbc, size_t size, uint32_t checksum[4])
|
|
+void vkd3d_compute_md5(const void *data, size_t size, uint32_t checksum[4], enum vkd3d_md5_variant variant)
|
|
{
|
|
- const uint8_t *ptr = dxbc;
|
|
+ const uint8_t *ptr = data;
|
|
struct md5_ctx ctx;
|
|
|
|
- VKD3D_ASSERT(size > DXBC_CHECKSUM_SKIP_BYTE_COUNT);
|
|
- ptr += DXBC_CHECKSUM_SKIP_BYTE_COUNT;
|
|
- size -= DXBC_CHECKSUM_SKIP_BYTE_COUNT;
|
|
-
|
|
md5_init(&ctx);
|
|
md5_update(&ctx, ptr, size);
|
|
- dxbc_checksum_final(&ctx);
|
|
+ md5_final(&ctx, variant);
|
|
|
|
memcpy(checksum, ctx.digest, sizeof(ctx.digest));
|
|
}
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
|
index d05394c3ab7..1145a91f3e6 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
|
@@ -1423,32 +1423,32 @@ bool hlsl_sm1_register_from_semantic(const struct vkd3d_shader_version *version,
|
|
}
|
|
|
|
bool hlsl_sm1_usage_from_semantic(const char *semantic_name,
|
|
- uint32_t semantic_index, D3DDECLUSAGE *usage, uint32_t *usage_idx)
|
|
+ uint32_t semantic_index, enum vkd3d_decl_usage *usage, uint32_t *usage_idx)
|
|
{
|
|
static const struct
|
|
{
|
|
const char *name;
|
|
- D3DDECLUSAGE usage;
|
|
+ enum vkd3d_decl_usage usage;
|
|
}
|
|
semantics[] =
|
|
{
|
|
- {"binormal", D3DDECLUSAGE_BINORMAL},
|
|
- {"blendindices", D3DDECLUSAGE_BLENDINDICES},
|
|
- {"blendweight", D3DDECLUSAGE_BLENDWEIGHT},
|
|
- {"color", D3DDECLUSAGE_COLOR},
|
|
- {"depth", D3DDECLUSAGE_DEPTH},
|
|
- {"fog", D3DDECLUSAGE_FOG},
|
|
- {"normal", D3DDECLUSAGE_NORMAL},
|
|
- {"position", D3DDECLUSAGE_POSITION},
|
|
- {"positiont", D3DDECLUSAGE_POSITIONT},
|
|
- {"psize", D3DDECLUSAGE_PSIZE},
|
|
- {"sample", D3DDECLUSAGE_SAMPLE},
|
|
- {"sv_depth", D3DDECLUSAGE_DEPTH},
|
|
- {"sv_position", D3DDECLUSAGE_POSITION},
|
|
- {"sv_target", D3DDECLUSAGE_COLOR},
|
|
- {"tangent", D3DDECLUSAGE_TANGENT},
|
|
- {"tessfactor", D3DDECLUSAGE_TESSFACTOR},
|
|
- {"texcoord", D3DDECLUSAGE_TEXCOORD},
|
|
+ {"binormal", VKD3D_DECL_USAGE_BINORMAL},
|
|
+ {"blendindices", VKD3D_DECL_USAGE_BLEND_INDICES},
|
|
+ {"blendweight", VKD3D_DECL_USAGE_BLEND_WEIGHT},
|
|
+ {"color", VKD3D_DECL_USAGE_COLOR},
|
|
+ {"depth", VKD3D_DECL_USAGE_DEPTH},
|
|
+ {"fog", VKD3D_DECL_USAGE_FOG},
|
|
+ {"normal", VKD3D_DECL_USAGE_NORMAL},
|
|
+ {"position", VKD3D_DECL_USAGE_POSITION},
|
|
+ {"positiont", VKD3D_DECL_USAGE_POSITIONT},
|
|
+ {"psize", VKD3D_DECL_USAGE_PSIZE},
|
|
+ {"sample", VKD3D_DECL_USAGE_SAMPLE},
|
|
+ {"sv_depth", VKD3D_DECL_USAGE_DEPTH},
|
|
+ {"sv_position", VKD3D_DECL_USAGE_POSITION},
|
|
+ {"sv_target", VKD3D_DECL_USAGE_COLOR},
|
|
+ {"tangent", VKD3D_DECL_USAGE_TANGENT},
|
|
+ {"tessfactor", VKD3D_DECL_USAGE_TESS_FACTOR},
|
|
+ {"texcoord", VKD3D_DECL_USAGE_TEXCOORD},
|
|
};
|
|
|
|
unsigned int i;
|
|
@@ -2203,8 +2203,8 @@ static void d3dbc_write_semantic_dcl(struct d3dbc_compiler *d3dbc,
|
|
const struct vkd3d_shader_version *version = &d3dbc->program->shader_version;
|
|
struct vkd3d_bytecode_buffer *buffer = &d3dbc->buffer;
|
|
struct sm1_dst_register reg = {0};
|
|
+ enum vkd3d_decl_usage usage;
|
|
uint32_t token, usage_idx;
|
|
- D3DDECLUSAGE usage;
|
|
bool ret;
|
|
|
|
if (hlsl_sm1_register_from_semantic(version, element->semantic_name,
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/dxbc.c b/libs/vkd3d/libs/vkd3d-shader/dxbc.c
|
|
index 184788dc57e..93fc993e0d1 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/dxbc.c
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/dxbc.c
|
|
@@ -20,6 +20,19 @@
|
|
|
|
#include "vkd3d_shader_private.h"
|
|
|
|
+#define DXBC_CHECKSUM_SKIP_BYTE_COUNT 20
|
|
+
|
|
+static void compute_dxbc_checksum(const void *dxbc, size_t size, uint32_t checksum[4])
|
|
+{
|
|
+ const uint8_t *ptr = dxbc;
|
|
+
|
|
+ VKD3D_ASSERT(size > DXBC_CHECKSUM_SKIP_BYTE_COUNT);
|
|
+ ptr += DXBC_CHECKSUM_SKIP_BYTE_COUNT;
|
|
+ size -= DXBC_CHECKSUM_SKIP_BYTE_COUNT;
|
|
+
|
|
+ vkd3d_compute_md5(ptr, size, checksum, VKD3D_MD5_DXBC);
|
|
+}
|
|
+
|
|
void dxbc_writer_init(struct dxbc_writer *dxbc)
|
|
{
|
|
memset(dxbc, 0, sizeof(*dxbc));
|
|
@@ -72,7 +85,7 @@ int vkd3d_shader_serialize_dxbc(size_t section_count, const struct vkd3d_shader_
|
|
}
|
|
set_u32(&buffer, size_position, bytecode_get_size(&buffer));
|
|
|
|
- vkd3d_compute_dxbc_checksum(buffer.data, buffer.size, checksum);
|
|
+ compute_dxbc_checksum(buffer.data, buffer.size, checksum);
|
|
for (i = 0; i < 4; ++i)
|
|
set_u32(&buffer, checksum_position + i * sizeof(uint32_t), checksum[i]);
|
|
|
|
@@ -188,7 +201,7 @@ static int parse_dxbc(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_
|
|
checksum[3] = read_u32(&ptr);
|
|
if (!(flags & VKD3D_SHADER_PARSE_DXBC_IGNORE_CHECKSUM))
|
|
{
|
|
- vkd3d_compute_dxbc_checksum(data, data_size, calculated_checksum);
|
|
+ compute_dxbc_checksum(data, data_size, calculated_checksum);
|
|
if (memcmp(checksum, calculated_checksum, sizeof(checksum)))
|
|
{
|
|
WARN("Checksum {0x%08x, 0x%08x, 0x%08x, 0x%08x} does not match "
|
|
@@ -1488,7 +1501,7 @@ int vkd3d_shader_serialize_root_signature(const struct vkd3d_shader_versioned_ro
|
|
dxbc->code = context.buffer.data;
|
|
dxbc->size = total_size;
|
|
|
|
- vkd3d_compute_dxbc_checksum(dxbc->code, dxbc->size, checksum);
|
|
+ compute_dxbc_checksum(dxbc->code, dxbc->size, checksum);
|
|
for (i = 0; i < 4; ++i)
|
|
set_u32(&context.buffer, (i + 1) * sizeof(uint32_t), checksum[i]);
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/fx.c b/libs/vkd3d/libs/vkd3d-shader/fx.c
|
|
index a1d1fd6572f..e3ab71fb386 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/fx.c
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/fx.c
|
|
@@ -575,6 +575,12 @@ static const char * get_fx_4_type_name(const struct hlsl_type *type)
|
|
}
|
|
}
|
|
|
|
+static bool is_numeric_fx_4_type(const struct hlsl_type *type)
|
|
+{
|
|
+ type = hlsl_get_multiarray_element_type(type);
|
|
+ return type->class == HLSL_CLASS_STRUCT || hlsl_is_numeric_type(type);
|
|
+}
|
|
+
|
|
static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_context *fx)
|
|
{
|
|
struct field_offsets
|
|
@@ -584,43 +590,41 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
|
|
uint32_t offset;
|
|
uint32_t type;
|
|
};
|
|
- uint32_t name_offset, offset, total_size, packed_size, stride, numeric_desc;
|
|
+ uint32_t name_offset, offset, unpacked_size, packed_size, stride, numeric_desc;
|
|
struct vkd3d_bytecode_buffer *buffer = &fx->unstructured;
|
|
struct field_offsets *field_offsets = NULL;
|
|
+ const struct hlsl_type *element_type;
|
|
struct hlsl_ctx *ctx = fx->ctx;
|
|
uint32_t elements_count = 0;
|
|
const char *name;
|
|
size_t i;
|
|
|
|
- /* Resolve arrays to element type and number of elements. */
|
|
if (type->class == HLSL_CLASS_ARRAY)
|
|
- {
|
|
elements_count = hlsl_get_multiarray_size(type);
|
|
- type = hlsl_get_multiarray_element_type(type);
|
|
- }
|
|
+ element_type = hlsl_get_multiarray_element_type(type);
|
|
|
|
- name = get_fx_4_type_name(type);
|
|
+ name = get_fx_4_type_name(element_type);
|
|
|
|
name_offset = write_string(name, fx);
|
|
- if (type->class == HLSL_CLASS_STRUCT)
|
|
+ if (element_type->class == HLSL_CLASS_STRUCT)
|
|
{
|
|
- if (!(field_offsets = hlsl_calloc(ctx, type->e.record.field_count, sizeof(*field_offsets))))
|
|
+ if (!(field_offsets = hlsl_calloc(ctx, element_type->e.record.field_count, sizeof(*field_offsets))))
|
|
return 0;
|
|
|
|
- for (i = 0; i < type->e.record.field_count; ++i)
|
|
+ for (i = 0; i < element_type->e.record.field_count; ++i)
|
|
{
|
|
- const struct hlsl_struct_field *field = &type->e.record.fields[i];
|
|
+ const struct hlsl_struct_field *field = &element_type->e.record.fields[i];
|
|
|
|
field_offsets[i].name = write_string(field->name, fx);
|
|
field_offsets[i].semantic = write_string(field->semantic.raw_name, fx);
|
|
- field_offsets[i].offset = field->reg_offset[HLSL_REGSET_NUMERIC];
|
|
+ field_offsets[i].offset = field->reg_offset[HLSL_REGSET_NUMERIC] * sizeof(float);
|
|
field_offsets[i].type = write_type(field->type, fx);
|
|
}
|
|
}
|
|
|
|
offset = put_u32_unaligned(buffer, name_offset);
|
|
|
|
- switch (type->class)
|
|
+ switch (element_type->class)
|
|
{
|
|
case HLSL_CLASS_SCALAR:
|
|
case HLSL_CLASS_VECTOR:
|
|
@@ -659,32 +663,32 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
|
|
vkd3d_unreachable();
|
|
|
|
case HLSL_CLASS_VOID:
|
|
- FIXME("Writing type class %u is not implemented.\n", type->class);
|
|
+ FIXME("Writing type class %u is not implemented.\n", element_type->class);
|
|
set_status(fx, VKD3D_ERROR_NOT_IMPLEMENTED);
|
|
return 0;
|
|
}
|
|
|
|
/* Structures can only contain numeric fields, this is validated during variable declaration. */
|
|
- total_size = stride = type->reg_size[HLSL_REGSET_NUMERIC] * sizeof(float);
|
|
+ unpacked_size = type->reg_size[HLSL_REGSET_NUMERIC] * sizeof(float);
|
|
+
|
|
packed_size = 0;
|
|
- if (type->class == HLSL_CLASS_STRUCT || hlsl_is_numeric_type(type))
|
|
- packed_size = hlsl_type_component_count(type) * sizeof(float);
|
|
+ if (is_numeric_fx_4_type(element_type))
|
|
+ packed_size = hlsl_type_component_count(element_type) * sizeof(float);
|
|
if (elements_count)
|
|
- {
|
|
- total_size *= elements_count;
|
|
packed_size *= elements_count;
|
|
- }
|
|
+
|
|
+ stride = element_type->reg_size[HLSL_REGSET_NUMERIC] * sizeof(float);
|
|
stride = align(stride, 4 * sizeof(float));
|
|
|
|
put_u32_unaligned(buffer, elements_count);
|
|
- put_u32_unaligned(buffer, total_size);
|
|
+ put_u32_unaligned(buffer, unpacked_size);
|
|
put_u32_unaligned(buffer, stride);
|
|
put_u32_unaligned(buffer, packed_size);
|
|
|
|
- if (type->class == HLSL_CLASS_STRUCT)
|
|
+ if (element_type->class == HLSL_CLASS_STRUCT)
|
|
{
|
|
- put_u32_unaligned(buffer, type->e.record.field_count);
|
|
- for (i = 0; i < type->e.record.field_count; ++i)
|
|
+ put_u32_unaligned(buffer, element_type->e.record.field_count);
|
|
+ for (i = 0; i < element_type->e.record.field_count; ++i)
|
|
{
|
|
const struct field_offsets *field = &field_offsets[i];
|
|
|
|
@@ -700,7 +704,7 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
|
|
put_u32_unaligned(buffer, 0); /* Interface count */
|
|
}
|
|
}
|
|
- else if (type->class == HLSL_CLASS_TEXTURE)
|
|
+ else if (element_type->class == HLSL_CLASS_TEXTURE)
|
|
{
|
|
static const uint32_t texture_type[] =
|
|
{
|
|
@@ -716,13 +720,13 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
|
|
[HLSL_SAMPLER_DIM_CUBEARRAY] = 23,
|
|
};
|
|
|
|
- put_u32_unaligned(buffer, texture_type[type->sampler_dim]);
|
|
+ put_u32_unaligned(buffer, texture_type[element_type->sampler_dim]);
|
|
}
|
|
- else if (type->class == HLSL_CLASS_SAMPLER)
|
|
+ else if (element_type->class == HLSL_CLASS_SAMPLER)
|
|
{
|
|
put_u32_unaligned(buffer, 21);
|
|
}
|
|
- else if (type->class == HLSL_CLASS_UAV)
|
|
+ else if (element_type->class == HLSL_CLASS_UAV)
|
|
{
|
|
static const uint32_t uav_type[] =
|
|
{
|
|
@@ -735,60 +739,60 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
|
|
[HLSL_SAMPLER_DIM_STRUCTURED_BUFFER] = 40,
|
|
};
|
|
|
|
- put_u32_unaligned(buffer, uav_type[type->sampler_dim]);
|
|
+ put_u32_unaligned(buffer, uav_type[element_type->sampler_dim]);
|
|
}
|
|
- else if (type->class == HLSL_CLASS_DEPTH_STENCIL_VIEW)
|
|
+ else if (element_type->class == HLSL_CLASS_DEPTH_STENCIL_VIEW)
|
|
{
|
|
put_u32_unaligned(buffer, 20);
|
|
}
|
|
- else if (type->class == HLSL_CLASS_RENDER_TARGET_VIEW)
|
|
+ else if (element_type->class == HLSL_CLASS_RENDER_TARGET_VIEW)
|
|
{
|
|
put_u32_unaligned(buffer, 19);
|
|
}
|
|
- else if (type->class == HLSL_CLASS_PIXEL_SHADER)
|
|
+ else if (element_type->class == HLSL_CLASS_PIXEL_SHADER)
|
|
{
|
|
put_u32_unaligned(buffer, 5);
|
|
}
|
|
- else if (type->class == HLSL_CLASS_VERTEX_SHADER)
|
|
+ else if (element_type->class == HLSL_CLASS_VERTEX_SHADER)
|
|
{
|
|
put_u32_unaligned(buffer, 6);
|
|
}
|
|
- else if (type->class == HLSL_CLASS_RASTERIZER_STATE)
|
|
+ else if (element_type->class == HLSL_CLASS_RASTERIZER_STATE)
|
|
{
|
|
put_u32_unaligned(buffer, 4);
|
|
}
|
|
- else if (type->class == HLSL_CLASS_DEPTH_STENCIL_STATE)
|
|
+ else if (element_type->class == HLSL_CLASS_DEPTH_STENCIL_STATE)
|
|
{
|
|
put_u32_unaligned(buffer, 3);
|
|
}
|
|
- else if (type->class == HLSL_CLASS_BLEND_STATE)
|
|
+ else if (element_type->class == HLSL_CLASS_BLEND_STATE)
|
|
{
|
|
put_u32_unaligned(buffer, 2);
|
|
}
|
|
- else if (type->class == HLSL_CLASS_STRING)
|
|
+ else if (element_type->class == HLSL_CLASS_STRING)
|
|
{
|
|
put_u32_unaligned(buffer, 1);
|
|
}
|
|
- else if (hlsl_is_numeric_type(type))
|
|
+ else if (hlsl_is_numeric_type(element_type))
|
|
{
|
|
- numeric_desc = get_fx_4_numeric_type_description(type, fx);
|
|
+ numeric_desc = get_fx_4_numeric_type_description(element_type, fx);
|
|
put_u32_unaligned(buffer, numeric_desc);
|
|
}
|
|
- else if (type->class == HLSL_CLASS_COMPUTE_SHADER)
|
|
+ else if (element_type->class == HLSL_CLASS_COMPUTE_SHADER)
|
|
{
|
|
put_u32_unaligned(buffer, 28);
|
|
}
|
|
- else if (type->class == HLSL_CLASS_HULL_SHADER)
|
|
+ else if (element_type->class == HLSL_CLASS_HULL_SHADER)
|
|
{
|
|
put_u32_unaligned(buffer, 29);
|
|
}
|
|
- else if (type->class == HLSL_CLASS_DOMAIN_SHADER)
|
|
+ else if (element_type->class == HLSL_CLASS_DOMAIN_SHADER)
|
|
{
|
|
put_u32_unaligned(buffer, 30);
|
|
}
|
|
else
|
|
{
|
|
- FIXME("Type %u is not supported.\n", type->class);
|
|
+ FIXME("Type %u is not supported.\n", element_type->class);
|
|
set_status(fx, VKD3D_ERROR_NOT_IMPLEMENTED);
|
|
}
|
|
|
|
@@ -2126,7 +2130,7 @@ static unsigned int decompose_fx_4_state_function_call(struct hlsl_ir_var *var,
|
|
}
|
|
|
|
/* For some states assignment sets all of the elements. This behaviour is limited to certain states of BlendState
|
|
- object, and only when fx_5_0 profile is used. */
|
|
+ object, and only when fx_4_1 or fx_5_0 profile is used. */
|
|
static unsigned int decompose_fx_4_state_block_expand_array(struct hlsl_ir_var *var, struct hlsl_state_block *block,
|
|
unsigned int entry_index, struct fx_write_context *fx)
|
|
{
|
|
@@ -2140,7 +2144,7 @@ static unsigned int decompose_fx_4_state_block_expand_array(struct hlsl_ir_var *
|
|
|
|
if (type->class != HLSL_CLASS_BLEND_STATE)
|
|
return 1;
|
|
- if (ctx->profile->major_version != 5)
|
|
+ if (hlsl_version_lt(ctx, 4, 1))
|
|
return 1;
|
|
if (entry->lhs_has_index)
|
|
return 1;
|
|
@@ -2401,6 +2405,9 @@ static void write_fx_4_buffer(struct hlsl_buffer *b, struct fx_write_context *fx
|
|
size = 0;
|
|
LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
|
|
{
|
|
+ if (!is_numeric_fx_4_type(var->data_type))
|
|
+ continue;
|
|
+
|
|
if (var->buffer != b)
|
|
continue;
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.h b/libs/vkd3d/libs/vkd3d-shader/hlsl.h
|
|
index 22e25b23988..bf38c0cd945 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.h
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.h
|
|
@@ -1528,7 +1528,7 @@ D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type);
|
|
bool hlsl_sm1_register_from_semantic(const struct vkd3d_shader_version *version, const char *semantic_name,
|
|
unsigned int semantic_index, bool output, enum vkd3d_shader_register_type *type, unsigned int *reg);
|
|
bool hlsl_sm1_usage_from_semantic(const char *semantic_name,
|
|
- uint32_t semantic_index, D3DDECLUSAGE *usage, uint32_t *usage_idx);
|
|
+ uint32_t semantic_index, enum vkd3d_decl_usage *usage, uint32_t *usage_idx);
|
|
|
|
void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer);
|
|
int d3dbc_compile(struct vsir_program *program, uint64_t config_flags,
|
|
@@ -1536,8 +1536,8 @@ int d3dbc_compile(struct vsir_program *program, uint64_t config_flags,
|
|
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context,
|
|
struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func);
|
|
|
|
-bool hlsl_sm4_usage_from_semantic(struct hlsl_ctx *ctx,
|
|
- const struct hlsl_semantic *semantic, bool output, D3D_NAME *usage);
|
|
+bool sysval_semantic_from_hlsl(enum vkd3d_shader_sysval_semantic *semantic,
|
|
+ struct hlsl_ctx *ctx, const struct hlsl_semantic *hlsl_semantic, bool output);
|
|
bool hlsl_sm4_register_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semantic *semantic,
|
|
bool output, enum vkd3d_shader_register_type *type, bool *has_idx);
|
|
int hlsl_sm4_write(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func, struct vkd3d_shader_code *out);
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
|
|
index 92b5c71c43f..154328a64c3 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
|
|
@@ -5128,7 +5128,7 @@ static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var
|
|
if (ctx->profile->major_version < 4)
|
|
{
|
|
struct vkd3d_shader_version version;
|
|
- D3DDECLUSAGE usage;
|
|
+ enum vkd3d_decl_usage usage;
|
|
uint32_t usage_idx;
|
|
|
|
/* ps_1_* outputs are special and go in temp register 0. */
|
|
@@ -5152,10 +5152,10 @@ static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var
|
|
}
|
|
else
|
|
{
|
|
- D3D_NAME usage;
|
|
+ enum vkd3d_shader_sysval_semantic semantic;
|
|
bool has_idx;
|
|
|
|
- if (!hlsl_sm4_usage_from_semantic(ctx, &var->semantic, output, &usage))
|
|
+ if (!sysval_semantic_from_hlsl(&semantic, ctx, &var->semantic, output))
|
|
{
|
|
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
|
|
"Invalid semantic '%s'.", var->semantic.name);
|
|
@@ -5956,8 +5956,8 @@ static void sm1_generate_vsir_signature_entry(struct hlsl_ctx *ctx,
|
|
if (!hlsl_sm1_register_from_semantic(&program->shader_version,
|
|
var->semantic.name, var->semantic.index, output, &type, ®ister_index))
|
|
{
|
|
+ enum vkd3d_decl_usage usage;
|
|
unsigned int usage_idx;
|
|
- D3DDECLUSAGE usage;
|
|
bool ret;
|
|
|
|
register_index = var->regs[HLSL_REGSET_NUMERIC].id;
|
|
@@ -5969,7 +5969,7 @@ static void sm1_generate_vsir_signature_entry(struct hlsl_ctx *ctx,
|
|
* SV_Position; the closer equivalent is VPOS, which is not declared
|
|
* as a semantic. */
|
|
if (program->shader_version.type == VKD3D_SHADER_TYPE_VERTEX
|
|
- && output && usage == D3DDECLUSAGE_POSITION)
|
|
+ && output && usage == VKD3D_DECL_USAGE_POSITION)
|
|
sysval = VKD3D_SHADER_SV_POSITION;
|
|
}
|
|
mask = (1 << var->data_type->dimx) - 1;
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/preproc.l b/libs/vkd3d/libs/vkd3d-shader/preproc.l
|
|
index 2b7455a5c30..7fc963192cf 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/preproc.l
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/preproc.l
|
|
@@ -20,6 +20,7 @@
|
|
|
|
%{
|
|
|
|
+#include "preproc.h"
|
|
#include "preproc.tab.h"
|
|
|
|
#undef ERROR /* defined in wingdi.h */
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/spirv.c b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
|
index 49979ab2491..8052e951704 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
|
@@ -6120,12 +6120,12 @@ static void spirv_compiler_decorate_descriptor(struct spirv_compiler *compiler,
|
|
static uint32_t spirv_compiler_build_descriptor_variable(struct spirv_compiler *compiler,
|
|
SpvStorageClass storage_class, uint32_t type_id, const struct vkd3d_shader_register *reg,
|
|
const struct vkd3d_shader_register_range *range, enum vkd3d_shader_resource_type resource_type,
|
|
- bool is_uav, bool is_uav_counter, struct vkd3d_descriptor_variable_info *var_info)
|
|
+ const struct vkd3d_shader_descriptor_info1 *descriptor, bool is_uav_counter,
|
|
+ struct vkd3d_descriptor_variable_info *var_info)
|
|
{
|
|
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
|
|
struct vkd3d_descriptor_binding_address binding_address;
|
|
struct vkd3d_shader_descriptor_binding binding;
|
|
- const struct vkd3d_shader_descriptor_info1 *d;
|
|
uint32_t array_type_id, ptr_type_id, var_id;
|
|
bool write_only = false, coherent = false;
|
|
struct vkd3d_symbol symbol;
|
|
@@ -6135,12 +6135,11 @@ static uint32_t spirv_compiler_build_descriptor_variable(struct spirv_compiler *
|
|
resource_type, is_uav_counter, &binding_address);
|
|
var_info->binding_base_idx = binding_address.binding_base_idx;
|
|
|
|
- if (is_uav)
|
|
+ if (descriptor->type == VKD3D_SHADER_DESCRIPTOR_TYPE_UAV && !is_uav_counter)
|
|
{
|
|
- d = spirv_compiler_get_descriptor_info(compiler, VKD3D_SHADER_DESCRIPTOR_TYPE_UAV, range);
|
|
- write_only = !(d->flags & VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_READ);
|
|
+ write_only = !(descriptor->flags & VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_READ);
|
|
/* ROVs are implicitly globally coherent. */
|
|
- coherent = d->uav_flags & (VKD3DSUF_GLOBALLY_COHERENT | VKD3DSUF_RASTERISER_ORDERED_VIEW);
|
|
+ coherent = descriptor->uav_flags & (VKD3DSUF_GLOBALLY_COHERENT | VKD3DSUF_RASTERISER_ORDERED_VIEW);
|
|
}
|
|
|
|
if (binding.count == 1 && range->first == binding_address.binding_base_idx && range->last != ~0u
|
|
@@ -6194,11 +6193,12 @@ static uint32_t spirv_compiler_build_descriptor_variable(struct spirv_compiler *
|
|
}
|
|
|
|
static void spirv_compiler_emit_cbv_declaration(struct spirv_compiler *compiler,
|
|
- const struct vkd3d_shader_register_range *range, unsigned int register_id, unsigned int size_in_bytes)
|
|
+ const struct vkd3d_shader_register_range *range, const struct vkd3d_shader_descriptor_info1 *descriptor)
|
|
{
|
|
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
|
|
uint32_t vec4_id, array_type_id, length_id, struct_id, var_id;
|
|
const SpvStorageClass storage_class = SpvStorageClassUniform;
|
|
+ unsigned int size_in_bytes = descriptor->buffer_size;
|
|
struct vkd3d_push_constant_buffer_binding *push_cb;
|
|
struct vkd3d_descriptor_variable_info var_info;
|
|
struct vkd3d_shader_register reg;
|
|
@@ -6206,7 +6206,7 @@ static void spirv_compiler_emit_cbv_declaration(struct spirv_compiler *compiler,
|
|
unsigned int size;
|
|
|
|
vsir_register_init(®, VKD3DSPR_CONSTBUFFER, VKD3D_DATA_FLOAT, 3);
|
|
- reg.idx[0].offset = register_id;
|
|
+ reg.idx[0].offset = descriptor->register_id;
|
|
reg.idx[1].offset = range->first;
|
|
reg.idx[2].offset = range->last;
|
|
|
|
@@ -6239,7 +6239,7 @@ static void spirv_compiler_emit_cbv_declaration(struct spirv_compiler *compiler,
|
|
vkd3d_spirv_build_op_name(builder, struct_id, "cb%u_struct", size);
|
|
|
|
var_id = spirv_compiler_build_descriptor_variable(compiler, storage_class, struct_id,
|
|
- ®, range, VKD3D_SHADER_RESOURCE_BUFFER, false, false, &var_info);
|
|
+ ®, range, VKD3D_SHADER_RESOURCE_BUFFER, descriptor, false, &var_info);
|
|
|
|
vkd3d_symbol_make_register(®_symbol, ®);
|
|
vkd3d_symbol_set_register_info(®_symbol, var_id, storage_class,
|
|
@@ -6275,7 +6275,7 @@ static void spirv_compiler_emit_dcl_immediate_constant_buffer(struct spirv_compi
|
|
}
|
|
|
|
static void spirv_compiler_emit_sampler_declaration(struct spirv_compiler *compiler,
|
|
- const struct vkd3d_shader_register_range *range, unsigned int register_id)
|
|
+ const struct vkd3d_shader_register_range *range, const struct vkd3d_shader_descriptor_info1 *descriptor)
|
|
{
|
|
const SpvStorageClass storage_class = SpvStorageClassUniformConstant;
|
|
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
|
|
@@ -6285,7 +6285,7 @@ static void spirv_compiler_emit_sampler_declaration(struct spirv_compiler *compi
|
|
uint32_t type_id, var_id;
|
|
|
|
vsir_register_init(®, VKD3DSPR_SAMPLER, VKD3D_DATA_FLOAT, 1);
|
|
- reg.idx[0].offset = register_id;
|
|
+ reg.idx[0].offset = descriptor->register_id;
|
|
|
|
vkd3d_symbol_make_sampler(®_symbol, ®);
|
|
reg_symbol.info.sampler.range = *range;
|
|
@@ -6295,8 +6295,8 @@ static void spirv_compiler_emit_sampler_declaration(struct spirv_compiler *compi
|
|
return;
|
|
|
|
type_id = vkd3d_spirv_get_op_type_sampler(builder);
|
|
- var_id = spirv_compiler_build_descriptor_variable(compiler, storage_class, type_id, ®,
|
|
- range, VKD3D_SHADER_RESOURCE_NONE, false, false, &var_info);
|
|
+ var_id = spirv_compiler_build_descriptor_variable(compiler, storage_class, type_id,
|
|
+ ®, range, VKD3D_SHADER_RESOURCE_NONE, descriptor, false, &var_info);
|
|
|
|
vkd3d_symbol_make_register(®_symbol, ®);
|
|
vkd3d_symbol_set_register_info(®_symbol, var_id, storage_class,
|
|
@@ -6461,21 +6461,24 @@ static void spirv_compiler_emit_combined_sampler_declarations(struct spirv_compi
|
|
}
|
|
|
|
static void spirv_compiler_emit_resource_declaration(struct spirv_compiler *compiler,
|
|
- const struct vkd3d_shader_register_range *range, unsigned int register_id,
|
|
- unsigned int sample_count, bool is_uav, enum vkd3d_shader_resource_type resource_type,
|
|
- enum vkd3d_shader_resource_data_type resource_data_type, unsigned int structure_stride, bool raw)
|
|
+ const struct vkd3d_shader_register_range *range, const struct vkd3d_shader_descriptor_info1 *descriptor)
|
|
{
|
|
+ bool raw = descriptor->flags & VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_RAW_BUFFER;
|
|
+ enum vkd3d_shader_resource_type resource_type = descriptor->resource_type;
|
|
struct vkd3d_descriptor_variable_info var_info, counter_var_info = {0};
|
|
+ bool is_uav = descriptor->type == VKD3D_SHADER_DESCRIPTOR_TYPE_UAV;
|
|
+ unsigned int structure_stride = descriptor->structure_stride / 4;
|
|
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
|
|
SpvStorageClass storage_class = SpvStorageClassUniformConstant;
|
|
uint32_t counter_type_id, type_id, var_id, counter_var_id = 0;
|
|
const struct vkd3d_spirv_resource_type *resource_type_info;
|
|
+ unsigned int sample_count = descriptor->sample_count;
|
|
enum vkd3d_shader_component_type sampled_type;
|
|
struct vkd3d_symbol resource_symbol;
|
|
struct vkd3d_shader_register reg;
|
|
|
|
vsir_register_init(®, is_uav ? VKD3DSPR_UAV : VKD3DSPR_RESOURCE, VKD3D_DATA_FLOAT, 1);
|
|
- reg.idx[0].offset = register_id;
|
|
+ reg.idx[0].offset = descriptor->register_id;
|
|
|
|
if (resource_type == VKD3D_SHADER_RESOURCE_TEXTURE_2DMS && sample_count == 1)
|
|
resource_type = VKD3D_SHADER_RESOURCE_TEXTURE_2D;
|
|
@@ -6489,7 +6492,7 @@ static void spirv_compiler_emit_resource_declaration(struct spirv_compiler *comp
|
|
return;
|
|
}
|
|
|
|
- sampled_type = vkd3d_component_type_from_resource_data_type(resource_data_type);
|
|
+ sampled_type = vkd3d_component_type_from_resource_data_type(descriptor->resource_data_type);
|
|
|
|
if (!is_uav && spirv_compiler_has_combined_sampler_for_resource(compiler, range))
|
|
{
|
|
@@ -6520,16 +6523,12 @@ static void spirv_compiler_emit_resource_declaration(struct spirv_compiler *comp
|
|
resource_type_info, sampled_type, structure_stride || raw, 0);
|
|
}
|
|
|
|
- var_id = spirv_compiler_build_descriptor_variable(compiler, storage_class, type_id, ®,
|
|
- range, resource_type, is_uav, false, &var_info);
|
|
+ var_id = spirv_compiler_build_descriptor_variable(compiler, storage_class,
|
|
+ type_id, ®, range, resource_type, descriptor, false, &var_info);
|
|
|
|
if (is_uav)
|
|
{
|
|
- const struct vkd3d_shader_descriptor_info1 *d;
|
|
-
|
|
- d = spirv_compiler_get_descriptor_info(compiler, VKD3D_SHADER_DESCRIPTOR_TYPE_UAV, range);
|
|
-
|
|
- if (d->uav_flags & VKD3DSUF_RASTERISER_ORDERED_VIEW)
|
|
+ if (descriptor->uav_flags & VKD3DSUF_RASTERISER_ORDERED_VIEW)
|
|
{
|
|
if (compiler->shader_type != VKD3D_SHADER_TYPE_PIXEL)
|
|
spirv_compiler_error(compiler, VKD3D_SHADER_ERROR_SPV_UNSUPPORTED_FEATURE,
|
|
@@ -6543,7 +6542,7 @@ static void spirv_compiler_emit_resource_declaration(struct spirv_compiler *comp
|
|
compiler->use_invocation_interlock = true;
|
|
}
|
|
|
|
- if (d->flags & VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_COUNTER)
|
|
+ if (descriptor->flags & VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_COUNTER)
|
|
{
|
|
VKD3D_ASSERT(structure_stride); /* counters are valid only for structured buffers */
|
|
|
|
@@ -6571,7 +6570,7 @@ static void spirv_compiler_emit_resource_declaration(struct spirv_compiler *comp
|
|
}
|
|
|
|
counter_var_id = spirv_compiler_build_descriptor_variable(compiler, storage_class,
|
|
- type_id, ®, range, resource_type, false, true, &counter_var_info);
|
|
+ type_id, ®, range, resource_type, descriptor, true, &counter_var_info);
|
|
}
|
|
}
|
|
|
|
@@ -10564,23 +10563,16 @@ static void spirv_compiler_emit_descriptor_declarations(struct spirv_compiler *c
|
|
switch (descriptor->type)
|
|
{
|
|
case VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER:
|
|
- spirv_compiler_emit_sampler_declaration(compiler, &range, descriptor->register_id);
|
|
+ spirv_compiler_emit_sampler_declaration(compiler, &range, descriptor);
|
|
break;
|
|
|
|
case VKD3D_SHADER_DESCRIPTOR_TYPE_CBV:
|
|
- spirv_compiler_emit_cbv_declaration(compiler, &range, descriptor->register_id, descriptor->buffer_size);
|
|
+ spirv_compiler_emit_cbv_declaration(compiler, &range, descriptor);
|
|
break;
|
|
|
|
case VKD3D_SHADER_DESCRIPTOR_TYPE_SRV:
|
|
- spirv_compiler_emit_resource_declaration(compiler, &range, descriptor->register_id,
|
|
- descriptor->sample_count, false, descriptor->resource_type, descriptor->resource_data_type,
|
|
- descriptor->structure_stride / 4, descriptor->flags & VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_RAW_BUFFER);
|
|
- break;
|
|
-
|
|
case VKD3D_SHADER_DESCRIPTOR_TYPE_UAV:
|
|
- spirv_compiler_emit_resource_declaration(compiler, &range, descriptor->register_id,
|
|
- descriptor->sample_count, true, descriptor->resource_type, descriptor->resource_data_type,
|
|
- descriptor->structure_stride / 4, descriptor->flags & VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_RAW_BUFFER);
|
|
+ spirv_compiler_emit_resource_declaration(compiler, &range, descriptor);
|
|
break;
|
|
|
|
default:
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/tpf.c b/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
|
index 84f641cc316..497a4c3b335 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
|
@@ -2782,8 +2782,8 @@ bool hlsl_sm4_register_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_sem
|
|
return false;
|
|
}
|
|
|
|
-bool hlsl_sm4_usage_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semantic *semantic,
|
|
- bool output, D3D_NAME *usage)
|
|
+bool sysval_semantic_from_hlsl(enum vkd3d_shader_sysval_semantic *semantic,
|
|
+ struct hlsl_ctx *ctx, const struct hlsl_semantic *hlsl_semantic, bool output)
|
|
{
|
|
unsigned int i;
|
|
|
|
@@ -2792,7 +2792,7 @@ bool hlsl_sm4_usage_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semant
|
|
const char *name;
|
|
bool output;
|
|
enum vkd3d_shader_type shader_type;
|
|
- D3D_NAME usage;
|
|
+ enum vkd3d_shader_sysval_semantic semantic;
|
|
}
|
|
semantics[] =
|
|
{
|
|
@@ -2800,46 +2800,46 @@ bool hlsl_sm4_usage_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semant
|
|
{"sv_groupid", false, VKD3D_SHADER_TYPE_COMPUTE, ~0u},
|
|
{"sv_groupthreadid", false, VKD3D_SHADER_TYPE_COMPUTE, ~0u},
|
|
|
|
- {"position", false, VKD3D_SHADER_TYPE_GEOMETRY, D3D_NAME_POSITION},
|
|
- {"sv_position", false, VKD3D_SHADER_TYPE_GEOMETRY, D3D_NAME_POSITION},
|
|
- {"sv_primitiveid", false, VKD3D_SHADER_TYPE_GEOMETRY, D3D_NAME_PRIMITIVE_ID},
|
|
-
|
|
- {"position", true, VKD3D_SHADER_TYPE_GEOMETRY, D3D_NAME_POSITION},
|
|
- {"sv_position", true, VKD3D_SHADER_TYPE_GEOMETRY, D3D_NAME_POSITION},
|
|
- {"sv_primitiveid", true, VKD3D_SHADER_TYPE_GEOMETRY, D3D_NAME_PRIMITIVE_ID},
|
|
-
|
|
- {"position", false, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_POSITION},
|
|
- {"sv_position", false, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_POSITION},
|
|
- {"sv_primitiveid", false, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_PRIMITIVE_ID},
|
|
- {"sv_isfrontface", false, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_IS_FRONT_FACE},
|
|
- {"sv_rendertargetarrayindex", false, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_RENDER_TARGET_ARRAY_INDEX},
|
|
- {"sv_viewportarrayindex", false, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_VIEWPORT_ARRAY_INDEX},
|
|
-
|
|
- {"color", true, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_TARGET},
|
|
- {"depth", true, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_DEPTH},
|
|
- {"sv_target", true, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_TARGET},
|
|
- {"sv_depth", true, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_DEPTH},
|
|
- {"sv_coverage", true, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_COVERAGE},
|
|
-
|
|
- {"sv_position", false, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_UNDEFINED},
|
|
- {"sv_vertexid", false, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_VERTEX_ID},
|
|
- {"sv_instanceid", false, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_INSTANCE_ID},
|
|
-
|
|
- {"position", true, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_POSITION},
|
|
- {"sv_position", true, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_POSITION},
|
|
- {"sv_rendertargetarrayindex", true, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_RENDER_TARGET_ARRAY_INDEX},
|
|
- {"sv_viewportarrayindex", true, VKD3D_SHADER_TYPE_VERTEX, D3D_NAME_VIEWPORT_ARRAY_INDEX},
|
|
+ {"position", false, VKD3D_SHADER_TYPE_GEOMETRY, VKD3D_SHADER_SV_POSITION},
|
|
+ {"sv_position", false, VKD3D_SHADER_TYPE_GEOMETRY, VKD3D_SHADER_SV_POSITION},
|
|
+ {"sv_primitiveid", false, VKD3D_SHADER_TYPE_GEOMETRY, VKD3D_SHADER_SV_PRIMITIVE_ID},
|
|
+
|
|
+ {"position", true, VKD3D_SHADER_TYPE_GEOMETRY, VKD3D_SHADER_SV_POSITION},
|
|
+ {"sv_position", true, VKD3D_SHADER_TYPE_GEOMETRY, VKD3D_SHADER_SV_POSITION},
|
|
+ {"sv_primitiveid", true, VKD3D_SHADER_TYPE_GEOMETRY, VKD3D_SHADER_SV_PRIMITIVE_ID},
|
|
+
|
|
+ {"position", false, VKD3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_SV_POSITION},
|
|
+ {"sv_position", false, VKD3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_SV_POSITION},
|
|
+ {"sv_primitiveid", false, VKD3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_SV_PRIMITIVE_ID},
|
|
+ {"sv_isfrontface", false, VKD3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_SV_IS_FRONT_FACE},
|
|
+ {"sv_rendertargetarrayindex", false, VKD3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_SV_RENDER_TARGET_ARRAY_INDEX},
|
|
+ {"sv_viewportarrayindex", false, VKD3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_SV_VIEWPORT_ARRAY_INDEX},
|
|
+
|
|
+ {"color", true, VKD3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_SV_TARGET},
|
|
+ {"depth", true, VKD3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_SV_DEPTH},
|
|
+ {"sv_target", true, VKD3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_SV_TARGET},
|
|
+ {"sv_depth", true, VKD3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_SV_DEPTH},
|
|
+ {"sv_coverage", true, VKD3D_SHADER_TYPE_PIXEL, VKD3D_SHADER_SV_COVERAGE},
|
|
+
|
|
+ {"sv_position", false, VKD3D_SHADER_TYPE_VERTEX, VKD3D_SHADER_SV_NONE},
|
|
+ {"sv_vertexid", false, VKD3D_SHADER_TYPE_VERTEX, VKD3D_SHADER_SV_VERTEX_ID},
|
|
+ {"sv_instanceid", false, VKD3D_SHADER_TYPE_VERTEX, VKD3D_SHADER_SV_INSTANCE_ID},
|
|
+
|
|
+ {"position", true, VKD3D_SHADER_TYPE_VERTEX, VKD3D_SHADER_SV_POSITION},
|
|
+ {"sv_position", true, VKD3D_SHADER_TYPE_VERTEX, VKD3D_SHADER_SV_POSITION},
|
|
+ {"sv_rendertargetarrayindex", true, VKD3D_SHADER_TYPE_VERTEX, VKD3D_SHADER_SV_RENDER_TARGET_ARRAY_INDEX},
|
|
+ {"sv_viewportarrayindex", true, VKD3D_SHADER_TYPE_VERTEX, VKD3D_SHADER_SV_VIEWPORT_ARRAY_INDEX},
|
|
};
|
|
- bool needs_compat_mapping = ascii_strncasecmp(semantic->name, "sv_", 3);
|
|
+ bool needs_compat_mapping = ascii_strncasecmp(hlsl_semantic->name, "sv_", 3);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(semantics); ++i)
|
|
{
|
|
- if (!ascii_strcasecmp(semantic->name, semantics[i].name)
|
|
+ if (!ascii_strcasecmp(hlsl_semantic->name, semantics[i].name)
|
|
&& output == semantics[i].output
|
|
&& (ctx->semantic_compat_mapping == needs_compat_mapping || !needs_compat_mapping)
|
|
&& ctx->profile->type == semantics[i].shader_type)
|
|
{
|
|
- *usage = semantics[i].usage;
|
|
+ *semantic = semantics[i].semantic;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -2847,7 +2847,7 @@ bool hlsl_sm4_usage_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semant
|
|
if (!needs_compat_mapping)
|
|
return false;
|
|
|
|
- *usage = D3D_NAME_UNDEFINED;
|
|
+ *semantic = VKD3D_SHADER_SV_NONE;
|
|
return true;
|
|
}
|
|
|
|
@@ -2880,16 +2880,16 @@ static void write_sm4_signature(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc,
|
|
LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
|
|
{
|
|
unsigned int width = (1u << var->data_type->dimx) - 1, use_mask;
|
|
+ enum vkd3d_shader_sysval_semantic semantic;
|
|
uint32_t usage_idx, reg_idx;
|
|
- D3D_NAME usage;
|
|
bool has_idx;
|
|
|
|
if ((output && !var->is_output_semantic) || (!output && !var->is_input_semantic))
|
|
continue;
|
|
|
|
- ret = hlsl_sm4_usage_from_semantic(ctx, &var->semantic, output, &usage);
|
|
+ ret = sysval_semantic_from_hlsl(&semantic, ctx, &var->semantic, output);
|
|
VKD3D_ASSERT(ret);
|
|
- if (usage == ~0u)
|
|
+ if (semantic == ~0u)
|
|
continue;
|
|
usage_idx = var->semantic.index;
|
|
|
|
@@ -2908,12 +2908,12 @@ static void write_sm4_signature(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc,
|
|
use_mask = 0xf ^ use_mask;
|
|
|
|
/* Special pixel shader semantics (TARGET, DEPTH, COVERAGE). */
|
|
- if (usage >= 64)
|
|
- usage = 0;
|
|
+ if (semantic >= VKD3D_SHADER_SV_TARGET)
|
|
+ semantic = VKD3D_SHADER_SV_NONE;
|
|
|
|
put_u32(&buffer, 0); /* name */
|
|
put_u32(&buffer, usage_idx);
|
|
- put_u32(&buffer, usage);
|
|
+ put_u32(&buffer, semantic);
|
|
switch (var->data_type->e.numeric.type)
|
|
{
|
|
case HLSL_TYPE_FLOAT:
|
|
@@ -2944,25 +2944,25 @@ static void write_sm4_signature(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc,
|
|
i = 0;
|
|
LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
|
|
{
|
|
- const char *semantic = var->semantic.name;
|
|
+ enum vkd3d_shader_sysval_semantic semantic;
|
|
+ const char *name = var->semantic.name;
|
|
size_t string_offset;
|
|
- D3D_NAME usage;
|
|
|
|
if ((output && !var->is_output_semantic) || (!output && !var->is_input_semantic))
|
|
continue;
|
|
|
|
- hlsl_sm4_usage_from_semantic(ctx, &var->semantic, output, &usage);
|
|
- if (usage == ~0u)
|
|
+ sysval_semantic_from_hlsl(&semantic, ctx, &var->semantic, output);
|
|
+ if (semantic == ~0u)
|
|
continue;
|
|
|
|
- if (usage == D3D_NAME_TARGET && !ascii_strcasecmp(semantic, "color"))
|
|
+ if (semantic == VKD3D_SHADER_SV_TARGET && !ascii_strcasecmp(name, "color"))
|
|
string_offset = put_string(&buffer, "SV_Target");
|
|
- else if (usage == D3D_NAME_DEPTH && !ascii_strcasecmp(semantic, "depth"))
|
|
+ else if (semantic == VKD3D_SHADER_SV_DEPTH && !ascii_strcasecmp(name, "depth"))
|
|
string_offset = put_string(&buffer, "SV_Depth");
|
|
- else if (usage == D3D_NAME_POSITION && !ascii_strcasecmp(semantic, "position"))
|
|
+ else if (semantic == VKD3D_SHADER_SV_POSITION && !ascii_strcasecmp(name, "position"))
|
|
string_offset = put_string(&buffer, "SV_Position");
|
|
else
|
|
- string_offset = put_string(&buffer, semantic);
|
|
+ string_offset = put_string(&buffer, name);
|
|
set_u32(&buffer, (2 + i++ * 6) * sizeof(uint32_t), string_offset);
|
|
}
|
|
|
|
@@ -4412,7 +4412,7 @@ static void write_sm4_dcl_semantic(const struct tpf_writer *tpf, const struct hl
|
|
{
|
|
const struct hlsl_profile_info *profile = tpf->ctx->profile;
|
|
const bool output = var->is_output_semantic;
|
|
- D3D_NAME usage;
|
|
+ enum vkd3d_shader_sysval_semantic semantic;
|
|
bool has_idx;
|
|
|
|
struct sm4_instruction instr =
|
|
@@ -4445,22 +4445,22 @@ static void write_sm4_dcl_semantic(const struct tpf_writer *tpf, const struct hl
|
|
if (instr.dsts[0].reg.type == VKD3DSPR_DEPTHOUT)
|
|
instr.dsts[0].reg.dimension = VSIR_DIMENSION_SCALAR;
|
|
|
|
- hlsl_sm4_usage_from_semantic(tpf->ctx, &var->semantic, output, &usage);
|
|
- if (usage == ~0u)
|
|
- usage = D3D_NAME_UNDEFINED;
|
|
+ sysval_semantic_from_hlsl(&semantic, tpf->ctx, &var->semantic, output);
|
|
+ if (semantic == ~0u)
|
|
+ semantic = VKD3D_SHADER_SV_NONE;
|
|
|
|
if (var->is_input_semantic)
|
|
{
|
|
- switch (usage)
|
|
+ switch (semantic)
|
|
{
|
|
- case D3D_NAME_UNDEFINED:
|
|
+ case VKD3D_SHADER_SV_NONE:
|
|
instr.opcode = (profile->type == VKD3D_SHADER_TYPE_PIXEL)
|
|
? VKD3D_SM4_OP_DCL_INPUT_PS : VKD3D_SM4_OP_DCL_INPUT;
|
|
break;
|
|
|
|
- case D3D_NAME_INSTANCE_ID:
|
|
- case D3D_NAME_PRIMITIVE_ID:
|
|
- case D3D_NAME_VERTEX_ID:
|
|
+ case VKD3D_SHADER_SV_INSTANCE_ID:
|
|
+ case VKD3D_SHADER_SV_PRIMITIVE_ID:
|
|
+ case VKD3D_SHADER_SV_VERTEX_ID:
|
|
instr.opcode = (profile->type == VKD3D_SHADER_TYPE_PIXEL)
|
|
? VKD3D_SM4_OP_DCL_INPUT_PS_SGV : VKD3D_SM4_OP_DCL_INPUT_SGV;
|
|
break;
|
|
@@ -4510,25 +4510,25 @@ static void write_sm4_dcl_semantic(const struct tpf_writer *tpf, const struct hl
|
|
}
|
|
else
|
|
{
|
|
- if (usage == D3D_NAME_UNDEFINED || profile->type == VKD3D_SHADER_TYPE_PIXEL)
|
|
+ if (semantic == VKD3D_SHADER_SV_NONE || profile->type == VKD3D_SHADER_TYPE_PIXEL)
|
|
instr.opcode = VKD3D_SM4_OP_DCL_OUTPUT;
|
|
else
|
|
instr.opcode = VKD3D_SM4_OP_DCL_OUTPUT_SIV;
|
|
}
|
|
|
|
- switch (usage)
|
|
+ switch (semantic)
|
|
{
|
|
- case D3D_NAME_COVERAGE:
|
|
- case D3D_NAME_DEPTH:
|
|
- case D3D_NAME_DEPTH_GREATER_EQUAL:
|
|
- case D3D_NAME_DEPTH_LESS_EQUAL:
|
|
- case D3D_NAME_TARGET:
|
|
- case D3D_NAME_UNDEFINED:
|
|
+ case VKD3D_SHADER_SV_COVERAGE:
|
|
+ case VKD3D_SHADER_SV_DEPTH:
|
|
+ case VKD3D_SHADER_SV_DEPTH_GREATER_EQUAL:
|
|
+ case VKD3D_SHADER_SV_DEPTH_LESS_EQUAL:
|
|
+ case VKD3D_SHADER_SV_TARGET:
|
|
+ case VKD3D_SHADER_SV_NONE:
|
|
break;
|
|
|
|
default:
|
|
instr.idx_count = 1;
|
|
- instr.idx[0] = usage;
|
|
+ instr.idx[0] = semantic;
|
|
break;
|
|
}
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
|
|
index 306c1ca0dd8..60be996ae24 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
|
|
@@ -23,6 +23,8 @@
|
|
#include <stdio.h>
|
|
#include <math.h>
|
|
|
|
+/* VKD3D_DEBUG_ENV_NAME("VKD3D_SHADER_DEBUG"); */
|
|
+
|
|
static inline int char_to_int(char c)
|
|
{
|
|
if ('0' <= c && c <= '9')
|
|
@@ -443,20 +445,47 @@ void set_string(struct vkd3d_bytecode_buffer *buffer, size_t offset, const char
|
|
bytecode_set_bytes(buffer, offset, string, length);
|
|
}
|
|
|
|
-static void vkd3d_shader_dump_blob(const char *path, const char *profile,
|
|
- const char *suffix, const void *data, size_t size)
|
|
+struct shader_dump_data
|
|
+{
|
|
+ uint8_t checksum[16];
|
|
+ const char *path;
|
|
+ const char *profile;
|
|
+ const char *source_suffix;
|
|
+ const char *target_suffix;
|
|
+};
|
|
+
|
|
+static void vkd3d_shader_dump_shader(const struct shader_dump_data *dump_data,
|
|
+ const void *data, size_t size, bool source)
|
|
{
|
|
- static unsigned int shader_id = 0;
|
|
+ static const char hexadecimal_digits[] = "0123456789abcdef";
|
|
+ const uint8_t *checksum = dump_data->checksum;
|
|
+ char str_checksum[33];
|
|
+ unsigned int pos = 0;
|
|
char filename[1024];
|
|
- unsigned int id;
|
|
+ unsigned int i;
|
|
FILE *f;
|
|
|
|
- id = vkd3d_atomic_increment_u32(&shader_id) - 1;
|
|
+ if (!dump_data->path)
|
|
+ return;
|
|
|
|
- if (profile)
|
|
- snprintf(filename, ARRAY_SIZE(filename), "%s/vkd3d-shader-%u-%s.%s", path, id, profile, suffix);
|
|
+ for (i = 0; i < ARRAY_SIZE(dump_data->checksum); ++i)
|
|
+ {
|
|
+ str_checksum[2 * i] = hexadecimal_digits[checksum[i] >> 4];
|
|
+ str_checksum[2 * i + 1] = hexadecimal_digits[checksum[i] & 0xf];
|
|
+ }
|
|
+ str_checksum[32] = '\0';
|
|
+
|
|
+ pos = snprintf(filename, ARRAY_SIZE(filename), "%s/vkd3d-shader-%s", dump_data->path, str_checksum);
|
|
+
|
|
+ if (dump_data->profile)
|
|
+ pos += snprintf(filename + pos, ARRAY_SIZE(filename) - pos, "-%s", dump_data->profile);
|
|
+
|
|
+ if (source)
|
|
+ pos += snprintf(filename + pos, ARRAY_SIZE(filename) - pos, "-source.%s", dump_data->source_suffix);
|
|
else
|
|
- snprintf(filename, ARRAY_SIZE(filename), "%s/vkd3d-shader-%u.%s", path, id, suffix);
|
|
+ pos += snprintf(filename + pos, ARRAY_SIZE(filename) - pos, "-target.%s", dump_data->target_suffix);
|
|
+
|
|
+ TRACE("Dumping shader to \"%s\".\n", filename);
|
|
if ((f = fopen(filename, "wb")))
|
|
{
|
|
if (fwrite(data, 1, size, f) != size)
|
|
@@ -488,37 +517,59 @@ static const char *shader_get_source_type_suffix(enum vkd3d_shader_source_type t
|
|
}
|
|
}
|
|
|
|
-void vkd3d_shader_dump_shader(const struct vkd3d_shader_compile_info *compile_info)
|
|
+static const char *shader_get_target_type_suffix(enum vkd3d_shader_target_type type)
|
|
+{
|
|
+ switch (type)
|
|
+ {
|
|
+ case VKD3D_SHADER_TARGET_SPIRV_BINARY:
|
|
+ return "spv";
|
|
+ case VKD3D_SHADER_TARGET_SPIRV_TEXT:
|
|
+ return "spv.s";
|
|
+ case VKD3D_SHADER_TARGET_D3D_ASM:
|
|
+ return "d3d.s";
|
|
+ case VKD3D_SHADER_TARGET_D3D_BYTECODE:
|
|
+ return "d3dbc";
|
|
+ case VKD3D_SHADER_TARGET_DXBC_TPF:
|
|
+ return "dxbc";
|
|
+ case VKD3D_SHADER_TARGET_GLSL:
|
|
+ return "glsl";
|
|
+ case VKD3D_SHADER_TARGET_FX:
|
|
+ return "fx";
|
|
+ default:
|
|
+ FIXME("Unhandled target type %#x.\n", type);
|
|
+ return "bin";
|
|
+ }
|
|
+}
|
|
+
|
|
+static void fill_shader_dump_data(const struct vkd3d_shader_compile_info *compile_info,
|
|
+ struct shader_dump_data *data)
|
|
{
|
|
- const struct vkd3d_shader_code *shader = &compile_info->source;
|
|
- const struct vkd3d_shader_hlsl_source_info *hlsl_source_info;
|
|
- const struct hlsl_profile_info *profile;
|
|
- const char *profile_name = NULL;
|
|
static bool enabled = true;
|
|
- const char *path;
|
|
+
|
|
+ data->path = NULL;
|
|
|
|
if (!enabled)
|
|
return;
|
|
|
|
- if (!(path = getenv("VKD3D_SHADER_DUMP_PATH")))
|
|
+ if (!(data->path = getenv("VKD3D_SHADER_DUMP_PATH")))
|
|
{
|
|
enabled = false;
|
|
return;
|
|
}
|
|
|
|
+ data->profile = NULL;
|
|
if (compile_info->source_type == VKD3D_SHADER_SOURCE_HLSL)
|
|
{
|
|
- if (!(hlsl_source_info = vkd3d_find_struct(compile_info->next, HLSL_SOURCE_INFO)))
|
|
- return;
|
|
-
|
|
- if (!(profile = hlsl_get_target_info(hlsl_source_info->profile)))
|
|
- return;
|
|
+ const struct vkd3d_shader_hlsl_source_info *hlsl_source_info;
|
|
|
|
- profile_name = profile->name;
|
|
+ if ((hlsl_source_info = vkd3d_find_struct(compile_info->next, HLSL_SOURCE_INFO)))
|
|
+ data->profile = hlsl_source_info->profile;
|
|
}
|
|
|
|
- vkd3d_shader_dump_blob(path, profile_name, shader_get_source_type_suffix(compile_info->source_type),
|
|
- shader->code, shader->size);
|
|
+ vkd3d_compute_md5(compile_info->source.code, compile_info->source.size,
|
|
+ (uint32_t *)data->checksum, VKD3D_MD5_STANDARD);
|
|
+ data->source_suffix = shader_get_source_type_suffix(compile_info->source_type);
|
|
+ data->target_suffix = shader_get_target_type_suffix(compile_info->target_type);
|
|
}
|
|
|
|
static void init_scan_signature_info(const struct vkd3d_shader_compile_info *info)
|
|
@@ -1497,6 +1548,7 @@ static int vsir_program_scan(struct vsir_program *program, const struct vkd3d_sh
|
|
int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char **messages)
|
|
{
|
|
struct vkd3d_shader_message_context message_context;
|
|
+ struct shader_dump_data dump_data;
|
|
int ret;
|
|
|
|
TRACE("compile_info %p, messages %p.\n", compile_info, messages);
|
|
@@ -1511,7 +1563,8 @@ int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char
|
|
|
|
vkd3d_shader_message_context_init(&message_context, compile_info->log_level);
|
|
|
|
- vkd3d_shader_dump_shader(compile_info);
|
|
+ fill_shader_dump_data(compile_info, &dump_data);
|
|
+ vkd3d_shader_dump_shader(&dump_data, compile_info->source.code, compile_info->source.size, true);
|
|
|
|
if (compile_info->source_type == VKD3D_SHADER_SOURCE_HLSL)
|
|
{
|
|
@@ -1620,6 +1673,7 @@ int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,
|
|
struct vkd3d_shader_code *out, char **messages)
|
|
{
|
|
struct vkd3d_shader_message_context message_context;
|
|
+ struct shader_dump_data dump_data;
|
|
int ret;
|
|
|
|
TRACE("compile_info %p, out %p, messages %p.\n", compile_info, out, messages);
|
|
@@ -1634,7 +1688,8 @@ int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,
|
|
|
|
vkd3d_shader_message_context_init(&message_context, compile_info->log_level);
|
|
|
|
- vkd3d_shader_dump_shader(compile_info);
|
|
+ fill_shader_dump_data(compile_info, &dump_data);
|
|
+ vkd3d_shader_dump_shader(&dump_data, compile_info->source.code, compile_info->source.size, true);
|
|
|
|
if (compile_info->source_type == VKD3D_SHADER_SOURCE_HLSL)
|
|
{
|
|
@@ -1676,6 +1731,8 @@ int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,
|
|
}
|
|
}
|
|
|
|
+ vkd3d_shader_dump_shader(&dump_data, out->code, out->size, false);
|
|
+
|
|
vkd3d_shader_message_context_trace_messages(&message_context);
|
|
if (!vkd3d_shader_message_context_copy_messages(&message_context, messages))
|
|
ret = VKD3D_ERROR_OUT_OF_MEMORY;
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
|
index ef66a8ca07a..442885f53b4 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
|
@@ -1549,7 +1549,6 @@ void vkd3d_shader_warning(struct vkd3d_shader_message_context *context, const st
|
|
void vkd3d_shader_vwarning(struct vkd3d_shader_message_context *context, const struct vkd3d_shader_location *location,
|
|
enum vkd3d_shader_error error, const char *format, va_list args);
|
|
|
|
-void vkd3d_shader_dump_shader(const struct vkd3d_shader_compile_info *compile_info);
|
|
uint64_t vkd3d_shader_init_config_flags(void);
|
|
void vkd3d_shader_trace_text_(const char *text, size_t size, const char *function);
|
|
#define vkd3d_shader_trace_text(text, size) \
|
|
@@ -1580,7 +1579,13 @@ int spirv_compile(struct vsir_program *program, uint64_t config_flags,
|
|
const struct vkd3d_shader_compile_info *compile_info,
|
|
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context);
|
|
|
|
-void vkd3d_compute_dxbc_checksum(const void *dxbc, size_t size, uint32_t checksum[4]);
|
|
+enum vkd3d_md5_variant
|
|
+{
|
|
+ VKD3D_MD5_STANDARD,
|
|
+ VKD3D_MD5_DXBC,
|
|
+};
|
|
+
|
|
+void vkd3d_compute_md5(const void *dxbc, size_t size, uint32_t checksum[4], enum vkd3d_md5_variant variant);
|
|
|
|
int preproc_lexer_parse(const struct vkd3d_shader_compile_info *compile_info,
|
|
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context);
|
|
--
|
|
2.45.2
|
|
|