mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-09-13 09:17:20 -07:00
Updated vkd3d-latest patchset
Squashed to previous wine-staging release Add latest changes.
This commit is contained in:
parent
5d8ef8d881
commit
320847e6f5
File diff suppressed because it is too large
Load Diff
@ -1,589 +0,0 @@
|
||||
From f22ca676f4fd29182711350bc2a08efb2e78dc3d Mon Sep 17 00:00:00 2001
|
||||
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
|
||||
Date: Thu, 7 Mar 2024 10:40:41 +1100
|
||||
Subject: [PATCH] Updated vkd3d to a0d52dc38508b76efedcb6fa1df3162a0062ceaf.
|
||||
|
||||
---
|
||||
libs/vkd3d/libs/vkd3d-common/blob.c | 2 +
|
||||
libs/vkd3d/libs/vkd3d-shader/d3dbc.c | 22 +++-
|
||||
libs/vkd3d/libs/vkd3d-shader/fx.c | 44 +++----
|
||||
libs/vkd3d/libs/vkd3d-shader/hlsl.c | 7 +-
|
||||
libs/vkd3d/libs/vkd3d-shader/hlsl.h | 1 +
|
||||
libs/vkd3d/libs/vkd3d-shader/hlsl.l | 5 +
|
||||
libs/vkd3d/libs/vkd3d-shader/hlsl.y | 7 +-
|
||||
libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c | 119 ++++++++++++++++--
|
||||
libs/vkd3d/libs/vkd3d-shader/spirv.c | 6 +-
|
||||
.../libs/vkd3d-shader/vkd3d_shader_main.c | 2 +
|
||||
.../libs/vkd3d-shader/vkd3d_shader_private.h | 1 +
|
||||
11 files changed, 169 insertions(+), 47 deletions(-)
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-common/blob.c b/libs/vkd3d/libs/vkd3d-common/blob.c
|
||||
index 06a12ef5bc4..dbb26de7d73 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-common/blob.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-common/blob.c
|
||||
@@ -17,11 +17,13 @@
|
||||
*/
|
||||
|
||||
#define COBJMACROS
|
||||
+
|
||||
#define CONST_VTABLE
|
||||
#include "vkd3d.h"
|
||||
#include "vkd3d_blob.h"
|
||||
#include "vkd3d_debug.h"
|
||||
#include "vkd3d_memory.h"
|
||||
+#include "d3d12shader.h"
|
||||
|
||||
struct vkd3d_blob
|
||||
{
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
||||
index 27f5c810436..a8cca17faa3 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
|
||||
@@ -1977,16 +1977,13 @@ static void write_sm1_cast(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b
|
||||
{
|
||||
case HLSL_TYPE_INT:
|
||||
case HLSL_TYPE_UINT:
|
||||
- /* Integers are internally represented as floats, so no change is necessary.*/
|
||||
+ case HLSL_TYPE_BOOL:
|
||||
+ /* Integrals are internally represented as floats, so no change is necessary.*/
|
||||
case HLSL_TYPE_HALF:
|
||||
case HLSL_TYPE_FLOAT:
|
||||
write_sm1_unary_op(ctx, buffer, D3DSIO_MOV, &instr->reg, &arg1->reg, 0, 0);
|
||||
break;
|
||||
|
||||
- case HLSL_TYPE_BOOL:
|
||||
- hlsl_fixme(ctx, &instr->loc, "SM1 cast from bool to float.");
|
||||
- break;
|
||||
-
|
||||
case HLSL_TYPE_DOUBLE:
|
||||
hlsl_fixme(ctx, &instr->loc, "SM1 cast from double to float.");
|
||||
break;
|
||||
@@ -2002,7 +1999,10 @@ static void write_sm1_cast(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b
|
||||
{
|
||||
case HLSL_TYPE_HALF:
|
||||
case HLSL_TYPE_FLOAT:
|
||||
- /* A compilation pass applies a FLOOR operation to casts to int, so no change is necessary. */
|
||||
+ /* A compilation pass turns these into FLOOR+REINTERPRET, so we should not
|
||||
+ * reach this case unless we are missing something. */
|
||||
+ hlsl_fixme(ctx, &instr->loc, "Unlowered SM1 cast from float to integer.");
|
||||
+ break;
|
||||
case HLSL_TYPE_INT:
|
||||
case HLSL_TYPE_UINT:
|
||||
write_sm1_unary_op(ctx, buffer, D3DSIO_MOV, &instr->reg, &arg1->reg, 0, 0);
|
||||
@@ -2242,6 +2242,12 @@ static void write_sm1_expr(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b
|
||||
|
||||
assert(instr->reg.allocated);
|
||||
|
||||
+ if (expr->op == HLSL_OP1_REINTERPRET)
|
||||
+ {
|
||||
+ write_sm1_unary_op(ctx, buffer, D3DSIO_MOV, &instr->reg, &arg1->reg, 0, 0);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
if (expr->op == HLSL_OP1_CAST)
|
||||
{
|
||||
write_sm1_cast(ctx, buffer, instr);
|
||||
@@ -2329,6 +2335,10 @@ static void write_sm1_expr(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b
|
||||
}
|
||||
break;
|
||||
|
||||
+ case HLSL_OP2_SLT:
|
||||
+ write_sm1_binary_op(ctx, buffer, D3DSIO_SLT, &instr->reg, &arg1->reg, &arg2->reg);
|
||||
+ break;
|
||||
+
|
||||
case HLSL_OP3_CMP:
|
||||
write_sm1_ternary_op(ctx, buffer, D3DSIO_CMP, &instr->reg, &arg1->reg, &arg2->reg, &arg3->reg);
|
||||
break;
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/fx.c b/libs/vkd3d/libs/vkd3d-shader/fx.c
|
||||
index bc70d5220fd..fd5c8443221 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/fx.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/fx.c
|
||||
@@ -179,7 +179,6 @@ static void fx_write_context_init(struct hlsl_ctx *ctx, const struct fx_write_co
|
||||
static int fx_write_context_cleanup(struct fx_write_context *fx)
|
||||
{
|
||||
struct type_entry *type, *next_type;
|
||||
- int status = fx->status;
|
||||
|
||||
rb_destroy(&fx->strings, string_storage_destroy, NULL);
|
||||
|
||||
@@ -189,7 +188,7 @@ static int fx_write_context_cleanup(struct fx_write_context *fx)
|
||||
vkd3d_free(type);
|
||||
}
|
||||
|
||||
- return status;
|
||||
+ return fx->ctx->result;
|
||||
}
|
||||
|
||||
static bool technique_matches_version(const struct hlsl_ir_var *var, const struct fx_write_context *fx)
|
||||
@@ -285,6 +284,7 @@ static uint32_t get_fx_4_numeric_type_description(const struct hlsl_type *type,
|
||||
[HLSL_TYPE_UINT ] = 3,
|
||||
[HLSL_TYPE_BOOL ] = 4,
|
||||
};
|
||||
+ struct hlsl_ctx *ctx = fx->ctx;
|
||||
uint32_t value = 0;
|
||||
|
||||
switch (type->class)
|
||||
@@ -295,8 +295,7 @@ static uint32_t get_fx_4_numeric_type_description(const struct hlsl_type *type,
|
||||
value |= numeric_type_class[type->class];
|
||||
break;
|
||||
default:
|
||||
- FIXME("Unexpected type class %u.\n", type->class);
|
||||
- set_status(fx, VKD3D_ERROR_NOT_IMPLEMENTED);
|
||||
+ hlsl_fixme(ctx, &ctx->location, "Not implemented for type class %u.\n", type->class);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -309,8 +308,7 @@ static uint32_t get_fx_4_numeric_type_description(const struct hlsl_type *type,
|
||||
value |= (numeric_base_type[type->base_type] << NUMERIC_BASE_TYPE_SHIFT);
|
||||
break;
|
||||
default:
|
||||
- FIXME("Unexpected base type %u.\n", type->base_type);
|
||||
- set_status(fx, VKD3D_ERROR_NOT_IMPLEMENTED);
|
||||
+ hlsl_fixme(ctx, &ctx->location, "Not implemented for base type %u.\n", type->base_type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -359,6 +357,7 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
|
||||
[HLSL_SAMPLER_DIM_BUFFER] = "RWBuffer",
|
||||
[HLSL_SAMPLER_DIM_STRUCTURED_BUFFER] = "RWStructuredBuffer",
|
||||
};
|
||||
+ struct hlsl_ctx *ctx = fx->ctx;
|
||||
|
||||
/* Resolve arrays to element type and number of elements. */
|
||||
if (type->class == HLSL_CLASS_ARRAY)
|
||||
@@ -387,8 +386,7 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
|
||||
put_u32_unaligned(buffer, variable_type[type->class]);
|
||||
break;
|
||||
default:
|
||||
- FIXME("Writing type class %u is not implemented.\n", type->class);
|
||||
- set_status(fx, VKD3D_ERROR_NOT_IMPLEMENTED);
|
||||
+ hlsl_fixme(ctx, &ctx->location, "Writing type class %u is not implemented.\n", type->class);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -466,8 +464,7 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
|
||||
put_u32_unaligned(buffer, uav_type[type->sampler_dim]);
|
||||
break;
|
||||
default:
|
||||
- FIXME("Object type %u is not supported.\n", type->base_type);
|
||||
- set_status(fx, VKD3D_ERROR_NOT_IMPLEMENTED);
|
||||
+ hlsl_fixme(ctx, &ctx->location, "Object type %u is not supported.\n", type->base_type);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -643,15 +640,18 @@ static int hlsl_fx_2_write(struct hlsl_ctx *ctx, struct vkd3d_shader_code *out)
|
||||
vkd3d_free(fx.unstructured.data);
|
||||
vkd3d_free(fx.structured.data);
|
||||
|
||||
- if (!fx.status)
|
||||
+ if (!fx.technique_count)
|
||||
+ hlsl_error(ctx, &ctx->location, VKD3D_SHADER_ERROR_HLSL_MISSING_TECHNIQUE, "No techniques found.");
|
||||
+
|
||||
+ if (fx.status < 0)
|
||||
+ ctx->result = fx.status;
|
||||
+
|
||||
+ if (!ctx->result)
|
||||
{
|
||||
out->code = buffer.data;
|
||||
out->size = buffer.size;
|
||||
}
|
||||
|
||||
- if (fx.status < 0)
|
||||
- ctx->result = fx.status;
|
||||
-
|
||||
return fx_write_context_cleanup(&fx);
|
||||
}
|
||||
|
||||
@@ -870,15 +870,15 @@ static int hlsl_fx_4_write(struct hlsl_ctx *ctx, struct vkd3d_shader_code *out)
|
||||
|
||||
set_status(&fx, buffer.status);
|
||||
|
||||
- if (!fx.status)
|
||||
+ if (fx.status < 0)
|
||||
+ ctx->result = fx.status;
|
||||
+
|
||||
+ if (!ctx->result)
|
||||
{
|
||||
out->code = buffer.data;
|
||||
out->size = buffer.size;
|
||||
}
|
||||
|
||||
- if (fx.status < 0)
|
||||
- ctx->result = fx.status;
|
||||
-
|
||||
return fx_write_context_cleanup(&fx);
|
||||
}
|
||||
|
||||
@@ -933,15 +933,15 @@ static int hlsl_fx_5_write(struct hlsl_ctx *ctx, struct vkd3d_shader_code *out)
|
||||
|
||||
set_status(&fx, buffer.status);
|
||||
|
||||
- if (!fx.status)
|
||||
+ if (fx.status < 0)
|
||||
+ ctx->result = fx.status;
|
||||
+
|
||||
+ if (!ctx->result)
|
||||
{
|
||||
out->code = buffer.data;
|
||||
out->size = buffer.size;
|
||||
}
|
||||
|
||||
- if (fx.status < 0)
|
||||
- ctx->result = fx.status;
|
||||
-
|
||||
return fx_write_context_cleanup(&fx);
|
||||
}
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.c b/libs/vkd3d/libs/vkd3d-shader/hlsl.c
|
||||
index 538f083df9c..45d02ce2b4e 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.c
|
||||
@@ -784,7 +784,9 @@ static const char * get_case_insensitive_typename(const char *name)
|
||||
"dword",
|
||||
"float",
|
||||
"matrix",
|
||||
+ "pixelshader",
|
||||
"vector",
|
||||
+ "vertexshader",
|
||||
};
|
||||
unsigned int i;
|
||||
|
||||
@@ -2611,6 +2613,7 @@ const char *debug_hlsl_expr_op(enum hlsl_ir_expr_op op)
|
||||
[HLSL_OP2_MUL] = "*",
|
||||
[HLSL_OP2_NEQUAL] = "!=",
|
||||
[HLSL_OP2_RSHIFT] = ">>",
|
||||
+ [HLSL_OP2_SLT] = "slt",
|
||||
|
||||
[HLSL_OP3_CMP] = "cmp",
|
||||
[HLSL_OP3_DP2ADD] = "dp2add",
|
||||
@@ -3395,8 +3398,8 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
|
||||
{"pass", HLSL_CLASS_OBJECT, HLSL_TYPE_PASS, 1, 1},
|
||||
{"STRING", HLSL_CLASS_OBJECT, HLSL_TYPE_STRING, 1, 1},
|
||||
{"TEXTURE", HLSL_CLASS_OBJECT, HLSL_TYPE_TEXTURE, 1, 1},
|
||||
- {"PIXELSHADER", HLSL_CLASS_OBJECT, HLSL_TYPE_PIXELSHADER, 1, 1},
|
||||
- {"VERTEXSHADER", HLSL_CLASS_OBJECT, HLSL_TYPE_VERTEXSHADER, 1, 1},
|
||||
+ {"pixelshader", HLSL_CLASS_OBJECT, HLSL_TYPE_PIXELSHADER, 1, 1},
|
||||
+ {"vertexshader", HLSL_CLASS_OBJECT, HLSL_TYPE_VERTEXSHADER, 1, 1},
|
||||
{"RenderTargetView",HLSL_CLASS_OBJECT, HLSL_TYPE_RENDERTARGETVIEW, 1, 1},
|
||||
{"DepthStencilView",HLSL_CLASS_OBJECT, HLSL_TYPE_DEPTHSTENCILVIEW, 1, 1},
|
||||
};
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.h b/libs/vkd3d/libs/vkd3d-shader/hlsl.h
|
||||
index df0a53b20de..97b9021146d 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.h
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.h
|
||||
@@ -593,6 +593,7 @@ enum hlsl_ir_expr_op
|
||||
HLSL_OP2_MUL,
|
||||
HLSL_OP2_NEQUAL,
|
||||
HLSL_OP2_RSHIFT,
|
||||
+ HLSL_OP2_SLT,
|
||||
|
||||
/* DP2ADD(a, b, c) computes the scalar product of a.xy and b.xy,
|
||||
* then adds c. */
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.l b/libs/vkd3d/libs/vkd3d-shader/hlsl.l
|
||||
index 558506db108..8dcceb94c1c 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.l
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.l
|
||||
@@ -76,6 +76,7 @@ case {return KW_CASE; }
|
||||
cbuffer {return KW_CBUFFER; }
|
||||
centroid {return KW_CENTROID; }
|
||||
column_major {return KW_COLUMN_MAJOR; }
|
||||
+ComputeShader {return KW_COMPUTESHADER; }
|
||||
compile {return KW_COMPILE; }
|
||||
const {return KW_CONST; }
|
||||
continue {return KW_CONTINUE; }
|
||||
@@ -83,6 +84,7 @@ DepthStencilState {return KW_DEPTHSTENCILSTATE; }
|
||||
DepthStencilView {return KW_DEPTHSTENCILVIEW; }
|
||||
default {return KW_DEFAULT; }
|
||||
discard {return KW_DISCARD; }
|
||||
+DomainShader {return KW_DOMAINSHADER; }
|
||||
do {return KW_DO; }
|
||||
double {return KW_DOUBLE; }
|
||||
else {return KW_ELSE; }
|
||||
@@ -92,6 +94,7 @@ for {return KW_FOR; }
|
||||
fxgroup {return KW_FXGROUP; }
|
||||
GeometryShader {return KW_GEOMETRYSHADER; }
|
||||
groupshared {return KW_GROUPSHARED; }
|
||||
+HullShader {return KW_HULLSHADER; }
|
||||
if {return KW_IF; }
|
||||
in {return KW_IN; }
|
||||
inline {return KW_INLINE; }
|
||||
@@ -105,6 +108,7 @@ out {return KW_OUT; }
|
||||
packoffset {return KW_PACKOFFSET; }
|
||||
pass {return KW_PASS; }
|
||||
PixelShader {return KW_PIXELSHADER; }
|
||||
+pixelshader {return KW_PIXELSHADER; }
|
||||
precise {return KW_PRECISE; }
|
||||
RasterizerOrderedBuffer {return KW_RASTERIZERORDEREDBUFFER; }
|
||||
RasterizerOrderedStructuredBuffer {return KW_RASTERIZERORDEREDSTRUCTUREDBUFFER; }
|
||||
@@ -163,6 +167,7 @@ typedef {return KW_TYPEDEF; }
|
||||
uniform {return KW_UNIFORM; }
|
||||
vector {return KW_VECTOR; }
|
||||
VertexShader {return KW_VERTEXSHADER; }
|
||||
+vertexshader {return KW_VERTEXSHADER; }
|
||||
void {return KW_VOID; }
|
||||
volatile {return KW_VOLATILE; }
|
||||
while {return KW_WHILE; }
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.y b/libs/vkd3d/libs/vkd3d-shader/hlsl.y
|
||||
index cd05fd008a6..8cdc8226370 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.y
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.y
|
||||
@@ -5243,6 +5243,7 @@ static void validate_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim,
|
||||
%token KW_CENTROID
|
||||
%token KW_COLUMN_MAJOR
|
||||
%token KW_COMPILE
|
||||
+%token KW_COMPUTESHADER
|
||||
%token KW_CONST
|
||||
%token KW_CONTINUE
|
||||
%token KW_DEFAULT
|
||||
@@ -5250,6 +5251,7 @@ static void validate_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim,
|
||||
%token KW_DEPTHSTENCILVIEW
|
||||
%token KW_DISCARD
|
||||
%token KW_DO
|
||||
+%token KW_DOMAINSHADER
|
||||
%token KW_DOUBLE
|
||||
%token KW_ELSE
|
||||
%token KW_EXTERN
|
||||
@@ -5258,6 +5260,7 @@ static void validate_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim,
|
||||
%token KW_FXGROUP
|
||||
%token KW_GEOMETRYSHADER
|
||||
%token KW_GROUPSHARED
|
||||
+%token KW_HULLSHADER
|
||||
%token KW_IF
|
||||
%token KW_IN
|
||||
%token KW_INLINE
|
||||
@@ -5535,10 +5538,6 @@ technique10:
|
||||
struct hlsl_scope *scope = ctx->cur_scope;
|
||||
hlsl_pop_scope(ctx);
|
||||
|
||||
- if (ctx->profile->type == VKD3D_SHADER_TYPE_EFFECT && ctx->profile->major_version == 2)
|
||||
- hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX,
|
||||
- "The 'technique10' keyword is invalid for this profile.");
|
||||
-
|
||||
if (!add_technique(ctx, $2, scope, $3, "technique10", &@1))
|
||||
YYABORT;
|
||||
}
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
|
||||
index 307f86f55b7..8434a921a62 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
|
||||
@@ -2647,10 +2647,11 @@ static bool sort_synthetic_separated_samplers_first(struct hlsl_ctx *ctx)
|
||||
return false;
|
||||
}
|
||||
|
||||
-/* Append a FLOOR before a CAST to int or uint (which is written as a mere MOV). */
|
||||
+/* Turn CAST to int or uint into FLOOR + REINTERPRET (which is written as a mere MOV). */
|
||||
static bool lower_casts_to_int(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
|
||||
{
|
||||
- struct hlsl_ir_node *arg, *floor, *cast2;
|
||||
+ struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = { 0 };
|
||||
+ struct hlsl_ir_node *arg, *floor, *res;
|
||||
struct hlsl_ir_expr *expr;
|
||||
|
||||
if (instr->type != HLSL_IR_EXPR)
|
||||
@@ -2665,17 +2666,15 @@ static bool lower_casts_to_int(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
|
||||
if (arg->data_type->base_type != HLSL_TYPE_FLOAT && arg->data_type->base_type != HLSL_TYPE_HALF)
|
||||
return false;
|
||||
|
||||
- /* Check that the argument is not already a FLOOR */
|
||||
- if (arg->type == HLSL_IR_EXPR && hlsl_ir_expr(arg)->op == HLSL_OP1_FLOOR)
|
||||
- return false;
|
||||
-
|
||||
if (!(floor = hlsl_new_unary_expr(ctx, HLSL_OP1_FLOOR, arg, &instr->loc)))
|
||||
return false;
|
||||
hlsl_block_add_instr(block, floor);
|
||||
|
||||
- if (!(cast2 = hlsl_new_cast(ctx, floor, instr->data_type, &instr->loc)))
|
||||
+ memset(operands, 0, sizeof(operands));
|
||||
+ operands[0] = floor;
|
||||
+ if (!(res = hlsl_new_expr(ctx, HLSL_OP1_REINTERPRET, operands, instr->data_type, &instr->loc)))
|
||||
return false;
|
||||
- hlsl_block_add_instr(block, cast2);
|
||||
+ hlsl_block_add_instr(block, res);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -2903,7 +2902,7 @@ static bool lower_floor(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct
|
||||
return true;
|
||||
}
|
||||
|
||||
-/* Use 'movc' for the ternary operator. */
|
||||
+/* Use movc/cmp/slt for the ternary operator. */
|
||||
static bool lower_ternary(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
|
||||
{
|
||||
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = { 0 }, *replacement;
|
||||
@@ -2949,8 +2948,44 @@ static bool lower_ternary(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, stru
|
||||
}
|
||||
else if (ctx->profile->major_version < 4 && ctx->profile->type == VKD3D_SHADER_TYPE_VERTEX)
|
||||
{
|
||||
- hlsl_fixme(ctx, &instr->loc, "Ternary operator is not implemented for %s profile.", ctx->profile->name);
|
||||
- return false;
|
||||
+ struct hlsl_ir_node *neg, *slt, *sum, *mul, *cond2;
|
||||
+
|
||||
+ /* Expression used here is "slt(<cond>) * (first - second) + second". */
|
||||
+
|
||||
+ if (ctx->profile->major_version == 3)
|
||||
+ {
|
||||
+ if (!(cond2 = hlsl_new_unary_expr(ctx, HLSL_OP1_ABS, cond, &instr->loc)))
|
||||
+ return false;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ if (!(cond2 = hlsl_new_binary_expr(ctx, HLSL_OP2_MUL, cond, cond)))
|
||||
+ return false;
|
||||
+ }
|
||||
+ hlsl_block_add_instr(block, cond2);
|
||||
+
|
||||
+ if (!(neg = hlsl_new_unary_expr(ctx, HLSL_OP1_NEG, cond2, &instr->loc)))
|
||||
+ return false;
|
||||
+ hlsl_block_add_instr(block, neg);
|
||||
+
|
||||
+ if (!(slt = hlsl_new_binary_expr(ctx, HLSL_OP2_SLT, neg, cond2)))
|
||||
+ return false;
|
||||
+ hlsl_block_add_instr(block, slt);
|
||||
+
|
||||
+ if (!(neg = hlsl_new_unary_expr(ctx, HLSL_OP1_NEG, second, &instr->loc)))
|
||||
+ return false;
|
||||
+ hlsl_block_add_instr(block, neg);
|
||||
+
|
||||
+ if (!(sum = hlsl_new_binary_expr(ctx, HLSL_OP2_ADD, first, neg)))
|
||||
+ return false;
|
||||
+ hlsl_block_add_instr(block, sum);
|
||||
+
|
||||
+ if (!(mul = hlsl_new_binary_expr(ctx, HLSL_OP2_MUL, slt, sum)))
|
||||
+ return false;
|
||||
+ hlsl_block_add_instr(block, mul);
|
||||
+
|
||||
+ if (!(replacement = hlsl_new_binary_expr(ctx, HLSL_OP2_ADD, mul, second)))
|
||||
+ return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3308,6 +3343,61 @@ static bool lower_float_modulus(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr
|
||||
return true;
|
||||
}
|
||||
|
||||
+static bool lower_nonfloat_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
|
||||
+{
|
||||
+ struct hlsl_ir_expr *expr;
|
||||
+
|
||||
+ if (instr->type != HLSL_IR_EXPR)
|
||||
+ return false;
|
||||
+ expr = hlsl_ir_expr(instr);
|
||||
+ if (expr->op == HLSL_OP1_CAST || instr->data_type->base_type == HLSL_TYPE_FLOAT)
|
||||
+ return false;
|
||||
+
|
||||
+ switch (expr->op)
|
||||
+ {
|
||||
+ case HLSL_OP1_ABS:
|
||||
+ case HLSL_OP1_NEG:
|
||||
+ case HLSL_OP2_ADD:
|
||||
+ case HLSL_OP2_DIV:
|
||||
+ case HLSL_OP2_MAX:
|
||||
+ case HLSL_OP2_MIN:
|
||||
+ case HLSL_OP2_MUL:
|
||||
+ {
|
||||
+ struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = {0};
|
||||
+ struct hlsl_ir_node *arg, *arg_cast, *float_expr, *ret;
|
||||
+ struct hlsl_type *float_type;
|
||||
+ unsigned int i;
|
||||
+
|
||||
+ for (i = 0; i < HLSL_MAX_OPERANDS; ++i)
|
||||
+ {
|
||||
+ arg = expr->operands[i].node;
|
||||
+ if (!arg)
|
||||
+ continue;
|
||||
+
|
||||
+ float_type = hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, arg->data_type->dimx);
|
||||
+ if (!(arg_cast = hlsl_new_cast(ctx, arg, float_type, &instr->loc)))
|
||||
+ return false;
|
||||
+ hlsl_block_add_instr(block, arg_cast);
|
||||
+
|
||||
+ operands[i] = arg_cast;
|
||||
+ }
|
||||
+
|
||||
+ float_type = hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, instr->data_type->dimx);
|
||||
+ if (!(float_expr = hlsl_new_expr(ctx, expr->op, operands, float_type, &instr->loc)))
|
||||
+ return false;
|
||||
+ hlsl_block_add_instr(block, float_expr);
|
||||
+
|
||||
+ if (!(ret = hlsl_new_cast(ctx, float_expr, instr->data_type, &instr->loc)))
|
||||
+ return false;
|
||||
+ hlsl_block_add_instr(block, ret);
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+ default:
|
||||
+ return false;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static bool lower_discard_neg(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
|
||||
{
|
||||
struct hlsl_ir_node *zero, *bool_false, *or, *cmp, *load;
|
||||
@@ -5087,6 +5177,13 @@ int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry
|
||||
remove_unreachable_code(ctx, body);
|
||||
hlsl_transform_ir(ctx, normalize_switch_cases, body, NULL);
|
||||
|
||||
+ if (profile-> major_version < 4)
|
||||
+ {
|
||||
+ lower_ir(ctx, lower_nonfloat_exprs, body);
|
||||
+ /* Constants casted to float must be folded. */
|
||||
+ hlsl_transform_ir(ctx, hlsl_fold_constant_exprs, body, NULL);
|
||||
+ }
|
||||
+
|
||||
lower_ir(ctx, lower_nonconstant_vector_derefs, body);
|
||||
lower_ir(ctx, lower_casts_to_bool, body);
|
||||
lower_ir(ctx, lower_int_dot, body);
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/spirv.c b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
index 5c87ff15503..efdb0b74758 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
@@ -7093,8 +7093,8 @@ static void spirv_compiler_emit_mov(struct spirv_compiler *compiler,
|
||||
struct vkd3d_shader_register_info dst_reg_info, src_reg_info;
|
||||
const struct vkd3d_shader_dst_param *dst = instruction->dst;
|
||||
const struct vkd3d_shader_src_param *src = instruction->src;
|
||||
+ unsigned int i, component_count, write_mask;
|
||||
uint32_t components[VKD3D_VEC4_SIZE];
|
||||
- unsigned int i, component_count;
|
||||
|
||||
if (register_is_constant_or_undef(&src->reg) || src->reg.type == VKD3DSPR_SSA || dst->reg.type == VKD3DSPR_SSA
|
||||
|| dst->modifiers || src->modifiers)
|
||||
@@ -7145,7 +7145,9 @@ static void spirv_compiler_emit_mov(struct spirv_compiler *compiler,
|
||||
}
|
||||
|
||||
general_implementation:
|
||||
- val_id = spirv_compiler_emit_load_src(compiler, src, dst->write_mask);
|
||||
+ write_mask = (src->reg.type == VKD3DSPR_IMMCONST64 && !data_type_is_64_bit(dst->reg.data_type))
|
||||
+ ? vsir_write_mask_64_from_32(dst->write_mask) : dst->write_mask;
|
||||
+ val_id = spirv_compiler_emit_load_src(compiler, src, write_mask);
|
||||
if (dst->reg.data_type != src->reg.data_type)
|
||||
{
|
||||
val_id = vkd3d_spirv_build_op_bitcast(builder, vkd3d_spirv_get_type_id_for_data_type(builder,
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
|
||||
index 4f400d19f6f..385c4368e31 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')
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
index 2d3b3254638..990a7713308 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
@@ -148,6 +148,7 @@ enum vkd3d_shader_error
|
||||
VKD3D_SHADER_ERROR_HLSL_INCONSISTENT_SAMPLER = 5026,
|
||||
VKD3D_SHADER_ERROR_HLSL_NON_FINITE_RESULT = 5027,
|
||||
VKD3D_SHADER_ERROR_HLSL_DUPLICATE_SWITCH_CASE = 5028,
|
||||
+ VKD3D_SHADER_ERROR_HLSL_MISSING_TECHNIQUE = 5029,
|
||||
|
||||
VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION = 5300,
|
||||
VKD3D_SHADER_WARNING_HLSL_DIVISION_BY_ZERO = 5301,
|
||||
--
|
||||
2.43.0
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,581 +0,0 @@
|
||||
From bd4a3d1a0a0a8e60d2f51a6e113dc9095ebad586 Mon Sep 17 00:00:00 2001
|
||||
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
|
||||
Date: Thu, 14 Mar 2024 20:16:07 +1100
|
||||
Subject: [PATCH] Updated vkd3d to 374c5fcbdd91b6b7e6c362c79871ddf30f0ccee2.
|
||||
|
||||
---
|
||||
libs/vkd3d/libs/vkd3d-shader/glsl.c | 20 +--
|
||||
libs/vkd3d/libs/vkd3d-shader/ir.c | 178 +++++++++++++++------------
|
||||
libs/vkd3d/libs/vkd3d-shader/spirv.c | 19 +++
|
||||
3 files changed, 125 insertions(+), 92 deletions(-)
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/glsl.c b/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
||||
index 7c630d181ef..da90782c814 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
struct vkd3d_glsl_generator
|
||||
{
|
||||
- struct vkd3d_shader_version version;
|
||||
+ struct vsir_program *program;
|
||||
struct vkd3d_string_buffer buffer;
|
||||
struct vkd3d_shader_location location;
|
||||
struct vkd3d_shader_message_context *message_context;
|
||||
@@ -42,7 +42,7 @@ static void VKD3D_PRINTF_FUNC(3, 4) vkd3d_glsl_compiler_error(
|
||||
static void shader_glsl_ret(struct vkd3d_glsl_generator *generator,
|
||||
const struct vkd3d_shader_instruction *ins)
|
||||
{
|
||||
- const struct vkd3d_shader_version *version = &generator->version;
|
||||
+ const struct vkd3d_shader_version *version = &generator->program->shader_version;
|
||||
|
||||
/*
|
||||
* TODO: Implement in_subroutine
|
||||
@@ -76,9 +76,9 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *generator
|
||||
}
|
||||
}
|
||||
|
||||
-static int vkd3d_glsl_generator_generate(struct vkd3d_glsl_generator *generator,
|
||||
- struct vsir_program *program, struct vkd3d_shader_code *out)
|
||||
+static int vkd3d_glsl_generator_generate(struct vkd3d_glsl_generator *generator, struct vkd3d_shader_code *out)
|
||||
{
|
||||
+ const struct vkd3d_shader_instruction_array *instructions = &generator->program->instructions;
|
||||
unsigned int i;
|
||||
void *code;
|
||||
|
||||
@@ -87,9 +87,9 @@ static int vkd3d_glsl_generator_generate(struct vkd3d_glsl_generator *generator,
|
||||
vkd3d_string_buffer_printf(&generator->buffer, "#version 440\n\n");
|
||||
vkd3d_string_buffer_printf(&generator->buffer, "void main()\n{\n");
|
||||
|
||||
- for (i = 0; i < program->instructions.count; ++i)
|
||||
+ for (i = 0; i < instructions->count; ++i)
|
||||
{
|
||||
- vkd3d_glsl_handle_instruction(generator, &program->instructions.elements[i]);
|
||||
+ vkd3d_glsl_handle_instruction(generator, &instructions->elements[i]);
|
||||
}
|
||||
|
||||
if (generator->failed)
|
||||
@@ -114,10 +114,10 @@ static void vkd3d_glsl_generator_cleanup(struct vkd3d_glsl_generator *gen)
|
||||
}
|
||||
|
||||
static void vkd3d_glsl_generator_init(struct vkd3d_glsl_generator *gen,
|
||||
- const struct vkd3d_shader_version *version, struct vkd3d_shader_message_context *message_context)
|
||||
+ struct vsir_program *program, struct vkd3d_shader_message_context *message_context)
|
||||
{
|
||||
memset(gen, 0, sizeof(*gen));
|
||||
- gen->version = *version;
|
||||
+ gen->program = program;
|
||||
vkd3d_string_buffer_init(&gen->buffer);
|
||||
gen->message_context = message_context;
|
||||
}
|
||||
@@ -128,8 +128,8 @@ int glsl_compile(struct vsir_program *program, struct vkd3d_shader_code *out,
|
||||
struct vkd3d_glsl_generator generator;
|
||||
int ret;
|
||||
|
||||
- vkd3d_glsl_generator_init(&generator, &program->shader_version, message_context);
|
||||
- ret = vkd3d_glsl_generator_generate(&generator, program, out);
|
||||
+ vkd3d_glsl_generator_init(&generator, program, message_context);
|
||||
+ ret = vkd3d_glsl_generator_generate(&generator, out);
|
||||
vkd3d_glsl_generator_cleanup(&generator);
|
||||
|
||||
return ret;
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/ir.c b/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
index 759c89957d6..0dd31af9192 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
@@ -94,9 +94,8 @@ static bool vsir_instruction_init_with_params(struct vsir_program *program,
|
||||
return true;
|
||||
}
|
||||
|
||||
-static enum vkd3d_result instruction_array_lower_texkills(struct vkd3d_shader_parser *parser)
|
||||
+static enum vkd3d_result vsir_program_lower_texkills(struct vsir_program *program)
|
||||
{
|
||||
- struct vsir_program *program = &parser->program;
|
||||
struct vkd3d_shader_instruction_array *instructions = &program->instructions;
|
||||
struct vkd3d_shader_instruction *texkill_ins, *ins;
|
||||
unsigned int components_read = 3 + (program->shader_version.major >= 2);
|
||||
@@ -230,10 +229,11 @@ static const struct vkd3d_shader_varying_map *find_varying_map(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
-static enum vkd3d_result remap_output_signature(struct vkd3d_shader_parser *parser,
|
||||
- const struct vkd3d_shader_compile_info *compile_info)
|
||||
+static enum vkd3d_result vsir_program_remap_output_signature(struct vsir_program *program,
|
||||
+ const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context)
|
||||
{
|
||||
- struct shader_signature *signature = &parser->program.output_signature;
|
||||
+ const struct vkd3d_shader_location location = {.source_name = compile_info->source_name};
|
||||
+ struct shader_signature *signature = &program->output_signature;
|
||||
const struct vkd3d_shader_varying_map_info *varying_map;
|
||||
unsigned int i;
|
||||
|
||||
@@ -255,7 +255,7 @@ static enum vkd3d_result remap_output_signature(struct vkd3d_shader_parser *pars
|
||||
* location with a different mask. */
|
||||
if (input_mask && input_mask != e->mask)
|
||||
{
|
||||
- vkd3d_shader_parser_error(parser, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED,
|
||||
+ vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED,
|
||||
"Aborting due to not yet implemented feature: "
|
||||
"Output mask %#x does not match input mask %#x.",
|
||||
e->mask, input_mask);
|
||||
@@ -272,7 +272,7 @@ static enum vkd3d_result remap_output_signature(struct vkd3d_shader_parser *pars
|
||||
{
|
||||
if (varying_map->varying_map[i].output_signature_index >= signature->element_count)
|
||||
{
|
||||
- vkd3d_shader_parser_error(parser, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED,
|
||||
+ vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED,
|
||||
"Aborting due to not yet implemented feature: "
|
||||
"The next stage consumes varyings not written by this stage.");
|
||||
return VKD3D_ERROR_NOT_IMPLEMENTED;
|
||||
@@ -2666,33 +2666,36 @@ fail:
|
||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
-static void materialize_ssas_to_temps_process_src_param(struct vkd3d_shader_parser *parser, struct vkd3d_shader_src_param *src);
|
||||
+static void materialize_ssas_to_temps_process_src_param(struct vsir_program *program,
|
||||
+ struct vkd3d_shader_src_param *src);
|
||||
|
||||
/* This is idempotent: it can be safely applied more than once on the
|
||||
* same register. */
|
||||
-static void materialize_ssas_to_temps_process_reg(struct vkd3d_shader_parser *parser, struct vkd3d_shader_register *reg)
|
||||
+static void materialize_ssas_to_temps_process_reg(struct vsir_program *program, struct vkd3d_shader_register *reg)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (reg->type == VKD3DSPR_SSA)
|
||||
{
|
||||
reg->type = VKD3DSPR_TEMP;
|
||||
- reg->idx[0].offset += parser->program.temp_count;
|
||||
+ reg->idx[0].offset += program->temp_count;
|
||||
}
|
||||
|
||||
for (i = 0; i < reg->idx_count; ++i)
|
||||
if (reg->idx[i].rel_addr)
|
||||
- materialize_ssas_to_temps_process_src_param(parser, reg->idx[i].rel_addr);
|
||||
+ materialize_ssas_to_temps_process_src_param(program, reg->idx[i].rel_addr);
|
||||
}
|
||||
|
||||
-static void materialize_ssas_to_temps_process_dst_param(struct vkd3d_shader_parser *parser, struct vkd3d_shader_dst_param *dst)
|
||||
+static void materialize_ssas_to_temps_process_dst_param(struct vsir_program *program,
|
||||
+ struct vkd3d_shader_dst_param *dst)
|
||||
{
|
||||
- materialize_ssas_to_temps_process_reg(parser, &dst->reg);
|
||||
+ materialize_ssas_to_temps_process_reg(program, &dst->reg);
|
||||
}
|
||||
|
||||
-static void materialize_ssas_to_temps_process_src_param(struct vkd3d_shader_parser *parser, struct vkd3d_shader_src_param *src)
|
||||
+static void materialize_ssas_to_temps_process_src_param(struct vsir_program *program,
|
||||
+ struct vkd3d_shader_src_param *src)
|
||||
{
|
||||
- materialize_ssas_to_temps_process_reg(parser, &src->reg);
|
||||
+ materialize_ssas_to_temps_process_reg(program, &src->reg);
|
||||
}
|
||||
|
||||
static const struct vkd3d_shader_src_param *materialize_ssas_to_temps_compute_source(struct vkd3d_shader_instruction *ins,
|
||||
@@ -2711,7 +2714,7 @@ static const struct vkd3d_shader_src_param *materialize_ssas_to_temps_compute_so
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
-static bool materialize_ssas_to_temps_synthesize_mov(struct vkd3d_shader_parser *parser,
|
||||
+static bool materialize_ssas_to_temps_synthesize_mov(struct vsir_program *program,
|
||||
struct vkd3d_shader_instruction *instruction, const struct vkd3d_shader_location *loc,
|
||||
const struct vkd3d_shader_dst_param *dest, const struct vkd3d_shader_src_param *cond,
|
||||
const struct vkd3d_shader_src_param *source, bool invert)
|
||||
@@ -2719,7 +2722,7 @@ static bool materialize_ssas_to_temps_synthesize_mov(struct vkd3d_shader_parser
|
||||
struct vkd3d_shader_src_param *src;
|
||||
struct vkd3d_shader_dst_param *dst;
|
||||
|
||||
- if (!vsir_instruction_init_with_params(&parser->program, instruction, loc,
|
||||
+ if (!vsir_instruction_init_with_params(program, instruction, loc,
|
||||
cond ? VKD3DSIH_MOVC : VKD3DSIH_MOV, 1, cond ? 3 : 1))
|
||||
return false;
|
||||
|
||||
@@ -2727,7 +2730,7 @@ static bool materialize_ssas_to_temps_synthesize_mov(struct vkd3d_shader_parser
|
||||
src = instruction->src;
|
||||
|
||||
dst[0] = *dest;
|
||||
- materialize_ssas_to_temps_process_dst_param(parser, &dst[0]);
|
||||
+ materialize_ssas_to_temps_process_dst_param(program, &dst[0]);
|
||||
|
||||
assert(dst[0].write_mask == VKD3DSP_WRITEMASK_0);
|
||||
assert(dst[0].modifiers == 0);
|
||||
@@ -2739,19 +2742,19 @@ static bool materialize_ssas_to_temps_synthesize_mov(struct vkd3d_shader_parser
|
||||
src[1 + invert] = *source;
|
||||
memset(&src[2 - invert], 0, sizeof(src[2 - invert]));
|
||||
src[2 - invert].reg = dst[0].reg;
|
||||
- materialize_ssas_to_temps_process_src_param(parser, &src[1]);
|
||||
- materialize_ssas_to_temps_process_src_param(parser, &src[2]);
|
||||
+ materialize_ssas_to_temps_process_src_param(program, &src[1]);
|
||||
+ materialize_ssas_to_temps_process_src_param(program, &src[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
src[0] = *source;
|
||||
- materialize_ssas_to_temps_process_src_param(parser, &src[0]);
|
||||
+ materialize_ssas_to_temps_process_src_param(program, &src[0]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
-static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *parser)
|
||||
+static enum vkd3d_result vsir_program_materialise_ssas_to_temps(struct vsir_program *program)
|
||||
{
|
||||
struct vkd3d_shader_instruction *instructions = NULL;
|
||||
struct materialize_ssas_to_temps_block_data
|
||||
@@ -2762,18 +2765,18 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p
|
||||
size_t ins_capacity = 0, ins_count = 0, i;
|
||||
unsigned int current_label = 0;
|
||||
|
||||
- if (!reserve_instructions(&instructions, &ins_capacity, parser->program.instructions.count))
|
||||
+ if (!reserve_instructions(&instructions, &ins_capacity, program->instructions.count))
|
||||
goto fail;
|
||||
|
||||
- if (!(block_index = vkd3d_calloc(parser->program.block_count, sizeof(*block_index))))
|
||||
+ if (!(block_index = vkd3d_calloc(program->block_count, sizeof(*block_index))))
|
||||
{
|
||||
ERR("Failed to allocate block index.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
- for (i = 0; i < parser->program.instructions.count; ++i)
|
||||
+ for (i = 0; i < program->instructions.count; ++i)
|
||||
{
|
||||
- struct vkd3d_shader_instruction *ins = &parser->program.instructions.elements[i];
|
||||
+ struct vkd3d_shader_instruction *ins = &program->instructions.elements[i];
|
||||
|
||||
switch (ins->handler_idx)
|
||||
{
|
||||
@@ -2795,16 +2798,16 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p
|
||||
}
|
||||
}
|
||||
|
||||
- for (i = 0; i < parser->program.instructions.count; ++i)
|
||||
+ for (i = 0; i < program->instructions.count; ++i)
|
||||
{
|
||||
- struct vkd3d_shader_instruction *ins = &parser->program.instructions.elements[i];
|
||||
+ struct vkd3d_shader_instruction *ins = &program->instructions.elements[i];
|
||||
size_t j;
|
||||
|
||||
for (j = 0; j < ins->dst_count; ++j)
|
||||
- materialize_ssas_to_temps_process_dst_param(parser, &ins->dst[j]);
|
||||
+ materialize_ssas_to_temps_process_dst_param(program, &ins->dst[j]);
|
||||
|
||||
for (j = 0; j < ins->src_count; ++j)
|
||||
- materialize_ssas_to_temps_process_src_param(parser, &ins->src[j]);
|
||||
+ materialize_ssas_to_temps_process_src_param(program, &ins->src[j]);
|
||||
|
||||
switch (ins->handler_idx)
|
||||
{
|
||||
@@ -2825,9 +2828,10 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p
|
||||
{
|
||||
const struct vkd3d_shader_src_param *source;
|
||||
|
||||
- source = materialize_ssas_to_temps_compute_source(&parser->program.instructions.elements[j], current_label);
|
||||
- if (!materialize_ssas_to_temps_synthesize_mov(parser, &instructions[ins_count], &ins->location,
|
||||
- &parser->program.instructions.elements[j].dst[0], NULL, source, false))
|
||||
+ source = materialize_ssas_to_temps_compute_source(&program->instructions.elements[j],
|
||||
+ current_label);
|
||||
+ if (!materialize_ssas_to_temps_synthesize_mov(program, &instructions[ins_count],
|
||||
+ &ins->location, &program->instructions.elements[j].dst[0], NULL, source, false))
|
||||
goto fail;
|
||||
|
||||
++ins_count;
|
||||
@@ -2847,9 +2851,10 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p
|
||||
{
|
||||
const struct vkd3d_shader_src_param *source;
|
||||
|
||||
- source = materialize_ssas_to_temps_compute_source(&parser->program.instructions.elements[j], current_label);
|
||||
- if (!materialize_ssas_to_temps_synthesize_mov(parser, &instructions[ins_count], &ins->location,
|
||||
- &parser->program.instructions.elements[j].dst[0], cond, source, false))
|
||||
+ source = materialize_ssas_to_temps_compute_source(&program->instructions.elements[j],
|
||||
+ current_label);
|
||||
+ if (!materialize_ssas_to_temps_synthesize_mov(program, &instructions[ins_count],
|
||||
+ &ins->location, &program->instructions.elements[j].dst[0], cond, source, false))
|
||||
goto fail;
|
||||
|
||||
++ins_count;
|
||||
@@ -2859,9 +2864,10 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p
|
||||
{
|
||||
const struct vkd3d_shader_src_param *source;
|
||||
|
||||
- source = materialize_ssas_to_temps_compute_source(&parser->program.instructions.elements[j], current_label);
|
||||
- if (!materialize_ssas_to_temps_synthesize_mov(parser, &instructions[ins_count], &ins->location,
|
||||
- &parser->program.instructions.elements[j].dst[0], cond, source, true))
|
||||
+ source = materialize_ssas_to_temps_compute_source(&program->instructions.elements[j],
|
||||
+ current_label);
|
||||
+ if (!materialize_ssas_to_temps_synthesize_mov(program, &instructions[ins_count],
|
||||
+ &ins->location, &program->instructions.elements[j].dst[0], cond, source, true))
|
||||
goto fail;
|
||||
|
||||
++ins_count;
|
||||
@@ -2883,13 +2889,13 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p
|
||||
instructions[ins_count++] = *ins;
|
||||
}
|
||||
|
||||
- vkd3d_free(parser->program.instructions.elements);
|
||||
+ vkd3d_free(program->instructions.elements);
|
||||
vkd3d_free(block_index);
|
||||
- parser->program.instructions.elements = instructions;
|
||||
- parser->program.instructions.capacity = ins_capacity;
|
||||
- parser->program.instructions.count = ins_count;
|
||||
- parser->program.temp_count += parser->program.ssa_count;
|
||||
- parser->program.ssa_count = 0;
|
||||
+ program->instructions.elements = instructions;
|
||||
+ program->instructions.capacity = ins_capacity;
|
||||
+ program->instructions.count = ins_count;
|
||||
+ program->temp_count += program->ssa_count;
|
||||
+ program->ssa_count = 0;
|
||||
|
||||
return VKD3D_OK;
|
||||
|
||||
@@ -2900,20 +2906,20 @@ fail:
|
||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
-static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *parser)
|
||||
+static enum vkd3d_result vsir_program_structurise(struct vsir_program *program)
|
||||
{
|
||||
- const unsigned int block_temp_idx = parser->program.temp_count;
|
||||
+ const unsigned int block_temp_idx = program->temp_count;
|
||||
struct vkd3d_shader_instruction *instructions = NULL;
|
||||
const struct vkd3d_shader_location no_loc = {0};
|
||||
size_t ins_capacity = 0, ins_count = 0, i;
|
||||
bool first_label_found = false;
|
||||
|
||||
- if (!reserve_instructions(&instructions, &ins_capacity, parser->program.instructions.count))
|
||||
+ if (!reserve_instructions(&instructions, &ins_capacity, program->instructions.count))
|
||||
goto fail;
|
||||
|
||||
- for (i = 0; i < parser->program.instructions.count; ++i)
|
||||
+ for (i = 0; i < program->instructions.count; ++i)
|
||||
{
|
||||
- struct vkd3d_shader_instruction *ins = &parser->program.instructions.elements[i];
|
||||
+ struct vkd3d_shader_instruction *ins = &program->instructions.elements[i];
|
||||
|
||||
switch (ins->handler_idx)
|
||||
{
|
||||
@@ -2929,23 +2935,27 @@ static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *par
|
||||
{
|
||||
first_label_found = true;
|
||||
|
||||
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_MOV, 1, 1))
|
||||
+ if (!vsir_instruction_init_with_params(program,
|
||||
+ &instructions[ins_count], &no_loc, VKD3DSIH_MOV, 1, 1))
|
||||
goto fail;
|
||||
dst_param_init_temp_uint(&instructions[ins_count].dst[0], block_temp_idx);
|
||||
src_param_init_const_uint(&instructions[ins_count].src[0], label_from_src_param(&ins->src[0]));
|
||||
ins_count++;
|
||||
|
||||
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_LOOP, 0, 0))
|
||||
+ if (!vsir_instruction_init_with_params(program,
|
||||
+ &instructions[ins_count], &no_loc, VKD3DSIH_LOOP, 0, 0))
|
||||
goto fail;
|
||||
ins_count++;
|
||||
|
||||
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_SWITCH, 0, 1))
|
||||
+ if (!vsir_instruction_init_with_params(program,
|
||||
+ &instructions[ins_count], &no_loc, VKD3DSIH_SWITCH, 0, 1))
|
||||
goto fail;
|
||||
src_param_init_temp_uint(&instructions[ins_count].src[0], block_temp_idx);
|
||||
ins_count++;
|
||||
}
|
||||
|
||||
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_CASE, 0, 1))
|
||||
+ if (!vsir_instruction_init_with_params(program,
|
||||
+ &instructions[ins_count], &no_loc, VKD3DSIH_CASE, 0, 1))
|
||||
goto fail;
|
||||
src_param_init_const_uint(&instructions[ins_count].src[0], label_from_src_param(&ins->src[0]));
|
||||
ins_count++;
|
||||
@@ -2957,7 +2967,8 @@ static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *par
|
||||
|
||||
if (vsir_register_is_label(&ins->src[0].reg))
|
||||
{
|
||||
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_MOV, 1, 1))
|
||||
+ if (!vsir_instruction_init_with_params(program,
|
||||
+ &instructions[ins_count], &no_loc, VKD3DSIH_MOV, 1, 1))
|
||||
goto fail;
|
||||
dst_param_init_temp_uint(&instructions[ins_count].dst[0], block_temp_idx);
|
||||
src_param_init_const_uint(&instructions[ins_count].src[0], label_from_src_param(&ins->src[0]));
|
||||
@@ -2965,7 +2976,8 @@ static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *par
|
||||
}
|
||||
else
|
||||
{
|
||||
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_MOVC, 1, 3))
|
||||
+ if (!vsir_instruction_init_with_params(program,
|
||||
+ &instructions[ins_count], &no_loc, VKD3DSIH_MOVC, 1, 3))
|
||||
goto fail;
|
||||
dst_param_init_temp_uint(&instructions[ins_count].dst[0], block_temp_idx);
|
||||
instructions[ins_count].src[0] = ins->src[0];
|
||||
@@ -2974,7 +2986,8 @@ static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *par
|
||||
ins_count++;
|
||||
}
|
||||
|
||||
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_BREAK, 0, 0))
|
||||
+ if (!vsir_instruction_init_with_params(program,
|
||||
+ &instructions[ins_count], &no_loc, VKD3DSIH_BREAK, 0, 0))
|
||||
goto fail;
|
||||
ins_count++;
|
||||
break;
|
||||
@@ -2994,23 +3007,23 @@ static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *par
|
||||
if (!reserve_instructions(&instructions, &ins_capacity, ins_count + 3))
|
||||
goto fail;
|
||||
|
||||
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_ENDSWITCH, 0, 0))
|
||||
+ if (!vsir_instruction_init_with_params(program, &instructions[ins_count], &no_loc, VKD3DSIH_ENDSWITCH, 0, 0))
|
||||
goto fail;
|
||||
ins_count++;
|
||||
|
||||
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_ENDLOOP, 0, 0))
|
||||
+ if (!vsir_instruction_init_with_params(program, &instructions[ins_count], &no_loc, VKD3DSIH_ENDLOOP, 0, 0))
|
||||
goto fail;
|
||||
ins_count++;
|
||||
|
||||
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_RET, 0, 0))
|
||||
+ if (!vsir_instruction_init_with_params(program, &instructions[ins_count], &no_loc, VKD3DSIH_RET, 0, 0))
|
||||
goto fail;
|
||||
ins_count++;
|
||||
|
||||
- vkd3d_free(parser->program.instructions.elements);
|
||||
- parser->program.instructions.elements = instructions;
|
||||
- parser->program.instructions.capacity = ins_capacity;
|
||||
- parser->program.instructions.count = ins_count;
|
||||
- parser->program.temp_count += 1;
|
||||
+ vkd3d_free(program->instructions.elements);
|
||||
+ program->instructions.elements = instructions;
|
||||
+ program->instructions.capacity = ins_capacity;
|
||||
+ program->instructions.count = ins_count;
|
||||
+ program->temp_count += 1;
|
||||
|
||||
return VKD3D_OK;
|
||||
|
||||
@@ -3906,25 +3919,26 @@ static enum vkd3d_result vsir_cfg_generate_synthetic_loop_intervals(struct vsir_
|
||||
enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser,
|
||||
const struct vkd3d_shader_compile_info *compile_info)
|
||||
{
|
||||
- struct vkd3d_shader_instruction_array *instructions = &parser->program.instructions;
|
||||
+ struct vkd3d_shader_message_context *message_context = parser->message_context;
|
||||
+ struct vsir_program *program = &parser->program;
|
||||
enum vkd3d_result result = VKD3D_OK;
|
||||
|
||||
- remove_dcl_temps(&parser->program);
|
||||
+ remove_dcl_temps(program);
|
||||
|
||||
- if ((result = instruction_array_lower_texkills(parser)) < 0)
|
||||
+ if ((result = vsir_program_lower_texkills(program)) < 0)
|
||||
return result;
|
||||
|
||||
- if (parser->program.shader_version.major >= 6)
|
||||
+ if (program->shader_version.major >= 6)
|
||||
{
|
||||
struct vsir_cfg cfg;
|
||||
|
||||
- if ((result = lower_switch_to_if_ladder(&parser->program)) < 0)
|
||||
+ if ((result = lower_switch_to_if_ladder(program)) < 0)
|
||||
return result;
|
||||
|
||||
- if ((result = materialize_ssas_to_temps(parser)) < 0)
|
||||
+ if ((result = vsir_program_materialise_ssas_to_temps(program)) < 0)
|
||||
return result;
|
||||
|
||||
- if ((result = vsir_cfg_init(&cfg, &parser->program, parser->message_context)) < 0)
|
||||
+ if ((result = vsir_cfg_init(&cfg, program, message_context)) < 0)
|
||||
return result;
|
||||
|
||||
vsir_cfg_compute_dominators(&cfg);
|
||||
@@ -3947,7 +3961,7 @@ enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser,
|
||||
return result;
|
||||
}
|
||||
|
||||
- if ((result = simple_structurizer_run(parser)) < 0)
|
||||
+ if ((result = vsir_program_structurise(program)) < 0)
|
||||
{
|
||||
vsir_cfg_cleanup(&cfg);
|
||||
return result;
|
||||
@@ -3957,29 +3971,29 @@ enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser,
|
||||
}
|
||||
else
|
||||
{
|
||||
- if (parser->program.shader_version.type != VKD3D_SHADER_TYPE_PIXEL)
|
||||
+ if (program->shader_version.type != VKD3D_SHADER_TYPE_PIXEL)
|
||||
{
|
||||
- if ((result = remap_output_signature(parser, compile_info)) < 0)
|
||||
+ if ((result = vsir_program_remap_output_signature(program, compile_info, message_context)) < 0)
|
||||
return result;
|
||||
}
|
||||
|
||||
- if (parser->program.shader_version.type == VKD3D_SHADER_TYPE_HULL)
|
||||
+ if (program->shader_version.type == VKD3D_SHADER_TYPE_HULL)
|
||||
{
|
||||
- if ((result = instruction_array_flatten_hull_shader_phases(instructions)) < 0)
|
||||
+ if ((result = instruction_array_flatten_hull_shader_phases(&program->instructions)) < 0)
|
||||
return result;
|
||||
|
||||
- if ((result = instruction_array_normalise_hull_shader_control_point_io(instructions,
|
||||
- &parser->program.input_signature)) < 0)
|
||||
+ if ((result = instruction_array_normalise_hull_shader_control_point_io(&program->instructions,
|
||||
+ &program->input_signature)) < 0)
|
||||
return result;
|
||||
}
|
||||
|
||||
if ((result = shader_normalise_io_registers(parser)) < 0)
|
||||
return result;
|
||||
|
||||
- if ((result = instruction_array_normalise_flat_constants(&parser->program)) < 0)
|
||||
+ if ((result = instruction_array_normalise_flat_constants(program)) < 0)
|
||||
return result;
|
||||
|
||||
- remove_dead_code(&parser->program);
|
||||
+ remove_dead_code(program);
|
||||
|
||||
if ((result = normalise_combined_samplers(parser)) < 0)
|
||||
return result;
|
||||
@@ -3989,7 +4003,7 @@ enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser,
|
||||
return result;
|
||||
|
||||
if (TRACE_ON())
|
||||
- vkd3d_shader_trace(&parser->program);
|
||||
+ vkd3d_shader_trace(program);
|
||||
|
||||
if (!parser->failed && (result = vsir_validate(parser)) < 0)
|
||||
return result;
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/spirv.c b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
index 0568407f997..1518afa93be 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
@@ -7020,6 +7020,15 @@ static enum vkd3d_result spirv_compiler_emit_alu_instruction(struct spirv_compil
|
||||
SpvOp op = SpvOpMax;
|
||||
unsigned int i;
|
||||
|
||||
+ if (src->reg.data_type == VKD3D_DATA_UINT64 && instruction->handler_idx == VKD3DSIH_COUNTBITS)
|
||||
+ {
|
||||
+ /* At least some drivers support this anyway, but if validation is enabled it will fail. */
|
||||
+ FIXME("Unsupported 64-bit source for bit count.\n");
|
||||
+ spirv_compiler_error(compiler, VKD3D_SHADER_ERROR_SPV_NOT_IMPLEMENTED,
|
||||
+ "64-bit source for bit count is not supported.");
|
||||
+ return VKD3D_ERROR_INVALID_SHADER;
|
||||
+ }
|
||||
+
|
||||
if (src->reg.data_type == VKD3D_DATA_BOOL)
|
||||
{
|
||||
if (dst->reg.data_type == VKD3D_DATA_BOOL)
|
||||
@@ -7160,6 +7169,16 @@ static void spirv_compiler_emit_ext_glsl_instruction(struct spirv_compiler *comp
|
||||
unsigned int i, component_count;
|
||||
enum GLSLstd450 glsl_inst;
|
||||
|
||||
+ if (src[0].reg.data_type == VKD3D_DATA_UINT64 && (instruction->handler_idx == VKD3DSIH_FIRSTBIT_HI
|
||||
+ || instruction->handler_idx == VKD3DSIH_FIRSTBIT_LO || instruction->handler_idx == VKD3DSIH_FIRSTBIT_SHI))
|
||||
+ {
|
||||
+ /* At least some drivers support this anyway, but if validation is enabled it will fail. */
|
||||
+ FIXME("Unsupported 64-bit source for handler %#x.\n", instruction->handler_idx);
|
||||
+ spirv_compiler_error(compiler, VKD3D_SHADER_ERROR_SPV_NOT_IMPLEMENTED,
|
||||
+ "64-bit source for handler %#x is not supported.", instruction->handler_idx);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
glsl_inst = spirv_compiler_map_ext_glsl_instruction(instruction);
|
||||
if (glsl_inst == GLSLstd450Bad)
|
||||
{
|
||||
--
|
||||
2.43.0
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,437 +0,0 @@
|
||||
From 1123af8d7108c26d7c4b4fdb6495d8ad03d8aaa0 Mon Sep 17 00:00:00 2001
|
||||
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
|
||||
Date: Wed, 20 Mar 2024 12:18:36 +1100
|
||||
Subject: [PATCH] Updated vkd3d to 166dc24b2f73b0541a14815081ee4c8d9eab3269.
|
||||
|
||||
---
|
||||
libs/vkd3d/include/private/vkd3d_common.h | 181 +++++++++++++++++-
|
||||
libs/vkd3d/include/private/vkd3d_memory.h | 2 +-
|
||||
libs/vkd3d/libs/vkd3d-common/blob.c | 1 -
|
||||
libs/vkd3d/libs/vkd3d-common/debug.c | 2 +-
|
||||
libs/vkd3d/libs/vkd3d-common/error.c | 1 -
|
||||
libs/vkd3d/libs/vkd3d-shader/ir.c | 8 +-
|
||||
libs/vkd3d/libs/vkd3d-shader/spirv.c | 3 +-
|
||||
.../libs/vkd3d-shader/vkd3d_shader_private.h | 5 +-
|
||||
libs/vkd3d/libs/vkd3d/vkd3d_private.h | 67 -------
|
||||
9 files changed, 189 insertions(+), 81 deletions(-)
|
||||
|
||||
diff --git a/libs/vkd3d/include/private/vkd3d_common.h b/libs/vkd3d/include/private/vkd3d_common.h
|
||||
index 6a3b530d868..974ff9446db 100644
|
||||
--- a/libs/vkd3d/include/private/vkd3d_common.h
|
||||
+++ b/libs/vkd3d/include/private/vkd3d_common.h
|
||||
@@ -30,6 +30,9 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
+#ifndef _WIN32
|
||||
+#include <pthread.h>
|
||||
+#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <intrin.h>
|
||||
@@ -105,11 +108,130 @@ VKD3D_NORETURN static inline void vkd3d_unreachable_(const char *filename, unsig
|
||||
#define vkd3d_unreachable() vkd3d_unreachable_(__FILE__, __LINE__)
|
||||
#endif
|
||||
|
||||
+#ifdef VKD3D_NO_TRACE_MESSAGES
|
||||
+#define TRACE(args...) do { } while (0)
|
||||
+#define TRACE_ON() (false)
|
||||
+#endif
|
||||
+
|
||||
+#ifdef VKD3D_NO_DEBUG_MESSAGES
|
||||
+#define WARN(args...) do { } while (0)
|
||||
+#define FIXME(args...) do { } while (0)
|
||||
+#endif
|
||||
+
|
||||
+enum vkd3d_dbg_level
|
||||
+{
|
||||
+ VKD3D_DBG_LEVEL_NONE,
|
||||
+ VKD3D_DBG_LEVEL_ERR,
|
||||
+ VKD3D_DBG_LEVEL_FIXME,
|
||||
+ VKD3D_DBG_LEVEL_WARN,
|
||||
+ VKD3D_DBG_LEVEL_TRACE,
|
||||
+};
|
||||
+
|
||||
+enum vkd3d_dbg_level vkd3d_dbg_get_level(void);
|
||||
+
|
||||
+void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4);
|
||||
+void vkd3d_dbg_set_log_callback(PFN_vkd3d_log callback);
|
||||
+
|
||||
+const char *vkd3d_dbg_sprintf(const char *fmt, ...) VKD3D_PRINTF_FUNC(1, 2);
|
||||
+const char *vkd3d_dbg_vsprintf(const char *fmt, va_list args);
|
||||
+const char *debugstr_a(const char *str);
|
||||
+const char *debugstr_an(const char *str, size_t n);
|
||||
+const char *debugstr_w(const WCHAR *wstr, size_t wchar_size);
|
||||
+
|
||||
+#define VKD3D_DBG_LOG(level) \
|
||||
+ do { \
|
||||
+ const enum vkd3d_dbg_level vkd3d_dbg_level = VKD3D_DBG_LEVEL_##level; \
|
||||
+ VKD3D_DBG_PRINTF
|
||||
+
|
||||
+#define VKD3D_DBG_LOG_ONCE(first_time_level, level) \
|
||||
+ do { \
|
||||
+ static bool vkd3d_dbg_next_time; \
|
||||
+ const enum vkd3d_dbg_level vkd3d_dbg_level = vkd3d_dbg_next_time \
|
||||
+ ? VKD3D_DBG_LEVEL_##level : VKD3D_DBG_LEVEL_##first_time_level; \
|
||||
+ vkd3d_dbg_next_time = true; \
|
||||
+ VKD3D_DBG_PRINTF
|
||||
+
|
||||
+#define VKD3D_DBG_PRINTF(...) \
|
||||
+ vkd3d_dbg_printf(vkd3d_dbg_level, __FUNCTION__, __VA_ARGS__); } while (0)
|
||||
+
|
||||
+#ifndef TRACE
|
||||
+#define TRACE VKD3D_DBG_LOG(TRACE)
|
||||
+#endif
|
||||
+
|
||||
+#ifndef WARN
|
||||
+#define WARN VKD3D_DBG_LOG(WARN)
|
||||
+#endif
|
||||
+
|
||||
+#ifndef FIXME
|
||||
+#define FIXME VKD3D_DBG_LOG(FIXME)
|
||||
+#endif
|
||||
+
|
||||
+#define ERR VKD3D_DBG_LOG(ERR)
|
||||
+
|
||||
+#ifndef TRACE_ON
|
||||
+#define TRACE_ON() (vkd3d_dbg_get_level() == VKD3D_DBG_LEVEL_TRACE)
|
||||
+#endif
|
||||
+
|
||||
+#ifndef WARN_ON
|
||||
+#define WARN_ON() (vkd3d_dbg_get_level() >= VKD3D_DBG_LEVEL_WARN)
|
||||
+#endif
|
||||
+
|
||||
+#define FIXME_ONCE VKD3D_DBG_LOG_ONCE(FIXME, WARN)
|
||||
+
|
||||
+#define VKD3D_DEBUG_ENV_NAME(name) const char *const vkd3d_dbg_env_name = name
|
||||
+
|
||||
+static inline const char *debugstr_guid(const GUID *guid)
|
||||
+{
|
||||
+ if (!guid)
|
||||
+ return "(null)";
|
||||
+
|
||||
+ return vkd3d_dbg_sprintf("{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
|
||||
+ (unsigned long)guid->Data1, guid->Data2, guid->Data3, guid->Data4[0],
|
||||
+ guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4],
|
||||
+ guid->Data4[5], guid->Data4[6], guid->Data4[7]);
|
||||
+}
|
||||
+
|
||||
+static inline const char *debugstr_hresult(HRESULT hr)
|
||||
+{
|
||||
+ switch (hr)
|
||||
+ {
|
||||
+#define TO_STR(u) case u: return #u;
|
||||
+ TO_STR(S_OK)
|
||||
+ TO_STR(S_FALSE)
|
||||
+ TO_STR(E_NOTIMPL)
|
||||
+ TO_STR(E_NOINTERFACE)
|
||||
+ TO_STR(E_POINTER)
|
||||
+ TO_STR(E_ABORT)
|
||||
+ TO_STR(E_FAIL)
|
||||
+ TO_STR(E_OUTOFMEMORY)
|
||||
+ TO_STR(E_INVALIDARG)
|
||||
+ TO_STR(DXGI_ERROR_NOT_FOUND)
|
||||
+ TO_STR(DXGI_ERROR_MORE_DATA)
|
||||
+ TO_STR(DXGI_ERROR_UNSUPPORTED)
|
||||
+#undef TO_STR
|
||||
+ default:
|
||||
+ return vkd3d_dbg_sprintf("%#x", (int)hr);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+unsigned int vkd3d_env_var_as_uint(const char *name, unsigned int default_value);
|
||||
+
|
||||
+struct vkd3d_debug_option
|
||||
+{
|
||||
+ const char *name;
|
||||
+ uint64_t flag;
|
||||
+};
|
||||
+
|
||||
+bool vkd3d_debug_list_has_member(const char *string, const char *member);
|
||||
+uint64_t vkd3d_parse_debug_options(const char *string,
|
||||
+ const struct vkd3d_debug_option *options, unsigned int option_count);
|
||||
+void vkd3d_set_thread_name(const char *name);
|
||||
+
|
||||
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;
|
||||
@@ -305,6 +427,63 @@ static inline uint32_t vkd3d_atomic_increment_u32(uint32_t volatile *x)
|
||||
return vkd3d_atomic_add_fetch_u32(x, 1);
|
||||
}
|
||||
|
||||
+struct vkd3d_mutex
|
||||
+{
|
||||
+#ifdef _WIN32
|
||||
+ CRITICAL_SECTION lock;
|
||||
+#else
|
||||
+ pthread_mutex_t lock;
|
||||
+#endif
|
||||
+};
|
||||
+
|
||||
+static inline void vkd3d_mutex_init(struct vkd3d_mutex *lock)
|
||||
+{
|
||||
+#ifdef _WIN32
|
||||
+ InitializeCriticalSection(&lock->lock);
|
||||
+#else
|
||||
+ int ret;
|
||||
+
|
||||
+ if ((ret = pthread_mutex_init(&lock->lock, NULL)))
|
||||
+ ERR("Failed to initialise the mutex, ret %d.\n", ret);
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+static inline void vkd3d_mutex_lock(struct vkd3d_mutex *lock)
|
||||
+{
|
||||
+#ifdef _WIN32
|
||||
+ EnterCriticalSection(&lock->lock);
|
||||
+#else
|
||||
+ int ret;
|
||||
+
|
||||
+ if ((ret = pthread_mutex_lock(&lock->lock)))
|
||||
+ ERR("Failed to lock the mutex, ret %d.\n", ret);
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+static inline void vkd3d_mutex_unlock(struct vkd3d_mutex *lock)
|
||||
+{
|
||||
+#ifdef _WIN32
|
||||
+ LeaveCriticalSection(&lock->lock);
|
||||
+#else
|
||||
+ int ret;
|
||||
+
|
||||
+ if ((ret = pthread_mutex_unlock(&lock->lock)))
|
||||
+ ERR("Failed to unlock the mutex, ret %d.\n", ret);
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+static inline void vkd3d_mutex_destroy(struct vkd3d_mutex *lock)
|
||||
+{
|
||||
+#ifdef _WIN32
|
||||
+ DeleteCriticalSection(&lock->lock);
|
||||
+#else
|
||||
+ int ret;
|
||||
+
|
||||
+ if ((ret = pthread_mutex_destroy(&lock->lock)))
|
||||
+ ERR("Failed to destroy the mutex, ret %d.\n", ret);
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
static inline void vkd3d_parse_version(const char *version, int *major, int *minor)
|
||||
{
|
||||
*major = atoi(version);
|
||||
diff --git a/libs/vkd3d/include/private/vkd3d_memory.h b/libs/vkd3d/include/private/vkd3d_memory.h
|
||||
index 8a2edb1000d..bb177e39add 100644
|
||||
--- a/libs/vkd3d/include/private/vkd3d_memory.h
|
||||
+++ b/libs/vkd3d/include/private/vkd3d_memory.h
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
-#include "vkd3d_debug.h"
|
||||
+#include "vkd3d_common.h"
|
||||
|
||||
static inline void *vkd3d_malloc(size_t size)
|
||||
{
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-common/blob.c b/libs/vkd3d/libs/vkd3d-common/blob.c
|
||||
index dbb26de7d73..6bc95dc55c4 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-common/blob.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-common/blob.c
|
||||
@@ -21,7 +21,6 @@
|
||||
#define CONST_VTABLE
|
||||
#include "vkd3d.h"
|
||||
#include "vkd3d_blob.h"
|
||||
-#include "vkd3d_debug.h"
|
||||
#include "vkd3d_memory.h"
|
||||
#include "d3d12shader.h"
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-common/debug.c b/libs/vkd3d/libs/vkd3d-common/debug.c
|
||||
index e12cd39450a..4523fc997ef 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-common/debug.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-common/debug.c
|
||||
@@ -20,7 +20,7 @@
|
||||
# define _WIN32_WINNT 0x0600 /* For InitOnceExecuteOnce(). */
|
||||
#endif
|
||||
|
||||
-#include "vkd3d_debug.h"
|
||||
+#include "vkd3d_common.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-common/error.c b/libs/vkd3d/libs/vkd3d-common/error.c
|
||||
index 3572669ac1c..b8350a5404c 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-common/error.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-common/error.c
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "vkd3d_common.h"
|
||||
-#include "vkd3d_debug.h"
|
||||
|
||||
HRESULT hresult_from_vkd3d_result(int vkd3d_result)
|
||||
{
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/ir.c b/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
index ec32faae8da..4f0226187af 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/ir.c
|
||||
@@ -4393,11 +4393,9 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
-enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser,
|
||||
- const struct vkd3d_shader_compile_info *compile_info)
|
||||
+enum vkd3d_result vsir_program_normalise(struct vsir_program *program, uint64_t config_flags,
|
||||
+ const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context)
|
||||
{
|
||||
- struct vkd3d_shader_message_context *message_context = parser->message_context;
|
||||
- struct vsir_program *program = &parser->program;
|
||||
enum vkd3d_result result = VKD3D_OK;
|
||||
|
||||
remove_dcl_temps(program);
|
||||
@@ -4488,7 +4486,7 @@ enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser,
|
||||
if (TRACE_ON())
|
||||
vkd3d_shader_trace(program);
|
||||
|
||||
- if ((result = vsir_program_validate(program, parser->config_flags,
|
||||
+ if ((result = vsir_program_validate(program, config_flags,
|
||||
compile_info->source_name, message_context)) < 0)
|
||||
return result;
|
||||
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/spirv.c b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
index f830bbdaa6d..673400efd69 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
||||
@@ -10133,7 +10133,8 @@ static int spirv_compiler_generate_spirv(struct spirv_compiler *compiler,
|
||||
enum vkd3d_result result = VKD3D_OK;
|
||||
unsigned int i;
|
||||
|
||||
- if ((result = vkd3d_shader_normalise(parser, compile_info)) < 0)
|
||||
+ if ((result = vsir_program_normalise(program, compiler->config_flags,
|
||||
+ compile_info, compiler->message_context)) < 0)
|
||||
return result;
|
||||
|
||||
if (program->temp_count)
|
||||
diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
index 7503d564af0..a33b6d2d967 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
+++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
||||
@@ -1321,6 +1321,8 @@ struct vsir_program
|
||||
|
||||
bool vsir_program_init(struct vsir_program *program, const struct vkd3d_shader_version *version, unsigned int reserve);
|
||||
void vsir_program_cleanup(struct vsir_program *program);
|
||||
+enum vkd3d_result vsir_program_normalise(struct vsir_program *program, uint64_t config_flags,
|
||||
+ const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context);
|
||||
enum vkd3d_result vsir_program_validate(struct vsir_program *program, uint64_t config_flags,
|
||||
const char *source_name, struct vkd3d_shader_message_context *message_context);
|
||||
|
||||
@@ -1784,7 +1786,4 @@ void dxbc_writer_add_section(struct dxbc_writer *dxbc, uint32_t tag, const void
|
||||
void dxbc_writer_init(struct dxbc_writer *dxbc);
|
||||
int dxbc_writer_write(struct dxbc_writer *dxbc, struct vkd3d_shader_code *code);
|
||||
|
||||
-enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser,
|
||||
- const struct vkd3d_shader_compile_info *compile_info);
|
||||
-
|
||||
#endif /* __VKD3D_SHADER_PRIVATE_H */
|
||||
diff --git a/libs/vkd3d/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/libs/vkd3d/vkd3d_private.h
|
||||
index 34a98c4fc3d..39d892a6fa7 100644
|
||||
--- a/libs/vkd3d/libs/vkd3d/vkd3d_private.h
|
||||
+++ b/libs/vkd3d/libs/vkd3d/vkd3d_private.h
|
||||
@@ -203,36 +203,11 @@ union vkd3d_thread_handle
|
||||
void *handle;
|
||||
};
|
||||
|
||||
-struct vkd3d_mutex
|
||||
-{
|
||||
- CRITICAL_SECTION lock;
|
||||
-};
|
||||
-
|
||||
struct vkd3d_cond
|
||||
{
|
||||
CONDITION_VARIABLE cond;
|
||||
};
|
||||
|
||||
-static inline void vkd3d_mutex_init(struct vkd3d_mutex *lock)
|
||||
-{
|
||||
- InitializeCriticalSection(&lock->lock);
|
||||
-}
|
||||
-
|
||||
-static inline void vkd3d_mutex_lock(struct vkd3d_mutex *lock)
|
||||
-{
|
||||
- EnterCriticalSection(&lock->lock);
|
||||
-}
|
||||
-
|
||||
-static inline void vkd3d_mutex_unlock(struct vkd3d_mutex *lock)
|
||||
-{
|
||||
- LeaveCriticalSection(&lock->lock);
|
||||
-}
|
||||
-
|
||||
-static inline void vkd3d_mutex_destroy(struct vkd3d_mutex *lock)
|
||||
-{
|
||||
- DeleteCriticalSection(&lock->lock);
|
||||
-}
|
||||
-
|
||||
static inline void vkd3d_cond_init(struct vkd3d_cond *cond)
|
||||
{
|
||||
InitializeConditionVariable(&cond->cond);
|
||||
@@ -288,53 +263,11 @@ union vkd3d_thread_handle
|
||||
void *handle;
|
||||
};
|
||||
|
||||
-struct vkd3d_mutex
|
||||
-{
|
||||
- pthread_mutex_t lock;
|
||||
-};
|
||||
-
|
||||
struct vkd3d_cond
|
||||
{
|
||||
pthread_cond_t cond;
|
||||
};
|
||||
|
||||
-
|
||||
-static inline void vkd3d_mutex_init(struct vkd3d_mutex *lock)
|
||||
-{
|
||||
- int ret;
|
||||
-
|
||||
- ret = pthread_mutex_init(&lock->lock, NULL);
|
||||
- if (ret)
|
||||
- ERR("Could not initialize the mutex, error %d.\n", ret);
|
||||
-}
|
||||
-
|
||||
-static inline void vkd3d_mutex_lock(struct vkd3d_mutex *lock)
|
||||
-{
|
||||
- int ret;
|
||||
-
|
||||
- ret = pthread_mutex_lock(&lock->lock);
|
||||
- if (ret)
|
||||
- ERR("Could not lock the mutex, error %d.\n", ret);
|
||||
-}
|
||||
-
|
||||
-static inline void vkd3d_mutex_unlock(struct vkd3d_mutex *lock)
|
||||
-{
|
||||
- int ret;
|
||||
-
|
||||
- ret = pthread_mutex_unlock(&lock->lock);
|
||||
- if (ret)
|
||||
- ERR("Could not unlock the mutex, error %d.\n", ret);
|
||||
-}
|
||||
-
|
||||
-static inline void vkd3d_mutex_destroy(struct vkd3d_mutex *lock)
|
||||
-{
|
||||
- int ret;
|
||||
-
|
||||
- ret = pthread_mutex_destroy(&lock->lock);
|
||||
- if (ret)
|
||||
- ERR("Could not destroy the mutex, error %d.\n", ret);
|
||||
-}
|
||||
-
|
||||
static inline void vkd3d_cond_init(struct vkd3d_cond *cond)
|
||||
{
|
||||
int ret;
|
||||
--
|
||||
2.43.0
|
||||
|
Loading…
Reference in New Issue
Block a user