Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • wine/vkd3d
  • stefan/vkd3d
  • cmccarthy/vkd3d
  • giomasce/vkd3d
  • fcasas/vkd3d
  • jactry/vkd3d
  • ReDress/vkd3d
  • mstorsjo/vkd3d
  • huw/vkd3d
  • julliard/vkd3d
  • bshanks/vkd3d
  • zfigura/vkd3d
  • hverbeet/vkd3d
  • DarkShadow44/vkd3d
  • nsivov/vkd3d
  • dhary686/vkd3d
  • Mystral/vkd3d
  • maljaf/vkd3d
  • smcv/vkd3d
  • flibitijibibo/vkd3d
  • q4a/vkd3d
  • jsikorski/vkd3d
  • alesliehughes/vkd3d-alesliehughes
  • vitorhnn/vkd3d
  • agusev/vkd3d
  • etang-cw/vkd3d
  • petrathekat/vkd3d
  • simon.mr995/vkd3d
  • sgwaki/vkd3d
  • jacek/vkd3d
  • fweimer/vkd3d
  • Clara/vkd3d
  • disini/vkd3d
  • antenabr2/vkd3d
  • gilvbp/vkd3d
  • yshui/vkd3d
  • shaunren/vkd3d
  • jennetsaryyewa96/vkd3d
  • Jamesattay/vkd3d
  • zacemmneeto77/vkd3d
  • GermanAizek/vkd3d
  • opespinach/vkd3d
  • ruslanboyka201/vkd3d
  • navi/vkd3d
  • Feifan/vkd3d
  • yashmhmdly172/vkd3d
  • Sec32fun32/vkd3d
  • ritalat/vkd3d
  • ivyl/vkd3d
  • baikaishiuc/vkd3d
  • austin987/vkd3d
  • TornadoCookie/vkd3d
