vkd3d-shader/hlsl: Make HLSL_TYPE_TEXTURE into a separate class.

This commit is contained in:
Zebediah Figura 2024-02-05 20:25:57 -06:00 committed by Alexandre Julliard
parent 220362cbad
commit 93d7cd1785
Notes: Alexandre Julliard 2024-04-19 22:26:17 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/781
7 changed files with 143 additions and 118 deletions

View File

@ -1515,6 +1515,7 @@ D3DXPARAMETER_CLASS hlsl_sm1_class(const struct hlsl_type *type)
case HLSL_CLASS_OBJECT:
case HLSL_CLASS_SAMPLER:
case HLSL_CLASS_STRING:
case HLSL_CLASS_TEXTURE:
return D3DXPC_OBJECT;
case HLSL_CLASS_VOID:
break;
@ -1572,29 +1573,30 @@ D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type)
}
break;
case HLSL_CLASS_TEXTURE:
switch (type->sampler_dim)
{
case HLSL_SAMPLER_DIM_1D:
return D3DXPT_TEXTURE1D;
case HLSL_SAMPLER_DIM_2D:
return D3DXPT_TEXTURE2D;
case HLSL_SAMPLER_DIM_3D:
return D3DXPT_TEXTURE3D;
case HLSL_SAMPLER_DIM_CUBE:
return D3DXPT_TEXTURECUBE;
case HLSL_SAMPLER_DIM_GENERIC:
return D3DXPT_TEXTURE;
default:
ERR("Invalid dimension %#x.\n", type->sampler_dim);
vkd3d_unreachable();
}
break;
case HLSL_CLASS_OBJECT:
switch (type->base_type)
{
case HLSL_TYPE_PIXELSHADER:
return D3DXPT_PIXELSHADER;
case HLSL_TYPE_TEXTURE:
switch (type->sampler_dim)
{
case HLSL_SAMPLER_DIM_1D:
return D3DXPT_TEXTURE1D;
case HLSL_SAMPLER_DIM_2D:
return D3DXPT_TEXTURE2D;
case HLSL_SAMPLER_DIM_3D:
return D3DXPT_TEXTURE3D;
case HLSL_SAMPLER_DIM_CUBE:
return D3DXPT_TEXTURECUBE;
case HLSL_SAMPLER_DIM_GENERIC:
return D3DXPT_TEXTURE;
default:
ERR("Invalid dimension %#x.\n", type->sampler_dim);
vkd3d_unreachable();
}
break;
case HLSL_TYPE_VERTEXSHADER:
return D3DXPT_VERTEXSHADER;
default:

View File

@ -380,7 +380,7 @@ static const char * get_fx_4_type_name(const struct hlsl_type *type)
[HLSL_SAMPLER_DIM_STRUCTURED_BUFFER] = "RWStructuredBuffer",
};
if (type->base_type == HLSL_TYPE_TEXTURE)
if (type->class == HLSL_CLASS_TEXTURE)
return texture_type_names[type->sampler_dim];
if (type->base_type == HLSL_TYPE_UAV)
@ -427,6 +427,7 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
break;
case HLSL_CLASS_OBJECT:
case HLSL_CLASS_TEXTURE:
put_u32_unaligned(buffer, 2);
break;
@ -475,15 +476,8 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
put_u32_unaligned(buffer, field_type_offset);
}
}
else if (type->class == HLSL_CLASS_OBJECT)
else if (type->class == HLSL_CLASS_TEXTURE)
{
static const uint32_t object_type[] =
{
[HLSL_TYPE_PIXELSHADER] = 5,
[HLSL_TYPE_VERTEXSHADER] = 6,
[HLSL_TYPE_RENDERTARGETVIEW] = 19,
[HLSL_TYPE_DEPTHSTENCILVIEW] = 20,
};
static const uint32_t texture_type[] =
{
[HLSL_SAMPLER_DIM_GENERIC] = 9,
@ -497,6 +491,18 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
[HLSL_SAMPLER_DIM_CUBE] = 17,
[HLSL_SAMPLER_DIM_CUBEARRAY] = 23,
};
put_u32_unaligned(buffer, texture_type[type->sampler_dim]);
}
else if (type->class == HLSL_CLASS_OBJECT)
{
static const uint32_t object_type[] =
{
[HLSL_TYPE_PIXELSHADER] = 5,
[HLSL_TYPE_VERTEXSHADER] = 6,
[HLSL_TYPE_RENDERTARGETVIEW] = 19,
[HLSL_TYPE_DEPTHSTENCILVIEW] = 20,
};
static const uint32_t uav_type[] =
{
[HLSL_SAMPLER_DIM_1D] = 31,
@ -516,9 +522,6 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
case HLSL_TYPE_VERTEXSHADER:
put_u32_unaligned(buffer, object_type[type->base_type]);
break;
case HLSL_TYPE_TEXTURE:
put_u32_unaligned(buffer, texture_type[type->sampler_dim]);
break;
case HLSL_TYPE_UAV:
put_u32_unaligned(buffer, uav_type[type->sampler_dim]);
break;
@ -794,23 +797,23 @@ static bool is_type_supported_fx_2(struct hlsl_ctx *ctx, const struct hlsl_type
case HLSL_CLASS_ARRAY:
return is_type_supported_fx_2(ctx, type->e.array.type, loc);
case HLSL_CLASS_TEXTURE:
switch (type->sampler_dim)
{
case HLSL_SAMPLER_DIM_1D:
case HLSL_SAMPLER_DIM_2D:
case HLSL_SAMPLER_DIM_3D:
case HLSL_SAMPLER_DIM_CUBE:
case HLSL_SAMPLER_DIM_GENERIC:
return true;
default:
return false;
}
break;
case HLSL_CLASS_OBJECT:
switch (type->base_type)
{
case HLSL_TYPE_TEXTURE:
switch (type->sampler_dim)
{
case HLSL_SAMPLER_DIM_1D:
case HLSL_SAMPLER_DIM_2D:
case HLSL_SAMPLER_DIM_3D:
case HLSL_SAMPLER_DIM_CUBE:
case HLSL_SAMPLER_DIM_GENERIC:
return true;
default:
return false;
}
break;
case HLSL_TYPE_PIXELSHADER:
case HLSL_TYPE_VERTEXSHADER:
hlsl_fixme(ctx, loc, "Write fx 2.0 parameter object type %#x.", type->base_type);
@ -1002,19 +1005,30 @@ static void write_fx_4_object_variable(struct hlsl_ir_var *var, struct fx_write_
}
/* Initializer */
switch (type->base_type)
switch (type->class)
{
case HLSL_TYPE_TEXTURE:
case HLSL_TYPE_UAV:
case HLSL_TYPE_RENDERTARGETVIEW:
case HLSL_CLASS_TEXTURE:
break;
case HLSL_TYPE_PIXELSHADER:
case HLSL_TYPE_VERTEXSHADER:
/* FIXME: write shader blobs, once parser support works. */
for (i = 0; i < elements_count; ++i)
put_u32(buffer, 0);
++fx->shader_variable_count;
case HLSL_CLASS_OBJECT:
switch (type->base_type)
{
case HLSL_TYPE_UAV:
case HLSL_TYPE_RENDERTARGETVIEW:
break;
case HLSL_TYPE_PIXELSHADER:
case HLSL_TYPE_VERTEXSHADER:
/* FIXME: write shader blobs, once parser support works. */
for (i = 0; i < elements_count; ++i)
put_u32(buffer, 0);
++fx->shader_variable_count;
break;
default:
hlsl_fixme(ctx, &ctx->location, "Writing initializer for object type %u is not implemented.",
type->base_type);
}
break;
default:
hlsl_fixme(ctx, &ctx->location, "Writing initializer for object type %u is not implemented.",
type->base_type);
@ -1101,12 +1115,12 @@ static bool is_object_variable(const struct hlsl_ir_var *var)
switch (type->class)
{
case HLSL_CLASS_SAMPLER:
case HLSL_CLASS_TEXTURE:
return true;
case HLSL_CLASS_OBJECT:
switch (type->base_type)
{
case HLSL_TYPE_TEXTURE:
case HLSL_TYPE_UAV:
case HLSL_TYPE_PIXELSHADER:
case HLSL_TYPE_VERTEXSHADER:

View File

@ -232,12 +232,12 @@ bool hlsl_type_is_resource(const struct hlsl_type *type)
return hlsl_type_is_resource(type->e.array.type);
case HLSL_CLASS_SAMPLER:
case HLSL_CLASS_TEXTURE:
return true;
case HLSL_CLASS_OBJECT:
switch (type->base_type)
{
case HLSL_TYPE_TEXTURE:
case HLSL_TYPE_UAV:
return true;
default:
@ -266,12 +266,12 @@ static enum hlsl_regset type_get_regset(const struct hlsl_type *type)
case HLSL_CLASS_SAMPLER:
return HLSL_REGSET_SAMPLERS;
case HLSL_CLASS_TEXTURE:
return HLSL_REGSET_TEXTURES;
case HLSL_CLASS_OBJECT:
switch (type->base_type)
{
case HLSL_TYPE_TEXTURE:
return HLSL_REGSET_TEXTURES;
case HLSL_TYPE_UAV:
return HLSL_REGSET_UAVS;
@ -381,6 +381,10 @@ static void hlsl_type_calculate_reg_size(struct hlsl_ctx *ctx, struct hlsl_type
type->reg_size[HLSL_REGSET_SAMPLERS] = 1;
break;
case HLSL_CLASS_TEXTURE:
type->reg_size[HLSL_REGSET_TEXTURES] = 1;
break;
case HLSL_CLASS_STRING:
case HLSL_CLASS_VOID:
break;
@ -446,6 +450,7 @@ static bool type_is_single_component(const struct hlsl_type *type)
case HLSL_CLASS_OBJECT:
case HLSL_CLASS_SAMPLER:
case HLSL_CLASS_STRING:
case HLSL_CLASS_TEXTURE:
return true;
case HLSL_CLASS_VECTOR:
@ -579,6 +584,7 @@ unsigned int hlsl_type_get_component_offset(struct hlsl_ctx *ctx, struct hlsl_ty
case HLSL_CLASS_OBJECT:
case HLSL_CLASS_SAMPLER:
case HLSL_CLASS_STRING:
case HLSL_CLASS_TEXTURE:
assert(idx == 0);
break;
@ -827,8 +833,7 @@ struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_
if (!(type = hlsl_alloc(ctx, sizeof(*type))))
return NULL;
type->class = HLSL_CLASS_OBJECT;
type->base_type = HLSL_TYPE_TEXTURE;
type->class = HLSL_CLASS_TEXTURE;
type->dimx = 4;
type->dimy = 1;
type->sampler_dim = dim;
@ -952,6 +957,7 @@ unsigned int hlsl_type_component_count(const struct hlsl_type *type)
case HLSL_CLASS_OBJECT:
case HLSL_CLASS_SAMPLER:
case HLSL_CLASS_STRING:
case HLSL_CLASS_TEXTURE:
return 1;
case HLSL_CLASS_VOID:
@ -970,12 +976,12 @@ bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2
return false;
if (t1->base_type != t2->base_type)
return false;
if (t1->class == HLSL_CLASS_SAMPLER || t1->base_type == HLSL_TYPE_TEXTURE
if (t1->class == HLSL_CLASS_SAMPLER || t1->class == HLSL_CLASS_TEXTURE
|| t1->base_type == HLSL_TYPE_UAV)
{
if (t1->sampler_dim != t2->sampler_dim)
return false;
if ((t1->base_type == HLSL_TYPE_TEXTURE || t1->base_type == HLSL_TYPE_UAV)
if ((t1->class == HLSL_CLASS_TEXTURE || t1->base_type == HLSL_TYPE_UAV)
&& t1->sampler_dim != HLSL_SAMPLER_DIM_GENERIC
&& !hlsl_types_are_equal(t1->e.resource.format, t2->e.resource.format))
return false;
@ -1096,10 +1102,14 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old,
break;
}
case HLSL_CLASS_TEXTURE:
type->e.resource.format = old->e.resource.format;
break;
case HLSL_CLASS_OBJECT:
if (type->base_type == HLSL_TYPE_TECHNIQUE)
type->e.version = old->e.version;
if (old->base_type == HLSL_TYPE_TEXTURE || old->base_type == HLSL_TYPE_UAV)
if (old->base_type == HLSL_TYPE_UAV)
{
type->e.resource.format = old->e.resource.format;
type->e.resource.rasteriser_ordered = old->e.resource.rasteriser_ordered;
@ -1678,8 +1688,7 @@ bool hlsl_index_is_resource_access(struct hlsl_ir_index *index)
{
const struct hlsl_type *type = index->val.node->data_type;
return type->class == HLSL_CLASS_OBJECT
&& (type->base_type == HLSL_TYPE_TEXTURE || type->base_type == HLSL_TYPE_UAV);
return type->class == HLSL_CLASS_TEXTURE || (type->class == HLSL_CLASS_OBJECT && type->base_type == HLSL_TYPE_UAV);
}
bool hlsl_index_chain_has_resource_access(struct hlsl_ir_index *index)
@ -1700,7 +1709,7 @@ struct hlsl_ir_node *hlsl_new_index(struct hlsl_ctx *ctx, struct hlsl_ir_node *v
if (!(index = hlsl_alloc(ctx, sizeof(*index))))
return NULL;
if (type->class == HLSL_CLASS_OBJECT)
if (type->class == HLSL_CLASS_TEXTURE || type->class == HLSL_CLASS_OBJECT)
type = type->e.resource.format;
else if (type->class == HLSL_CLASS_MATRIX)
type = hlsl_get_vector_type(ctx, type->base_type, type->dimx);
@ -2264,6 +2273,19 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru
[HLSL_TYPE_BOOL] = "bool",
};
static const char *const dimensions[] =
{
[HLSL_SAMPLER_DIM_1D] = "1D",
[HLSL_SAMPLER_DIM_2D] = "2D",
[HLSL_SAMPLER_DIM_3D] = "3D",
[HLSL_SAMPLER_DIM_CUBE] = "Cube",
[HLSL_SAMPLER_DIM_1DARRAY] = "1DArray",
[HLSL_SAMPLER_DIM_2DARRAY] = "2DArray",
[HLSL_SAMPLER_DIM_2DMS] = "2DMS",
[HLSL_SAMPLER_DIM_2DMSARRAY] = "2DMSArray",
[HLSL_SAMPLER_DIM_CUBEARRAY] = "CubeArray",
};
if (!(string = hlsl_get_string_buffer(ctx)))
return NULL;
@ -2317,47 +2339,34 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru
vkd3d_string_buffer_printf(string, "<anonymous struct>");
return string;
case HLSL_CLASS_TEXTURE:
if (type->sampler_dim == HLSL_SAMPLER_DIM_GENERIC)
{
vkd3d_string_buffer_printf(string, "Texture");
return string;
}
assert(type->e.resource.format->base_type < ARRAY_SIZE(base_types));
if (type->sampler_dim == HLSL_SAMPLER_DIM_BUFFER)
{
vkd3d_string_buffer_printf(string, "Buffer");
}
else
{
assert(type->sampler_dim < ARRAY_SIZE(dimensions));
vkd3d_string_buffer_printf(string, "Texture%s", dimensions[type->sampler_dim]);
}
if ((inner_string = hlsl_type_to_string(ctx, type->e.resource.format)))
{
vkd3d_string_buffer_printf(string, "<%s>", inner_string->buffer);
hlsl_release_string_buffer(ctx, inner_string);
}
return string;
case HLSL_CLASS_OBJECT:
{
static const char *const dimensions[] =
{
[HLSL_SAMPLER_DIM_1D] = "1D",
[HLSL_SAMPLER_DIM_2D] = "2D",
[HLSL_SAMPLER_DIM_3D] = "3D",
[HLSL_SAMPLER_DIM_CUBE] = "Cube",
[HLSL_SAMPLER_DIM_1DARRAY] = "1DArray",
[HLSL_SAMPLER_DIM_2DARRAY] = "2DArray",
[HLSL_SAMPLER_DIM_2DMS] = "2DMS",
[HLSL_SAMPLER_DIM_2DMSARRAY] = "2DMSArray",
[HLSL_SAMPLER_DIM_CUBEARRAY] = "CubeArray",
};
switch (type->base_type)
{
case HLSL_TYPE_TEXTURE:
if (type->sampler_dim == HLSL_SAMPLER_DIM_GENERIC)
{
vkd3d_string_buffer_printf(string, "Texture");
return string;
}
assert(type->e.resource.format->base_type < ARRAY_SIZE(base_types));
if (type->sampler_dim == HLSL_SAMPLER_DIM_BUFFER)
{
vkd3d_string_buffer_printf(string, "Buffer");
}
else
{
assert(type->sampler_dim < ARRAY_SIZE(dimensions));
vkd3d_string_buffer_printf(string, "Texture%s", dimensions[type->sampler_dim]);
}
if ((inner_string = hlsl_type_to_string(ctx, type->e.resource.format)))
{
vkd3d_string_buffer_printf(string, "<%s>", inner_string->buffer);
hlsl_release_string_buffer(ctx, inner_string);
}
return string;
case HLSL_TYPE_UAV:
if (type->sampler_dim == HLSL_SAMPLER_DIM_BUFFER)
vkd3d_string_buffer_printf(string, "RWBuffer");
@ -3556,7 +3565,6 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
{"matrix", HLSL_CLASS_MATRIX, HLSL_TYPE_FLOAT, 4, 4},
{"fxgroup", HLSL_CLASS_OBJECT, HLSL_TYPE_EFFECT_GROUP, 1, 1},
{"pass", HLSL_CLASS_OBJECT, HLSL_TYPE_PASS, 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},
{"RenderTargetView",HLSL_CLASS_OBJECT, HLSL_TYPE_RENDERTARGETVIEW, 1, 1},
@ -3673,6 +3681,7 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
ctx->builtin_types.Void = hlsl_new_simple_type(ctx, "void", HLSL_CLASS_VOID);
hlsl_scope_add_type(ctx->globals, hlsl_new_simple_type(ctx, "STRING", HLSL_CLASS_STRING));
hlsl_scope_add_type(ctx->globals, hlsl_new_simple_type(ctx, "texture", HLSL_CLASS_TEXTURE));
for (i = 0; i < ARRAY_SIZE(effect_types); ++i)
{

View File

@ -81,6 +81,7 @@ enum hlsl_type_class
HLSL_CLASS_OBJECT,
HLSL_CLASS_SAMPLER,
HLSL_CLASS_STRING,
HLSL_CLASS_TEXTURE,
HLSL_CLASS_VOID,
};
@ -93,7 +94,6 @@ enum hlsl_base_type
HLSL_TYPE_UINT,
HLSL_TYPE_BOOL,
HLSL_TYPE_LAST_SCALAR = HLSL_TYPE_BOOL,
HLSL_TYPE_TEXTURE,
HLSL_TYPE_UAV,
HLSL_TYPE_PIXELSHADER,
HLSL_TYPE_VERTEXSHADER,
@ -151,7 +151,7 @@ struct hlsl_type
enum hlsl_base_type base_type;
/* If class is HLSL_CLASS_SAMPLER, then sampler_dim is <= HLSL_SAMPLER_DIM_LAST_SAMPLER.
* If base_type is HLSL_TYPE_TEXTURE, then sampler_dim can be any value of the enum except
* If class is HLSL_CLASS_TEXTURE, then sampler_dim can be any value of the enum except
* HLSL_SAMPLER_DIM_GENERIC and HLSL_SAMPLER_DIM_COMPARISON.
* If base_type is HLSL_TYPE_UAV, then sampler_dim must be one of HLSL_SAMPLER_DIM_1D,
* HLSL_SAMPLER_DIM_2D, HLSL_SAMPLER_DIM_3D, HLSL_SAMPLER_DIM_1DARRAY, HLSL_SAMPLER_DIM_2DARRAY,
@ -172,7 +172,6 @@ struct hlsl_type
* If type is HLSL_CLASS_ARRAY, then dimx and dimy have the same value as in the type of the array elements.
* If type is HLSL_CLASS_STRUCT, then dimx is the sum of (dimx * dimy) of every component, and dimy = 1.
* If type is HLSL_CLASS_OBJECT, dimx and dimy depend on the base_type:
* If base_type is HLSL_TYPE_TEXTURE, then dimx = 4 and dimy = 1.
* If base_type is HLSL_TYPE_UAV, then dimx is the dimx of e.resource_format, and dimy = 1.
*/
unsigned int dimx;

View File

@ -833,8 +833,8 @@ static bool add_array_access(struct hlsl_ctx *ctx, struct hlsl_block *block, str
const struct hlsl_type *expr_type = array->data_type, *index_type = index->data_type;
struct hlsl_ir_node *return_index, *cast;
if (expr_type->class == HLSL_CLASS_OBJECT
&& (expr_type->base_type == HLSL_TYPE_TEXTURE || expr_type->base_type == HLSL_TYPE_UAV)
if ((expr_type->class == HLSL_CLASS_TEXTURE
|| (expr_type->class == HLSL_CLASS_OBJECT && expr_type->base_type == HLSL_TYPE_UAV))
&& expr_type->sampler_dim != HLSL_SAMPLER_DIM_GENERIC)
{
unsigned int dim_count = hlsl_sampler_dim_count(expr_type->sampler_dim);
@ -1941,8 +1941,8 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct hlsl_blo
return NULL;
resource_type = hlsl_deref_get_type(ctx, &resource_deref);
assert(resource_type->class == HLSL_CLASS_OBJECT);
assert(resource_type->base_type == HLSL_TYPE_TEXTURE || resource_type->base_type == HLSL_TYPE_UAV);
assert(resource_type->class == HLSL_CLASS_TEXTURE
|| (resource_type->class == HLSL_CLASS_OBJECT && resource_type->base_type == HLSL_TYPE_UAV));
if (resource_type->base_type != HLSL_TYPE_UAV)
hlsl_error(ctx, &lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
@ -5277,8 +5277,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct hlsl_block *block, stru
const struct hlsl_type *object_type = object->data_type;
const struct method_function *method;
if (object_type->class != HLSL_CLASS_OBJECT || object_type->base_type != HLSL_TYPE_TEXTURE
|| object_type->sampler_dim == HLSL_SAMPLER_DIM_GENERIC)
if (object_type->class != HLSL_CLASS_TEXTURE || object_type->sampler_dim == HLSL_SAMPLER_DIM_GENERIC)
{
struct vkd3d_string_buffer *string;

View File

@ -1626,6 +1626,7 @@ static bool copy_propagation_transform_load(struct hlsl_ctx *ctx,
case HLSL_CLASS_SCALAR:
case HLSL_CLASS_VECTOR:
case HLSL_CLASS_SAMPLER:
case HLSL_CLASS_TEXTURE:
case HLSL_CLASS_OBJECT:
break;
@ -2611,7 +2612,7 @@ static bool lower_combined_samples(struct hlsl_ctx *ctx, struct hlsl_ir_node *in
hlsl_copy_deref(ctx, &load->sampler, &load->resource);
load->resource.var = var;
assert(hlsl_deref_get_type(ctx, &load->resource)->base_type == HLSL_TYPE_TEXTURE);
assert(hlsl_deref_get_type(ctx, &load->resource)->class == HLSL_CLASS_TEXTURE);
assert(hlsl_deref_get_type(ctx, &load->sampler)->class == HLSL_CLASS_SAMPLER);
return true;

View File

@ -3010,6 +3010,7 @@ static D3D_SHADER_VARIABLE_CLASS sm4_class(const struct hlsl_type *type)
case HLSL_CLASS_OBJECT:
case HLSL_CLASS_SAMPLER:
case HLSL_CLASS_STRING:
case HLSL_CLASS_TEXTURE:
case HLSL_CLASS_VOID:
break;
}
@ -3116,11 +3117,11 @@ static D3D_SHADER_INPUT_TYPE sm4_resource_type(const struct hlsl_type *type)
return sm4_resource_type(type->e.array.type);
case HLSL_CLASS_SAMPLER:
return D3D_SIT_SAMPLER;
case HLSL_CLASS_TEXTURE:
return D3D_SIT_TEXTURE;
case HLSL_CLASS_OBJECT:
switch (type->base_type)
{
case HLSL_TYPE_TEXTURE:
return D3D_SIT_TEXTURE;
case HLSL_TYPE_UAV:
return D3D_SIT_UAV_RWTYPED;
default:
@ -4569,7 +4570,7 @@ static void write_sm4_ld(const struct tpf_writer *tpf, const struct hlsl_ir_node
enum hlsl_sampler_dim dim)
{
const struct hlsl_type *resource_type = hlsl_deref_get_type(tpf->ctx, resource);
bool multisampled = resource_type->base_type == HLSL_TYPE_TEXTURE
bool multisampled = resource_type->class == HLSL_CLASS_TEXTURE
&& (resource_type->sampler_dim == HLSL_SAMPLER_DIM_2DMS || resource_type->sampler_dim == HLSL_SAMPLER_DIM_2DMSARRAY);
bool uav = (hlsl_deref_get_regset(tpf->ctx, resource) == HLSL_REGSET_UAVS);
unsigned int coords_writemask = VKD3DSP_WRITEMASK_ALL;