From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- libs/vkd3d-shader/hlsl.y | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index bc59f84d..b38926fd 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -3456,11 +3456,16 @@ static bool intrinsic_tex(struct hlsl_ctx *ctx, const struct parse_initializer * hlsl_release_string_buffer(ctx, string); }
- if (!strcmp(name, "tex2Dproj")) + if (!strcmp(name, "tex1Dproj") + || !strcmp(name, "tex2Dproj")) { coords_dim = 4; load_params.type = HLSL_RESOURCE_SAMPLE_PROJ; } + else if (dim == HLSL_SAMPLER_DIM_1D) + { + coords_dim = 2; + } else { coords_dim = hlsl_sampler_dim_count(dim); @@ -3474,8 +3479,6 @@ static bool intrinsic_tex(struct hlsl_ctx *ctx, const struct parse_initializer *
if (load_params.type == HLSL_RESOURCE_SAMPLE_PROJ && shader_profile_version_ge(ctx, 4, 0)) { - coords_dim = hlsl_sampler_dim_count(dim); - if (!(divisor = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(W, W, W, W), coords_dim, coords, loc))) return false; hlsl_block_add_instr(params->instrs, divisor); @@ -3494,25 +3497,30 @@ static bool intrinsic_tex(struct hlsl_ctx *ctx, const struct parse_initializer * is used for the second coordinate, while older ones appear to replicate first coordinate.*/ if (dim == HLSL_SAMPLER_DIM_1D) { + struct hlsl_ir_node *half, *store; + struct hlsl_block store_block; + struct hlsl_deref dst_deref; struct hlsl_ir_load *load; - struct hlsl_ir_node *half; struct hlsl_ir_var *var; - unsigned int idx = 0;
- if (!(var = hlsl_new_synthetic_var(ctx, "coords", hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, 2), loc))) + if (!(var = hlsl_new_synthetic_var(ctx, "coords", hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, coords_dim), loc))) return false;
- initialize_var_components(ctx, params->instrs, var, &idx, coords); + if (!(store = hlsl_new_simple_store(ctx, var, coords))) + return NULL; + hlsl_block_add_instr(params->instrs, store); + if (shader_profile_version_ge(ctx, 4, 0)) { if (!(half = hlsl_new_float_constant(ctx, 0.5f, loc))) return false; hlsl_block_add_instr(params->instrs, half);
- initialize_var_components(ctx, params->instrs, var, &idx, half); + hlsl_init_simple_deref_from_var(&dst_deref, var); + if (!hlsl_new_store_component(ctx, &store_block, &dst_deref, 1, half)) + return false; + hlsl_block_add_block(params->instrs, &store_block); } - else - initialize_var_components(ctx, params->instrs, var, &idx, coords);
if (!(load = hlsl_new_var_load(ctx, var, loc))) return false; @@ -3540,6 +3548,12 @@ static bool intrinsic_tex1D(struct hlsl_ctx *ctx, return intrinsic_tex(ctx, params, loc, "tex1D", HLSL_SAMPLER_DIM_1D); }
+static bool intrinsic_tex1Dproj(struct hlsl_ctx *ctx, + const struct parse_initializer *params, const struct vkd3d_shader_location *loc) +{ + return intrinsic_tex(ctx, params, loc, "tex1Dproj", HLSL_SAMPLER_DIM_1D); +} + static bool intrinsic_tex2D(struct hlsl_ctx *ctx, const struct parse_initializer *params, const struct vkd3d_shader_location *loc) { @@ -3733,6 +3747,7 @@ intrinsic_functions[] = {"sqrt", 1, true, intrinsic_sqrt}, {"step", 2, true, intrinsic_step}, {"tex1D", -1, false, intrinsic_tex1D}, + {"tex1Dproj", 2, false, intrinsic_tex1Dproj}, {"tex2D", -1, false, intrinsic_tex2D}, {"tex2Dproj", 2, false, intrinsic_tex2Dproj}, {"tex3D", -1, false, intrinsic_tex3D},