52 results
Show changes
Commits on Source (28)
Showing
with 1079 additions and 285 deletions
......@@ -71,6 +71,7 @@ vkd3d_shader_tests = \
tests/exp.shader_test \
tests/expr-indexing.shader_test \
tests/floor.shader_test \
tests/fmod.shader_test \
tests/frac.shader_test \
tests/function-return.shader_test \
tests/hlsl-array-dimension.shader_test \
......@@ -132,6 +133,7 @@ vkd3d_shader_tests = \
tests/hlsl-vector-indexing.shader_test \
tests/hlsl-vector-indexing-uniform.shader_test \
tests/lit.shader_test \
tests/load-level.shader_test \
tests/log.shader_test \
tests/logic-operations.shader_test \
tests/majority-syntax.shader_test \
......@@ -143,6 +145,7 @@ vkd3d_shader_tests = \
tests/nointerpolation.shader_test \
tests/object-field-offsets.shader_test \
tests/object-references.shader_test \
tests/object-parameters.shader_test \
tests/pow.shader_test \
tests/preproc-if.shader_test \
tests/preproc-ifdef.shader_test \
......@@ -154,6 +157,8 @@ vkd3d_shader_tests = \
tests/register-reservations.shader_test \
tests/return.shader_test \
tests/round.shader_test \
tests/sample-bias.shader_test \
tests/sample-level.shader_test \
tests/sampler.shader_test \
tests/sampler-offset.shader_test \
tests/saturate.shader_test \
......
......@@ -1323,19 +1323,15 @@ static void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffe
if (!var->semantic.name && var->regs[regset].allocated)
{
put_u32(buffer, 0); /* name */
if (var->data_type->class == HLSL_CLASS_OBJECT
&& (var->data_type->base_type == HLSL_TYPE_SAMPLER
|| var->data_type->base_type == HLSL_TYPE_TEXTURE))
if (regset == HLSL_REGSET_NUMERIC)
{
assert(regset == HLSL_REGSET_SAMPLERS);
put_u32(buffer, vkd3d_make_u32(D3DXRS_SAMPLER, var->regs[regset].id));
put_u32(buffer, 1);
put_u32(buffer, vkd3d_make_u32(D3DXRS_FLOAT4, var->regs[regset].id));
put_u32(buffer, var->data_type->reg_size[regset] / 4);
}
else
{
assert(regset == HLSL_REGSET_NUMERIC);
put_u32(buffer, vkd3d_make_u32(D3DXRS_FLOAT4, var->regs[regset].id));
put_u32(buffer, var->data_type->reg_size[regset] / 4);
put_u32(buffer, vkd3d_make_u32(D3DXRS_SAMPLER, var->regs[regset].id));
put_u32(buffer, var->regs[regset].bind_count);
}
put_u32(buffer, 0); /* type */
put_u32(buffer, 0); /* FIXME: default value */
......@@ -1618,6 +1614,81 @@ static void write_sm1_semantic_dcls(struct hlsl_ctx *ctx, struct vkd3d_bytecode_
}
}
static void write_sm1_sampler_dcl(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer,
unsigned int reg_id, enum hlsl_sampler_dim sampler_dim)
{
struct sm1_dst_register reg = {0};
uint32_t token, res_type = 0;
token = D3DSIO_DCL;
if (ctx->profile->major_version > 1)
token |= 2 << D3DSI_INSTLENGTH_SHIFT;
put_u32(buffer, token);
switch (sampler_dim)
{
case HLSL_SAMPLER_DIM_1D:
res_type = VKD3D_SM1_RESOURCE_TEXTURE_1D;
break;
case HLSL_SAMPLER_DIM_2D:
res_type = VKD3D_SM1_RESOURCE_TEXTURE_2D;
break;
case HLSL_SAMPLER_DIM_CUBE:
res_type = VKD3D_SM1_RESOURCE_TEXTURE_CUBE;
break;
case HLSL_SAMPLER_DIM_3D:
res_type = VKD3D_SM1_RESOURCE_TEXTURE_3D;
break;
default:
vkd3d_unreachable();
break;
}
token = (1u << 31);
token |= res_type << VKD3D_SM1_RESOURCE_TYPE_SHIFT;
put_u32(buffer, token);
reg.type = D3DSPR_SAMPLER;
reg.writemask = VKD3DSP_WRITEMASK_ALL;
reg.reg = reg_id;
write_sm1_dst_register(buffer, &reg);
}
static void write_sm1_sampler_dcls(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer)
{
enum hlsl_sampler_dim sampler_dim;
unsigned int i, count, reg_id;
struct hlsl_ir_var *var;
if (ctx->profile->major_version < 2)
return;
LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
{
if (!var->regs[HLSL_REGSET_SAMPLERS].allocated)
continue;
count = var->regs[HLSL_REGSET_SAMPLERS].bind_count;
for (i = 0; i < count; ++i)
{
if (var->objects_usage[HLSL_REGSET_SAMPLERS][i].used)
{
sampler_dim = var->objects_usage[HLSL_REGSET_SAMPLERS][i].sampler_dim;
assert(sampler_dim != HLSL_SAMPLER_DIM_GENERIC);
reg_id = var->regs[HLSL_REGSET_SAMPLERS].id + i;
write_sm1_sampler_dcl(ctx, buffer, reg_id, sampler_dim);
}
}
}
}
static void write_sm1_constant(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer,
const struct hlsl_ir_node *instr)
{
......@@ -1803,6 +1874,42 @@ static void write_sm1_load(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b
write_sm1_instruction(ctx, buffer, &sm1_instr);
}
static void write_sm1_resource_load(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer,
const struct hlsl_ir_node *instr)
{
const struct hlsl_ir_resource_load *load = hlsl_ir_resource_load(instr);
struct hlsl_ir_node *coords = load->coords.node;
unsigned int sampler_offset, reg_id;
struct sm1_instruction sm1_instr;
sampler_offset = hlsl_offset_from_deref_safe(ctx, &load->resource);
reg_id = load->resource.var->regs[HLSL_REGSET_SAMPLERS].id + sampler_offset;
sm1_instr = (struct sm1_instruction)
{
.opcode = D3DSIO_TEX,
.dst.type = D3DSPR_TEMP,
.dst.reg = instr->reg.id,
.dst.writemask = instr->reg.writemask,
.has_dst = 1,
.srcs[0].type = D3DSPR_TEMP,
.srcs[0].reg = coords->reg.id,
.srcs[0].swizzle = hlsl_swizzle_from_writemask(VKD3DSP_WRITEMASK_ALL),
.srcs[1].type = D3DSPR_SAMPLER,
.srcs[1].reg = reg_id,
.srcs[1].swizzle = hlsl_swizzle_from_writemask(VKD3DSP_WRITEMASK_ALL),
.src_count = 2,
};
assert(instr->reg.allocated);
write_sm1_instruction(ctx, buffer, &sm1_instr);
}
static void write_sm1_store(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer,
const struct hlsl_ir_node *instr)
{
......@@ -1922,6 +2029,10 @@ static void write_sm1_instructions(struct hlsl_ctx *ctx, struct vkd3d_bytecode_b
write_sm1_load(ctx, buffer, instr);
break;
case HLSL_IR_RESOURCE_LOAD:
write_sm1_resource_load(ctx, buffer, instr);
break;
case HLSL_IR_STORE:
write_sm1_store(ctx, buffer, instr);
break;
......@@ -1947,6 +2058,7 @@ int hlsl_sm1_write(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun
write_sm1_constant_defs(ctx, &buffer);
write_sm1_semantic_dcls(ctx, &buffer);
write_sm1_sampler_dcls(ctx, &buffer);
write_sm1_instructions(ctx, &buffer, entry_func);
put_u32(&buffer, D3DSIO_END);
......
......@@ -112,8 +112,12 @@ struct hlsl_ir_var *hlsl_get_var(struct hlsl_scope *scope, const char *name)
void hlsl_free_var(struct hlsl_ir_var *decl)
{
unsigned int k;
vkd3d_free((void *)decl->name);
hlsl_cleanup_semantic(&decl->semantic);
for (k = 0; k <= HLSL_REGSET_LAST_OBJECT; ++k)
vkd3d_free((void *)decl->objects_usage[k]);
vkd3d_free(decl);
}
......@@ -173,6 +177,9 @@ unsigned int hlsl_get_multiarray_size(const struct hlsl_type *type)
bool hlsl_type_is_resource(const struct hlsl_type *type)
{
if (type->class == HLSL_CLASS_ARRAY)
return hlsl_type_is_resource(type->e.array.type);
if (type->class == HLSL_CLASS_OBJECT)
{
switch (type->base_type)
......@@ -193,6 +200,9 @@ enum hlsl_regset hlsl_type_get_regset(const struct hlsl_type *type)
if (type->class <= HLSL_CLASS_LAST_NUMERIC)
return HLSL_REGSET_NUMERIC;
if (type->class == HLSL_CLASS_ARRAY)
return hlsl_type_get_regset(type->e.array.type);
if (type->class == HLSL_CLASS_OBJECT)
{
switch (type->base_type)
......@@ -210,8 +220,6 @@ enum hlsl_regset hlsl_type_get_regset(const struct hlsl_type *type)
vkd3d_unreachable();
}
}
else if (type->class == HLSL_CLASS_ARRAY)
return hlsl_type_get_regset(type->e.array.type);
vkd3d_unreachable();
}
......@@ -435,7 +443,7 @@ static bool init_deref(struct hlsl_ctx *ctx, struct hlsl_deref *deref, struct hl
return true;
}
if (!(deref->path = hlsl_alloc(ctx, sizeof(*deref->path) * deref->path_len)))
if (!(deref->path = hlsl_calloc(ctx, deref->path_len, sizeof(*deref->path))))
{
deref->var = NULL;
deref->path_len = 0;
......@@ -532,7 +540,7 @@ static bool init_deref_from_component_index(struct hlsl_ctx *ctx, struct hlsl_bl
{
unsigned int path_len, path_index, deref_path_len, i;
struct hlsl_type *path_type;
struct hlsl_ir_constant *c;
struct hlsl_ir_node *c;
hlsl_block_init(block);
......@@ -563,9 +571,9 @@ static bool init_deref_from_component_index(struct hlsl_ctx *ctx, struct hlsl_bl
hlsl_block_cleanup(block);
return false;
}
hlsl_block_add_instr(block, &c->node);
hlsl_block_add_instr(block, c);
hlsl_src_from_node(&deref->path[deref_path_len++], &c->node);
hlsl_src_from_node(&deref->path[deref_path_len++], c);
}
assert(deref_path_len == deref->path_len);
......@@ -874,7 +882,7 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old,
type->e.record.field_count = field_count;
if (!(type->e.record.fields = hlsl_alloc(ctx, field_count * sizeof(*type->e.record.fields))))
if (!(type->e.record.fields = hlsl_calloc(ctx, field_count, sizeof(*type->e.record.fields))))
{
vkd3d_free((void *)type->name);
vkd3d_free(type);
......@@ -945,6 +953,7 @@ struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct
const struct hlsl_reg_reservation *reg_reservation)
{
struct hlsl_ir_var *var;
unsigned int k;
if (!(var = hlsl_alloc(ctx, sizeof(*var))))
return NULL;
......@@ -957,6 +966,23 @@ struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct
var->storage_modifiers = modifiers;
if (reg_reservation)
var->reg_reservation = *reg_reservation;
for (k = 0; k <= HLSL_REGSET_LAST_OBJECT; ++k)
{
unsigned int i, obj_count = type->reg_size[k];
if (obj_count == 0)
continue;
if (!(var->objects_usage[k] = hlsl_calloc(ctx, obj_count, sizeof(*var->objects_usage[0]))))
{
for (i = 0; i < k; ++i)
vkd3d_free(var->objects_usage[i]);
vkd3d_free(var);
return NULL;
}
}
return var;
}
......@@ -1039,7 +1065,7 @@ static void init_node(struct hlsl_ir_node *node, enum hlsl_ir_node_type type,
list_init(&node->uses);
}
struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir_var *lhs, struct hlsl_ir_node *rhs)
struct hlsl_ir_node *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir_var *lhs, struct hlsl_ir_node *rhs)
{
struct hlsl_deref lhs_deref;
......@@ -1047,7 +1073,7 @@ struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir
return hlsl_new_store_index(ctx, &lhs_deref, NULL, rhs, 0, &rhs->loc);
}
struct hlsl_ir_store *hlsl_new_store_index(struct hlsl_ctx *ctx, const struct hlsl_deref *lhs,
struct hlsl_ir_node *hlsl_new_store_index(struct hlsl_ctx *ctx, const struct hlsl_deref *lhs,
struct hlsl_ir_node *idx, struct hlsl_ir_node *rhs, unsigned int writemask, const struct vkd3d_shader_location *loc)
{
struct hlsl_ir_store *store;
......@@ -1076,10 +1102,10 @@ struct hlsl_ir_store *hlsl_new_store_index(struct hlsl_ctx *ctx, const struct hl
writemask = (1 << rhs->data_type->dimx) - 1;
store->writemask = writemask;
return store;
return &store->node;
}
struct hlsl_ir_store *hlsl_new_store_component(struct hlsl_ctx *ctx, struct hlsl_block *block,
bool hlsl_new_store_component(struct hlsl_ctx *ctx, struct hlsl_block *block,
const struct hlsl_deref *lhs, unsigned int comp, struct hlsl_ir_node *rhs)
{
struct hlsl_block comp_path_block;
......@@ -1088,13 +1114,13 @@ struct hlsl_ir_store *hlsl_new_store_component(struct hlsl_ctx *ctx, struct hlsl
hlsl_block_init(block);
if (!(store = hlsl_alloc(ctx, sizeof(*store))))
return NULL;
return false;
init_node(&store->node, HLSL_IR_STORE, NULL, &rhs->loc);
if (!init_deref_from_component_index(ctx, &comp_path_block, &store->lhs, lhs, comp, &rhs->loc))
{
vkd3d_free(store);
return NULL;
return false;
}
hlsl_block_add_block(block, &comp_path_block);
hlsl_src_from_node(&store->rhs, rhs);
......@@ -1104,7 +1130,7 @@ struct hlsl_ir_store *hlsl_new_store_component(struct hlsl_ctx *ctx, struct hlsl
hlsl_block_add_instr(block, &store->node);
return store;
return true;
}
struct hlsl_ir_node *hlsl_new_call(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *decl,
......@@ -1168,7 +1194,7 @@ struct hlsl_ir_node *hlsl_new_int_constant(struct hlsl_ctx *ctx, int32_t n, cons
return &c->node;
}
struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
struct hlsl_ir_node *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
const struct vkd3d_shader_location *loc)
{
struct hlsl_ir_constant *c;
......@@ -1178,7 +1204,7 @@ struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned i
if (c)
c->value.u[0].u = n;
return c;
return &c->node;
}
struct hlsl_ir_node *hlsl_new_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op,
......@@ -1327,6 +1353,9 @@ struct hlsl_ir_node *hlsl_new_resource_load(struct hlsl_ctx *ctx,
hlsl_src_from_node(&load->coords, params->coords);
hlsl_src_from_node(&load->texel_offset, params->texel_offset);
hlsl_src_from_node(&load->lod, params->lod);
load->sampling_dim = params->sampling_dim;
if (load->sampling_dim == HLSL_SAMPLER_DIM_GENERIC)
load->sampling_dim = hlsl_deref_get_type(ctx, &load->resource)->sampler_dim;
return &load->node;
}
......@@ -1344,7 +1373,7 @@ struct hlsl_ir_node *hlsl_new_resource_store(struct hlsl_ctx *ctx, const struct
return &store->node;
}
struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned int components,
struct hlsl_ir_node *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned int components,
struct hlsl_ir_node *val, const struct vkd3d_shader_location *loc)
{
struct hlsl_ir_swizzle *swizzle;
......@@ -1359,7 +1388,7 @@ struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned
init_node(&swizzle->node, HLSL_IR_SWIZZLE, type, loc);
hlsl_src_from_node(&swizzle->val, val);
swizzle->swizzle = s;
return swizzle;
return &swizzle->node;
}
bool hlsl_index_is_noncontiguous(struct hlsl_ir_index *index)
......@@ -1615,6 +1644,7 @@ static struct hlsl_ir_node *clone_resource_load(struct hlsl_ctx *ctx,
clone_src(map, &dst->coords, &src->coords);
clone_src(map, &dst->lod, &src->lod);
clone_src(map, &dst->texel_offset, &src->texel_offset);
dst->sampling_dim = src->sampling_dim;
return &dst->node;
}
......@@ -1657,12 +1687,8 @@ static struct hlsl_ir_node *clone_store(struct hlsl_ctx *ctx, struct clone_instr
static struct hlsl_ir_node *clone_swizzle(struct hlsl_ctx *ctx,
struct clone_instr_map *map, struct hlsl_ir_swizzle *src)
{
struct hlsl_ir_swizzle *dst;
if (!(dst = hlsl_new_swizzle(ctx, src->swizzle, src->node.data_type->dimx,
map_instr(map, src->val.node), &src->node.loc)))
return NULL;
return &dst->node;
return hlsl_new_swizzle(ctx, src->swizzle, src->node.data_type->dimx,
map_instr(map, src->val.node), &src->node.loc);
}
static struct hlsl_ir_node *clone_index(struct hlsl_ctx *ctx, struct clone_instr_map *map,
......@@ -1735,9 +1761,8 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx,
struct hlsl_type *return_type, const struct hlsl_func_parameters *parameters,
const struct hlsl_semantic *semantic, const struct vkd3d_shader_location *loc)
{
struct hlsl_ir_node *constant, *store;
struct hlsl_ir_function_decl *decl;
struct hlsl_ir_node *constant;
struct hlsl_ir_store *store;
if (!(decl = hlsl_alloc(ctx, sizeof(*decl))))
return NULL;
......@@ -1766,7 +1791,7 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx,
if (!(store = hlsl_new_simple_store(ctx, decl->early_return_var, constant)))
return decl;
hlsl_block_add_instr(&decl->body, &store->node);
hlsl_block_add_instr(&decl->body, store);
return decl;
}
......
......@@ -240,16 +240,21 @@ struct hlsl_struct_field
size_t name_bytecode_offset;
};
/* Information of the register allocated for an instruction node or variable.
/* Information of the register(s) allocated for an instruction node or variable.
* These values are initialized at the end of hlsl_emit_bytecode(), after the compilation passes,
* just before writing the bytecode.
* For numeric registers, a writemask can be provided to indicate the reservation of only some of the
* 4 components.
* The type of register (register class) is implied from its use, so it is not stored in this
* struct. */
struct hlsl_reg
{
/* Index of the first register allocated. */
uint32_t id;
/* Number of registers to be allocated.
* Unlike the variable's type's regsize, it is not expressed in register components, but rather
* in whole registers, and may depend on which components are used within the shader. */
uint32_t bind_count;
/* For numeric registers, a writemask can be provided to indicate the reservation of only some
* of the 4 components. */
unsigned int writemask;
/* Whether the register has been allocated. */
bool allocated;
......@@ -401,6 +406,13 @@ struct hlsl_ir_var
* and the buffer_offset instead. */
struct hlsl_reg regs[HLSL_REGSET_LAST + 1];
struct
{
bool used;
enum hlsl_sampler_dim sampler_dim;
struct vkd3d_shader_location first_sampler_dim_loc;
} *objects_usage[HLSL_REGSET_LAST_OBJECT + 1];
uint32_t is_input_semantic : 1;
uint32_t is_output_semantic : 1;
uint32_t is_uniform : 1;
......@@ -612,6 +624,7 @@ struct hlsl_ir_resource_load
enum hlsl_resource_load_type load_type;
struct hlsl_deref resource, sampler;
struct hlsl_src coords, lod, texel_offset;
enum hlsl_sampler_dim sampling_dim;
};
struct hlsl_ir_resource_store
......@@ -813,6 +826,7 @@ struct hlsl_resource_load_params
enum hlsl_resource_load_type type;
struct hlsl_ir_node *resource, *sampler;
struct hlsl_ir_node *coords, *lod, *texel_offset;
enum hlsl_sampler_dim sampling_dim;
};
static inline struct hlsl_ir_call *hlsl_ir_call(const struct hlsl_ir_node *node)
......@@ -925,6 +939,15 @@ static inline void *hlsl_alloc(struct hlsl_ctx *ctx, size_t size)
return ptr;
}
static inline void *hlsl_calloc(struct hlsl_ctx *ctx, size_t count, size_t size)
{
void *ptr = vkd3d_calloc(count, size);
if (!ptr)
ctx->result = VKD3D_ERROR_OUT_OF_MEMORY;
return ptr;
}
static inline void *hlsl_realloc(struct hlsl_ctx *ctx, void *ptr, size_t size)
{
void *ret = vkd3d_realloc(ptr, size);
......@@ -1026,7 +1049,7 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru
struct vkd3d_string_buffer *hlsl_modifiers_to_string(struct hlsl_ctx *ctx, unsigned int modifiers);
const char *hlsl_node_type_to_string(enum hlsl_ir_node_type type);
struct hlsl_ir_load *hlsl_add_conditional(struct hlsl_ctx *ctx, struct list *instrs,
struct hlsl_ir_node *hlsl_add_conditional(struct hlsl_ctx *ctx, struct list *instrs,
struct hlsl_ir_node *condition, struct hlsl_ir_node *if_true, struct hlsl_ir_node *if_false);
void hlsl_add_function(struct hlsl_ctx *ctx, char *name, struct hlsl_ir_function_decl *decl);
bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local_var);
......@@ -1099,10 +1122,10 @@ struct hlsl_ir_load *hlsl_new_load_index(struct hlsl_ctx *ctx, const struct hlsl
struct hlsl_ir_node *hlsl_new_load_component(struct hlsl_ctx *ctx, struct hlsl_block *block,
const struct hlsl_deref *deref, unsigned int comp, const struct vkd3d_shader_location *loc);
struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir_var *lhs, struct hlsl_ir_node *rhs);
struct hlsl_ir_store *hlsl_new_store_index(struct hlsl_ctx *ctx, const struct hlsl_deref *lhs,
struct hlsl_ir_node *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir_var *lhs, struct hlsl_ir_node *rhs);
struct hlsl_ir_node *hlsl_new_store_index(struct hlsl_ctx *ctx, const struct hlsl_deref *lhs,
struct hlsl_ir_node *idx, struct hlsl_ir_node *rhs, unsigned int writemask, const struct vkd3d_shader_location *loc);
struct hlsl_ir_store *hlsl_new_store_component(struct hlsl_ctx *ctx, struct hlsl_block *block,
bool hlsl_new_store_component(struct hlsl_ctx *ctx, struct hlsl_block *block,
const struct hlsl_deref *lhs, unsigned int comp, struct hlsl_ir_node *rhs);
bool hlsl_index_is_noncontiguous(struct hlsl_ir_index *index);
......@@ -1118,14 +1141,14 @@ struct hlsl_ir_node *hlsl_new_resource_store(struct hlsl_ctx *ctx, const struct
struct hlsl_ir_node *coords, struct hlsl_ir_node *value, const struct vkd3d_shader_location *loc);
struct hlsl_type *hlsl_new_struct_type(struct hlsl_ctx *ctx, const char *name,
struct hlsl_struct_field *fields, size_t field_count);
struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned int components,
struct hlsl_ir_node *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned int components,
struct hlsl_ir_node *val, const struct vkd3d_shader_location *loc);
struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *template,
struct hlsl_type *type, const struct vkd3d_shader_location *loc);
struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, struct hlsl_type *format,
unsigned int sample_count);
struct hlsl_type *hlsl_new_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, struct hlsl_type *format);
struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
struct hlsl_ir_node *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
const struct vkd3d_shader_location *loc);
struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg,
const struct vkd3d_shader_location *loc);
......@@ -1173,6 +1196,8 @@ unsigned int hlsl_swizzle_from_writemask(unsigned int writemask);
struct hlsl_type *hlsl_deref_get_type(struct hlsl_ctx *ctx, const struct hlsl_deref *deref);
bool hlsl_component_index_range_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref,
unsigned int *start, unsigned int *count);
bool hlsl_regset_index_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref,
enum hlsl_regset regset, unsigned int *index);
bool hlsl_offset_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref, unsigned int *offset);
unsigned int hlsl_offset_from_deref_safe(struct hlsl_ctx *ctx, const struct hlsl_deref *deref);
struct hlsl_reg hlsl_reg_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref);
......
......@@ -37,6 +37,7 @@ static void update_location(struct hlsl_ctx *ctx, YYLTYPE *loc);
%option bison-locations
%option extra-type="struct hlsl_ctx *"
%option never-interactive
%option nodefault
%option noinput
%option nounput
%option noyywrap
......@@ -266,6 +267,10 @@ row_major {return KW_ROW_MAJOR; }
return STRING;
}
<pp_line>{WS}+ {}
<pp_line>{ANY} {
FIXME("Malformed preprocessor line directive?\n");
BEGIN(INITIAL);
}
<pp_line>{NEWLINE} {
FIXME("Malformed preprocessor line directive?\n");
BEGIN(INITIAL);
......
This diff is collapsed.
This diff is collapsed.
......@@ -40,6 +40,7 @@ static void update_location(struct preproc_ctx *ctx);
%option bison-locations
%option extra-type="struct preproc_ctx *"
%option never-interactive
%option nodefault
%option noinput
%option nounput
%option noyy_top_state
......@@ -74,6 +75,7 @@ INT_SUFFIX [uUlL]{0,2}
<C_COMMENT>"*/" {yy_pop_state(yyscanner);}
<C_COMMENT,CXX_COMMENT><<EOF>> {yy_pop_state(yyscanner);}
<C_COMMENT,CXX_COMMENT>. {}
<C_COMMENT>\n {}
<ERROR>(\\{NEWLINE}|[^\n])* {return T_STRING;}
......@@ -175,9 +177,9 @@ INT_SUFFIX [uUlL]{0,2}
return T_NEWLINE;
}
<INITIAL>{WS}+ {}
<INITIAL,INCLUDE,LINE>{WS}+ {}
<INITIAL>[-()\[\]{},+!*/<>&|^?:] {return yytext[0];}
<INITIAL>. {return T_TEXT;}
<INITIAL,INCLUDE,LINE>. {return T_TEXT;}
%%
......
......@@ -2595,6 +2595,9 @@ static void write_sm4_type(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b
static D3D_SHADER_INPUT_TYPE sm4_resource_type(const struct hlsl_type *type)
{
if (type->class == HLSL_CLASS_ARRAY)
return sm4_resource_type(type->e.array.type);
switch (type->base_type)
{
case HLSL_TYPE_SAMPLER:
......@@ -2610,6 +2613,9 @@ static D3D_SHADER_INPUT_TYPE sm4_resource_type(const struct hlsl_type *type)
static D3D_RESOURCE_RETURN_TYPE sm4_resource_format(const struct hlsl_type *type)
{
if (type->class == HLSL_CLASS_ARRAY)
return sm4_resource_format(type->e.array.type);
switch (type->e.resource_format->base_type)
{
case HLSL_TYPE_DOUBLE:
......@@ -2634,6 +2640,9 @@ static D3D_RESOURCE_RETURN_TYPE sm4_resource_format(const struct hlsl_type *type
static D3D_SRV_DIMENSION sm4_rdef_resource_dimension(const struct hlsl_type *type)
{
if (type->class == HLSL_CLASS_ARRAY)
return sm4_rdef_resource_dimension(type->e.array.type);
switch (type->sampler_dim)
{
case HLSL_SAMPLER_DIM_1D:
......@@ -2786,13 +2795,15 @@ static void write_sm4_rdef(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc)
}
else
{
unsigned int dimx = hlsl_type_get_component_type(ctx, var->data_type, 0)->e.resource_format->dimx;
put_u32(&buffer, sm4_resource_format(var->data_type));
put_u32(&buffer, sm4_rdef_resource_dimension(var->data_type));
put_u32(&buffer, ~0u); /* FIXME: multisample count */
flags |= (var->data_type->e.resource_format->dimx - 1) << VKD3D_SM4_SIF_TEXTURE_COMPONENTS_SHIFT;
flags |= (dimx - 1) << VKD3D_SM4_SIF_TEXTURE_COMPONENTS_SHIFT;
}
put_u32(&buffer, var->regs[regset].id);
put_u32(&buffer, 1); /* bind count */
put_u32(&buffer, var->regs[regset].bind_count);
put_u32(&buffer, flags);
}
......@@ -3037,33 +3048,41 @@ static void sm4_register_from_deref(struct hlsl_ctx *ctx, struct sm4_register *r
if (var->is_uniform)
{
if (data_type->class == HLSL_CLASS_OBJECT && data_type->base_type == HLSL_TYPE_TEXTURE)
enum hlsl_regset regset = hlsl_type_get_regset(data_type);
if (regset == HLSL_REGSET_TEXTURES)
{
reg->type = VKD3D_SM4_RT_RESOURCE;
reg->dim = VKD3D_SM4_DIMENSION_VEC4;
if (swizzle_type)
*swizzle_type = VKD3D_SM4_SWIZZLE_VEC4;
reg->idx[0] = var->regs[HLSL_REGSET_TEXTURES].id;
reg->idx[0] += hlsl_offset_from_deref_safe(ctx, deref);
assert(deref->offset_regset == HLSL_REGSET_TEXTURES);
reg->idx_count = 1;
*writemask = VKD3DSP_WRITEMASK_ALL;
}
else if (data_type->class == HLSL_CLASS_OBJECT && data_type->base_type == HLSL_TYPE_UAV)
else if (regset == HLSL_REGSET_UAVS)
{
reg->type = VKD3D_SM5_RT_UAV;
reg->dim = VKD3D_SM4_DIMENSION_VEC4;
if (swizzle_type)
*swizzle_type = VKD3D_SM4_SWIZZLE_VEC4;
reg->idx[0] = var->regs[HLSL_REGSET_UAVS].id;
reg->idx[0] += hlsl_offset_from_deref_safe(ctx, deref);
assert(deref->offset_regset == HLSL_REGSET_UAVS);
reg->idx_count = 1;
*writemask = VKD3DSP_WRITEMASK_ALL;
}
else if (data_type->class == HLSL_CLASS_OBJECT && data_type->base_type == HLSL_TYPE_SAMPLER)
else if (regset == HLSL_REGSET_SAMPLERS)
{
reg->type = VKD3D_SM4_RT_SAMPLER;
reg->dim = VKD3D_SM4_DIMENSION_NONE;
if (swizzle_type)
*swizzle_type = VKD3D_SM4_SWIZZLE_NONE;
reg->idx[0] = var->regs[HLSL_REGSET_SAMPLERS].id;
reg->idx[0] += hlsl_offset_from_deref_safe(ctx, deref);
assert(deref->offset_regset == HLSL_REGSET_SAMPLERS);
reg->idx_count = 1;
*writemask = VKD3DSP_WRITEMASK_ALL;
}
......@@ -3349,44 +3368,67 @@ static void write_sm4_dcl_constant_buffer(struct vkd3d_bytecode_buffer *buffer,
write_sm4_instruction(buffer, &instr);
}
static void write_sm4_dcl_sampler(struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_var *var)
static void write_sm4_dcl_samplers(struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_var *var)
{
const struct sm4_instruction instr =
unsigned int i, count = var->data_type->reg_size[HLSL_REGSET_SAMPLERS];
struct sm4_instruction instr;
for (i = 0; i < count; ++i)
{
.opcode = VKD3D_SM4_OP_DCL_SAMPLER,
if (!var->objects_usage[HLSL_REGSET_SAMPLERS][i].used)
continue;
.dsts[0].reg.type = VKD3D_SM4_RT_SAMPLER,
.dsts[0].reg.idx = {var->regs[HLSL_REGSET_SAMPLERS].id},
.dsts[0].reg.idx_count = 1,
.dst_count = 1,
};
write_sm4_instruction(buffer, &instr);
instr = (struct sm4_instruction)
{
.opcode = VKD3D_SM4_OP_DCL_SAMPLER,
.dsts[0].reg.type = VKD3D_SM4_RT_SAMPLER,
.dsts[0].reg.idx = {var->regs[HLSL_REGSET_SAMPLERS].id + i},
.dsts[0].reg.idx_count = 1,
.dst_count = 1,
};
write_sm4_instruction(buffer, &instr);
}
}
static void write_sm4_dcl_texture(struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_var *var)
static void write_sm4_dcl_textures(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer,
const struct hlsl_ir_var *var, bool uav)
{
bool uav = (var->data_type->base_type == HLSL_TYPE_UAV);
struct sm4_instruction instr =
enum hlsl_regset regset = uav ? HLSL_REGSET_UAVS : HLSL_REGSET_TEXTURES;
unsigned int i, count = var->data_type->reg_size[regset];
struct hlsl_type *component_type;
struct sm4_instruction instr;
component_type = hlsl_type_get_component_type(ctx, var->data_type, 0);
for (i = 0; i < count; ++i)
{
.opcode = (uav ? VKD3D_SM5_OP_DCL_UAV_TYPED : VKD3D_SM4_OP_DCL_RESOURCE)
| (sm4_resource_dimension(var->data_type) << VKD3D_SM4_RESOURCE_TYPE_SHIFT),
if (!var->objects_usage[regset][i].used)
continue;
.dsts[0].reg.type = uav ? VKD3D_SM5_RT_UAV : VKD3D_SM4_RT_RESOURCE,
.dsts[0].reg.idx = {uav ? var->regs[HLSL_REGSET_UAVS].id : var->regs[HLSL_REGSET_TEXTURES].id},
.dsts[0].reg.idx_count = 1,
.dst_count = 1,
instr = (struct sm4_instruction)
{
.opcode = (uav ? VKD3D_SM5_OP_DCL_UAV_TYPED : VKD3D_SM4_OP_DCL_RESOURCE)
| (sm4_resource_dimension(component_type) << VKD3D_SM4_RESOURCE_TYPE_SHIFT),
.idx[0] = sm4_resource_format(var->data_type) * 0x1111,
.idx_count = 1,
};
.dsts[0].reg.type = uav ? VKD3D_SM5_RT_UAV : VKD3D_SM4_RT_RESOURCE,
.dsts[0].reg.idx = {var->regs[regset].id + i},
.dsts[0].reg.idx_count = 1,
.dst_count = 1,
if (var->data_type->sampler_dim == HLSL_SAMPLER_DIM_2DMS
|| var->data_type->sampler_dim == HLSL_SAMPLER_DIM_2DMSARRAY)
{
instr.opcode |= var->data_type->sample_count << VKD3D_SM4_RESOURCE_SAMPLE_COUNT_SHIFT;
}
.idx[0] = sm4_resource_format(component_type) * 0x1111,
.idx_count = 1,
};
write_sm4_instruction(buffer, &instr);
if (component_type->sampler_dim == HLSL_SAMPLER_DIM_2DMS
|| component_type->sampler_dim == HLSL_SAMPLER_DIM_2DMSARRAY)
{
instr.opcode |= component_type->sample_count << VKD3D_SM4_RESOURCE_SAMPLE_COUNT_SHIFT;
}
write_sm4_instruction(buffer, &instr);
}
}
static void write_sm4_dcl_semantic(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_var *var)
......@@ -3648,9 +3690,9 @@ static void write_sm4_constant(struct hlsl_ctx *ctx,
static void write_sm4_ld(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer,
const struct hlsl_type *resource_type, const struct hlsl_ir_node *dst,
const struct hlsl_deref *resource, const struct hlsl_ir_node *coords,
const struct hlsl_ir_node *texel_offset)
const struct hlsl_ir_node *texel_offset, enum hlsl_sampler_dim dim)
{
bool uav = (resource_type->base_type == HLSL_TYPE_UAV);
bool uav = (hlsl_type_get_regset(resource_type) == HLSL_REGSET_UAVS);
struct sm4_instruction instr;
unsigned int dim_count;
......@@ -3676,7 +3718,7 @@ static void write_sm4_ld(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buf
{
/* Mipmap level is in the last component in the IR, but needs to be in the W
* component in the instruction. */
dim_count = hlsl_sampler_dim_count(resource_type->sampler_dim);
dim_count = hlsl_sampler_dim_count(dim);
if (dim_count == 1)
instr.srcs[0].swizzle = hlsl_combine_swizzles(instr.srcs[0].swizzle, HLSL_SWIZZLE(X, X, X, Y), 4);
if (dim_count == 2)
......@@ -4499,10 +4541,9 @@ static void write_sm4_resource_load(struct hlsl_ctx *ctx,
const struct hlsl_ir_node *texel_offset = load->texel_offset.node;
const struct hlsl_ir_node *coords = load->coords.node;
if (resource_type->class != HLSL_CLASS_OBJECT)
if (!hlsl_type_is_resource(resource_type))
{
assert(resource_type->class == HLSL_CLASS_ARRAY || resource_type->class == HLSL_CLASS_STRUCT);
hlsl_fixme(ctx, &load->node.loc, "Resource being a component of another variable.");
hlsl_fixme(ctx, &load->node.loc, "Separate object fields as new variables.");
return;
}
......@@ -4510,14 +4551,11 @@ static void write_sm4_resource_load(struct hlsl_ctx *ctx,
{
const struct hlsl_type *sampler_type = load->sampler.var->data_type;
if (sampler_type->class != HLSL_CLASS_OBJECT)
if (!hlsl_type_is_resource(sampler_type))
{
assert(sampler_type->class == HLSL_CLASS_ARRAY || sampler_type->class == HLSL_CLASS_STRUCT);
hlsl_fixme(ctx, &load->node.loc, "Sampler being a component of another variable.");
hlsl_fixme(ctx, &load->node.loc, "Separate object fields as new variables.");
return;
}
assert(sampler_type->base_type == HLSL_TYPE_SAMPLER);
assert(sampler_type->sampler_dim == HLSL_SAMPLER_DIM_GENERIC);
if (!load->sampler.var->is_uniform)
{
......@@ -4536,7 +4574,7 @@ static void write_sm4_resource_load(struct hlsl_ctx *ctx,
{
case HLSL_RESOURCE_LOAD:
write_sm4_ld(ctx, buffer, resource_type, &load->node, &load->resource,
coords, texel_offset);
coords, texel_offset, load->sampling_dim);
break;
case HLSL_RESOURCE_SAMPLE:
......@@ -4580,10 +4618,9 @@ static void write_sm4_resource_store(struct hlsl_ctx *ctx,
{
const struct hlsl_type *resource_type = store->resource.var->data_type;
if (resource_type->class != HLSL_CLASS_OBJECT)
if (!hlsl_type_is_resource(resource_type))
{
assert(resource_type->class == HLSL_CLASS_ARRAY || resource_type->class == HLSL_CLASS_STRUCT);
hlsl_fixme(ctx, &store->node.loc, "Resource being a component of another variable.");
hlsl_fixme(ctx, &store->node.loc, "Separate object fields as new variables.");
return;
}
......@@ -4747,12 +4784,17 @@ static void write_sm4_shdr(struct hlsl_ctx *ctx,
for (i = 0; i < extern_resources_count; ++i)
{
enum hlsl_regset regset;
var = extern_resources[i];
regset = hlsl_type_get_regset(var->data_type);
if (var->data_type->base_type == HLSL_TYPE_SAMPLER)
write_sm4_dcl_sampler(&buffer, var);
else if (var->data_type->base_type == HLSL_TYPE_TEXTURE || var->data_type->base_type == HLSL_TYPE_UAV)
write_sm4_dcl_texture(&buffer, var);
if (regset == HLSL_REGSET_SAMPLERS)
write_sm4_dcl_samplers(&buffer, var);
else if (regset == HLSL_REGSET_TEXTURES)
write_sm4_dcl_textures(ctx, &buffer, var, false);
else if (regset == HLSL_REGSET_UAVS)
write_sm4_dcl_textures(ctx, &buffer, var, true);
}
LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
......
......@@ -125,6 +125,7 @@ enum vkd3d_shader_error
VKD3D_SHADER_ERROR_HLSL_INVALID_THREAD_COUNT = 5023,
VKD3D_SHADER_ERROR_HLSL_MISSING_ATTRIBUTE = 5024,
VKD3D_SHADER_ERROR_HLSL_RECURSIVE_CALL = 5025,
VKD3D_SHADER_ERROR_HLSL_INCONSISTENT_SAMPLER = 5026,
VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION = 5300,
VKD3D_SHADER_WARNING_HLSL_DIVISION_BY_ZERO = 5301,
......
......@@ -1437,7 +1437,7 @@ static VkDescriptorPool d3d12_command_allocator_allocate_descriptor_pool(
pool_desc.pNext = NULL;
pool_desc.flags = 0;
pool_desc.maxSets = 512;
pool_desc.poolSizeCount = ARRAY_SIZE(device->vk_pool_sizes);
pool_desc.poolSizeCount = device->vk_pool_count;
pool_desc.pPoolSizes = device->vk_pool_sizes;
if ((vr = VK_CALL(vkCreateDescriptorPool(vk_device, &pool_desc, NULL, &vk_pool))) < 0)
{
......
......@@ -19,6 +19,8 @@
#include "vkd3d_private.h"
#include "vkd3d_version.h"
#define VKD3D_MAX_UAV_CLEAR_DESCRIPTORS_PER_TYPE 256u
struct vkd3d_struct
{
enum vkd3d_structure_type type;
......@@ -2393,9 +2395,23 @@ static void vkd3d_time_domains_init(struct d3d12_device *device)
WARN("Found no acceptable host time domain. Calibrated timestamps will not be available.\n");
}
static void vkd3d_init_descriptor_pool_sizes(VkDescriptorPoolSize *pool_sizes,
const struct vkd3d_device_descriptor_limits *limits)
static void device_init_descriptor_pool_sizes(struct d3d12_device *device)
{
const struct vkd3d_device_descriptor_limits *limits = &device->vk_info.descriptor_limits;
VkDescriptorPoolSize *pool_sizes = device->vk_pool_sizes;
if (device->use_vk_heaps)
{
pool_sizes[0].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
pool_sizes[0].descriptorCount = min(limits->storage_image_max_descriptors,
VKD3D_MAX_UAV_CLEAR_DESCRIPTORS_PER_TYPE);
pool_sizes[1].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
pool_sizes[1].descriptorCount = pool_sizes[0].descriptorCount;
device->vk_pool_count = 2;
return;
}
assert(ARRAY_SIZE(device->vk_pool_sizes) >= 6);
pool_sizes[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
pool_sizes[0].descriptorCount = min(limits->uniform_buffer_max_descriptors,
VKD3D_MAX_VIRTUAL_HEAP_DESCRIPTORS_PER_TYPE);
......@@ -2412,6 +2428,7 @@ static void vkd3d_init_descriptor_pool_sizes(VkDescriptorPoolSize *pool_sizes,
pool_sizes[5].type = VK_DESCRIPTOR_TYPE_SAMPLER;
pool_sizes[5].descriptorCount = min(limits->sampler_max_descriptors,
VKD3D_MAX_VIRTUAL_HEAP_DESCRIPTORS_PER_TYPE);
device->vk_pool_count = 6;
};
static void vkd3d_desc_object_cache_init(struct vkd3d_desc_object_cache *cache, size_t size)
......@@ -4000,7 +4017,7 @@ static HRESULT d3d12_device_init(struct d3d12_device *device,
vkd3d_desc_object_cache_init(&device->view_desc_cache, sizeof(struct vkd3d_view));
vkd3d_desc_object_cache_init(&device->cbuffer_desc_cache, sizeof(struct vkd3d_cbuffer_desc));
vkd3d_init_descriptor_pool_sizes(device->vk_pool_sizes, &device->vk_info.descriptor_limits);
device_init_descriptor_pool_sizes(device);
if ((device->parent = create_info->parent))
IUnknown_AddRef(device->parent);
......
......@@ -1666,6 +1666,7 @@ struct d3d12_device
struct vkd3d_uav_clear_state uav_clear_state;
VkDescriptorPoolSize vk_pool_sizes[VKD3D_DESCRIPTOR_POOL_COUNT];
unsigned int vk_pool_count;
struct vkd3d_vk_descriptor_heap_layout vk_descriptor_heap_layouts[VKD3D_SET_INDEX_COUNT];
bool use_vk_heaps;
};
......
[pixel shader]
float4 main(uniform float4 u) : sv_target
{
return float4(fmod(u.x, u.y), 0, 0, 0);
}
[test]
uniform 0 float4 -0.5 6.5 0.0 0.0
draw quad
probe all rgba (-0.5, 0.0, 0.0, 0.0) 4
uniform 0 float4 1.1 0.3 0.0 0.0
draw quad
probe all rgba (0.2, 0.0, 0.0, 0.0) 4
[require]
shader model >= 4.0
[texture 0]
size (2, 2)
levels 2
1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0
1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0
0.0 0.0 1.0 0.0
[pixel shader]
sampler s;
Texture2D t;
uniform uint level;
float4 main() : sv_target
{
return t.Load(uint3(0, 0, level));
}
[test]
uniform 0 uint 0
draw quad
probe all rgba (1.0, 0.0, 1.0, 0.0)
uniform 0 uint 1
draw quad
probe all rgba (0.0, 0.0, 1.0, 0.0)
[pixel shader fail]
sampler s;
Texture2D t;
float4 main() : sv_target
{
return t[uint3(0, 0, 0)];
}
[pixel shader]
sampler s;
Texture2D t;
float4 main() : sv_target
{
return t[uint2(0, 0)];
}
[test]
draw quad
probe all rgba (1.0, 0.0, 1.0, 0.0)
[pixel shader fail todo]
Texture2D tex0;
float4 main(out Texture2D tex : TEXTURE) : sv_target
{
return float4(1, 2, 3, 4);
}
[pixel shader fail todo]
struct params
{
Texture2D tex : TEXTURE;
};
float4 main(inout params x) : sv_target
{
return float4(1, 2, 3, 4);
}
[require]
shader model >= 5.0
[pixel shader todo]
uniform float global;
struct apple
{
Texture2D tex;
float4 pos : sv_position;
};
float4 main(struct apple input, uniform float param) : sv_target
{
return input.tex.Load(int3(0, 0, 0)) + global + param + input.pos;
}
[texture 0]
size (2, 2)
1.0 1.0 1.0 1.0 0.0 0.0 0.0 1.0
1.0 1.0 1.0 1.0 0.0 0.0 0.0 1.0
[texture 1]
size (2, 2)
2.0 2.0 2.0 1.0 0.0 0.0 0.0 1.0
2.0 2.0 2.0 1.0 0.0 0.0 0.0 1.0
[texture 2]
size (2, 2)
3.0 3.0 3.0 1.0 0.0 0.0 0.0 1.0
3.0 3.0 3.0 1.0 0.0 0.0 0.0 1.0
[texture 3]
size (2, 2)
4.0 4.0 4.0 1.0 0.0 0.0 0.0 1.0
4.0 4.0 4.0 1.0 0.0 0.0 0.0 1.0
[texture 4]
size (2, 2)
5.0 5.0 5.0 1.0 0.0 0.0 0.0 1.0
5.0 5.0 5.0 1.0 0.0 0.0 0.0 1.0
[texture 5]
size (2, 2)
6.0 6.0 6.0 1.0 0.0 0.0 0.0 1.0
6.0 6.0 6.0 1.0 0.0 0.0 0.0 1.0
[sampler 0]
filter linear linear linear
address clamp clamp clamp
[sampler 1]
filter linear linear linear
address clamp clamp clamp
[sampler 2]
filter linear linear linear
address clamp clamp clamp
[sampler 3]
filter point point point
address clamp clamp clamp
[sampler 4]
filter linear linear linear
address clamp clamp clamp
[pixel shader todo]
struct apple
{
Texture2D unused; // must reserve t1
Texture2D tex[3]; // must reserve t2-t4
Texture2D lone; // must reserve t5
float4 pos : sv_position;
};
Texture2D tex0; // must reserve t0
sampler sam;
float4 main(struct apple input) : sv_target
{
return 100 * input.tex[1].Sample(sam, float2(0, 0))
+ 10 * tex0.Sample(sam, float2(0, 0))
+ input.lone.Sample(sam, float2(0, 0));
}
[test]
todo draw quad
todo probe all rgba (416.0, 416.0, 416.0, 111.0)
[pixel shader todo]
Texture2D tex;
struct apple
{
sampler unused0; // must reserve s0
sampler sam[3]; // must reserve to s1-s2
sampler unused1; // doesn't reserve
};
float4 main(struct apple input, sampler samp) : sv_target
{
// samp must reserve s3
return float4(tex.Sample(samp, float2(0.3, 0.3)).xy,
tex.Sample(input.sam[1], float2(0.5, 0.5)).xy);
}
[test]
todo draw quad
todo probe all rgba (1.0, 1.0, 0.5, 0.5)
[sampler 0]
filter linear linear linear
address clamp clamp clamp
[sampler 1]
filter linear linear linear
address clamp clamp clamp
[sampler 2]
filter linear linear linear
address clamp clamp clamp
[sampler 3]
filter linear linear linear
address clamp clamp clamp
[sampler 4]
filter point point point
address clamp clamp clamp
[pixel shader todo]
Texture2D tex;
sampler sam0; // must reserve s3
struct apple
{
sampler unused0; // must reserve s0
sampler sam[3]; // must reserve s1-s2
sampler unused1; // doesn't reserve
};
float4 main(struct apple input, sampler samp) : sv_target
{
// samp must reserve s4
return float4(tex.Sample(sam0, float2(0.5, 0.5)).x, tex.Sample(samp, float2(0.3, 0.3)).x,
tex.Sample(input.sam[1], float2(0.5, 0.5)).xw);
}
[test]
todo draw quad
todo probe all rgba (0.5, 1.0, 0.5, 1.0)
......@@ -92,7 +92,7 @@ size (1, 1)
size (1, 1)
3.0 3.0 3.0 1.0
[pixel shader todo]
[pixel shader]
Texture2D tex[3];
struct foo {
......@@ -111,8 +111,8 @@ float4 main() : sv_target
}
[test]
todo draw quad
todo probe all rgba (312, 312, 312, 111)
draw quad
probe all rgba (312, 312, 312, 111)
[pixel shader]
......
......@@ -23,6 +23,38 @@ size (1, 1)
4.0 4.0 4.0 99.0
% If a single component in a texture array is used, all registers are reserved.
[pixel shader]
Texture2D partially_used[2][2];
Texture2D tex;
float4 main() : sv_target
{
return 10 * tex.Load(int3(0, 0, 0)) + partially_used[0][1].Load(int3(0, 0, 0));
}
[test]
draw quad
probe all rgba (41.0, 41.0, 41.0, 1089.0)
% If no component in a texture array is used, and it doesn't have a register reservation, no
% register is reserved.
[pixel shader]
Texture2D unused[4];
Texture2D tex;
float4 main() : sv_target
{
return tex.Load(int3(0, 0, 0));
}
[test]
draw quad
probe all rgba (0.0, 0.0, 0.0, 99.0)
% Register reservations force to reserve all the resource registers. Even if unused.
[pixel shader]
Texture2D unused : register(t0);
Texture2D tex;
......@@ -48,4 +80,4 @@ float4 main() : sv_target
[test]
draw quad
todo probe all rgba (4.0, 4.0, 4.0, 99.0)
probe all rgba (4.0, 4.0, 4.0, 99.0)
[sampler 0]
filter linear linear linear
address clamp clamp clamp
[texture 0]
size (2, 2)
levels 2
1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0
1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0
0.0 0.0 1.0 0.0
[vertex shader]
void main(out float2 tex : texcoord, inout float4 pos : sv_position)
{
tex = pos.xy;
}
[pixel shader]
sampler s;
Texture2D t;
uniform float bias;
float4 main(float2 coord : texcoord) : sv_target
{
/* Choice of initial mipmap level is hardware-dependent, and in practice
* varies too much to be reasonably covered by ULPS. Quantize instead. */
return floor(t.SampleBias(s, coord, bias) * 10);
}
[test]
uniform 0 float4 6.5 0.0 0.0 0.0
draw quad
probe all rgba (10.0, 0.0, 10.0, 0.0)
uniform 0 float4 7.5 0.0 0.0 0.0
draw quad
probe all rgba (4.0, 0.0, 10.0, 0.0)
uniform 0 float4 8.5 0.0 0.0 0.0
draw quad
probe all rgba (0.0, 0.0, 10.0, 0.0)
[require]
shader model >= 3.0
[sampler 0]
filter linear linear linear
address clamp clamp clamp
[texture 0]
size (2, 2)
levels 2
1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0
1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0
0.0 0.0 1.0 0.0
[pixel shader todo]
sampler s;
Texture2D t;
uniform float level;
float4 main() : sv_target
{
return t.SampleLevel(s, float2(0.5, 0.5), level);
}
[test]
uniform 0 float4 0.0 0.0 0.0 0.0
todo draw quad
probe all rgba (1.0, 0.0, 1.0, 0.0)
uniform 0 float4 0.5 0.0 0.0 0.0
todo draw quad
probe all rgba (0.5, 0.0, 1.0, 0.0)
uniform 0 float4 1.0 0.0 0.0 0.0
todo draw quad
probe all rgba (0.0, 0.0, 1.0, 0.0)