ReactOS 0.4.17-dev-934-g091855f
hlsl.h File Reference
#include "vkd3d_shader_private.h"
#include "wine/rbtree.h"
#include "d3dcommon.h"
#include "d3dx9shader.h"
Include dependency graph for hlsl.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  hlsl_type
 
struct  hlsl_semantic
 
struct  hlsl_struct_field
 
struct  hlsl_reg
 
struct  hlsl_ir_node
 
struct  hlsl_block
 
struct  hlsl_src
 
struct  hlsl_attribute
 
struct  hlsl_reg_reservation
 
union  hlsl_constant_value_component
 
struct  hlsl_ir_var
 
struct  hlsl_ir_var::hlsl_default_value
 
struct  hlsl_state_block_entry
 
struct  hlsl_state_block
 
struct  hlsl_func_parameters
 
struct  hlsl_ir_function
 
struct  hlsl_ir_function_decl
 
struct  hlsl_ir_call
 
struct  hlsl_ir_if
 
struct  hlsl_ir_loop
 
struct  hlsl_ir_switch_case
 
struct  hlsl_ir_switch
 
struct  hlsl_ir_expr
 
struct  hlsl_ir_jump
 
struct  hlsl_ir_swizzle
 
struct  hlsl_ir_index
 
struct  hlsl_deref
 
struct  hlsl_ir_load
 
struct  hlsl_ir_resource_load
 
struct  hlsl_ir_resource_store
 
struct  hlsl_ir_store
 
struct  hlsl_ir_constant
 
struct  hlsl_ir_constant::hlsl_constant_value
 
struct  hlsl_ir_string_constant
 
struct  hlsl_ir_compile
 
struct  hlsl_ir_sampler_state
 
struct  hlsl_ir_stateblock_constant
 
struct  hlsl_ir_vsir_instruction_ref
 
struct  hlsl_scope
 
struct  hlsl_profile_info
 
struct  hlsl_vec4
 
struct  hlsl_buffer
 
struct  hlsl_ctx
 
struct  hlsl_ctx::hlsl_constant_defs
 
struct  hlsl_ctx::hlsl_constant_defs::hlsl_constant_register
 
struct  hlsl_resource_load_params
 

Macros

#define HLSL_SWIZZLE_X   (0u)
 
#define HLSL_SWIZZLE_Y   (1u)
 
#define HLSL_SWIZZLE_Z   (2u)
 
#define HLSL_SWIZZLE_W   (3u)
 
#define HLSL_SWIZZLE(x, y, z, w)
 
#define HLSL_SWIZZLE_MASK   (0x3u)
 
#define HLSL_SWIZZLE_SHIFT(idx)   (2u * (idx))
 
#define HLSL_STORAGE_EXTERN   0x00000001
 
#define HLSL_STORAGE_NOINTERPOLATION   0x00000002
 
#define HLSL_MODIFIER_PRECISE   0x00000004
 
#define HLSL_STORAGE_SHARED   0x00000008
 
#define HLSL_STORAGE_GROUPSHARED   0x00000010
 
#define HLSL_STORAGE_STATIC   0x00000020
 
#define HLSL_STORAGE_UNIFORM   0x00000040
 
#define HLSL_MODIFIER_VOLATILE   0x00000080
 
#define HLSL_MODIFIER_CONST   0x00000100
 
#define HLSL_MODIFIER_ROW_MAJOR   0x00000200
 
#define HLSL_MODIFIER_COLUMN_MAJOR   0x00000400
 
#define HLSL_STORAGE_IN   0x00000800
 
#define HLSL_STORAGE_OUT   0x00001000
 
#define HLSL_MODIFIER_INLINE   0x00002000
 
#define HLSL_STORAGE_CENTROID   0x00004000
 
#define HLSL_STORAGE_NOPERSPECTIVE   0x00008000
 
#define HLSL_STORAGE_LINEAR   0x00010000
 
#define HLSL_MODIFIER_SINGLE   0x00020000
 
#define HLSL_MODIFIER_EXPORT   0x00040000
 
#define HLSL_STORAGE_ANNOTATION   0x00080000
 
#define HLSL_MODIFIER_UNORM   0x00100000
 
#define HLSL_MODIFIER_SNORM   0x00200000
 
#define HLSL_TYPE_MODIFIERS_MASK
 
#define HLSL_INTERPOLATION_MODIFIERS_MASK
 
#define HLSL_MODIFIERS_MAJORITY_MASK   (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)
 
#define HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT   0
 
#define HLSL_MAX_OPERANDS   3
 

Enumerations

enum  hlsl_type_class {
  HLSL_CLASS_SCALAR , HLSL_CLASS_VECTOR , HLSL_CLASS_MATRIX , HLSL_CLASS_LAST_NUMERIC = HLSL_CLASS_MATRIX ,
  HLSL_CLASS_STRUCT , HLSL_CLASS_ARRAY , HLSL_CLASS_DEPTH_STENCIL_STATE , HLSL_CLASS_DEPTH_STENCIL_VIEW ,
  HLSL_CLASS_EFFECT_GROUP , HLSL_CLASS_PASS , HLSL_CLASS_PIXEL_SHADER , HLSL_CLASS_RASTERIZER_STATE ,
  HLSL_CLASS_RENDER_TARGET_VIEW , HLSL_CLASS_SAMPLER , HLSL_CLASS_STRING , HLSL_CLASS_TECHNIQUE ,
  HLSL_CLASS_TEXTURE , HLSL_CLASS_UAV , HLSL_CLASS_VERTEX_SHADER , HLSL_CLASS_COMPUTE_SHADER ,
  HLSL_CLASS_DOMAIN_SHADER , HLSL_CLASS_HULL_SHADER , HLSL_CLASS_GEOMETRY_SHADER , HLSL_CLASS_CONSTANT_BUFFER ,
  HLSL_CLASS_BLEND_STATE , HLSL_CLASS_VOID , HLSL_CLASS_NULL , HLSL_CLASS_ERROR
}
 
enum  hlsl_base_type {
  HLSL_TYPE_FLOAT , HLSL_TYPE_HALF , HLSL_TYPE_DOUBLE , HLSL_TYPE_INT ,
  HLSL_TYPE_UINT , HLSL_TYPE_BOOL , HLSL_TYPE_LAST_SCALAR = HLSL_TYPE_BOOL
}
 
enum  hlsl_sampler_dim {
  HLSL_SAMPLER_DIM_GENERIC = 0 , HLSL_SAMPLER_DIM_COMPARISON , HLSL_SAMPLER_DIM_1D , HLSL_SAMPLER_DIM_2D ,
  HLSL_SAMPLER_DIM_3D , HLSL_SAMPLER_DIM_CUBE , HLSL_SAMPLER_DIM_LAST_SAMPLER = HLSL_SAMPLER_DIM_CUBE , HLSL_SAMPLER_DIM_1DARRAY ,
  HLSL_SAMPLER_DIM_2DARRAY , HLSL_SAMPLER_DIM_2DMS , HLSL_SAMPLER_DIM_2DMSARRAY , HLSL_SAMPLER_DIM_CUBEARRAY ,
  HLSL_SAMPLER_DIM_BUFFER , HLSL_SAMPLER_DIM_STRUCTURED_BUFFER , HLSL_SAMPLER_DIM_RAW_BUFFER , HLSL_SAMPLER_DIM_MAX = HLSL_SAMPLER_DIM_RAW_BUFFER
}
 
enum  hlsl_regset {
  HLSL_REGSET_SAMPLERS , HLSL_REGSET_TEXTURES , HLSL_REGSET_UAVS , HLSL_REGSET_LAST_OBJECT = HLSL_REGSET_UAVS ,
  HLSL_REGSET_NUMERIC , HLSL_REGSET_LAST = HLSL_REGSET_NUMERIC
}
 
enum  hlsl_ir_node_type {
  HLSL_IR_CALL , HLSL_IR_CONSTANT , HLSL_IR_EXPR , HLSL_IR_IF ,
  HLSL_IR_INDEX , HLSL_IR_LOAD , HLSL_IR_LOOP , HLSL_IR_JUMP ,
  HLSL_IR_RESOURCE_LOAD , HLSL_IR_RESOURCE_STORE , HLSL_IR_STRING_CONSTANT , HLSL_IR_STORE ,
  HLSL_IR_SWIZZLE , HLSL_IR_SWITCH , HLSL_IR_COMPILE , HLSL_IR_SAMPLER_STATE ,
  HLSL_IR_STATEBLOCK_CONSTANT , HLSL_IR_VSIR_INSTRUCTION_REF
}
 
enum  hlsl_ir_loop_unroll_type { HLSL_IR_LOOP_UNROLL , HLSL_IR_LOOP_FORCE_UNROLL , HLSL_IR_LOOP_FORCE_LOOP }
 
enum  hlsl_ir_expr_op {
  HLSL_OP0_ERROR , HLSL_OP0_VOID , HLSL_OP0_RASTERIZER_SAMPLE_COUNT , HLSL_OP1_ABS ,
  HLSL_OP1_BIT_NOT , HLSL_OP1_CAST , HLSL_OP1_CEIL , HLSL_OP1_COS ,
  HLSL_OP1_COS_REDUCED , HLSL_OP1_DSX , HLSL_OP1_DSX_COARSE , HLSL_OP1_DSX_FINE ,
  HLSL_OP1_DSY , HLSL_OP1_DSY_COARSE , HLSL_OP1_DSY_FINE , HLSL_OP1_EXP2 ,
  HLSL_OP1_F16TOF32 , HLSL_OP1_F32TOF16 , HLSL_OP1_FLOOR , HLSL_OP1_FRACT ,
  HLSL_OP1_LOG2 , HLSL_OP1_LOGIC_NOT , HLSL_OP1_NEG , HLSL_OP1_NRM ,
  HLSL_OP1_RCP , HLSL_OP1_REINTERPRET , HLSL_OP1_ROUND , HLSL_OP1_RSQ ,
  HLSL_OP1_SAT , HLSL_OP1_SIGN , HLSL_OP1_SIN , HLSL_OP1_SIN_REDUCED ,
  HLSL_OP1_SQRT , HLSL_OP1_TRUNC , HLSL_OP2_ADD , HLSL_OP2_BIT_AND ,
  HLSL_OP2_BIT_OR , HLSL_OP2_BIT_XOR , HLSL_OP2_CRS , HLSL_OP2_DIV ,
  HLSL_OP2_DOT , HLSL_OP2_EQUAL , HLSL_OP2_GEQUAL , HLSL_OP2_LESS ,
  HLSL_OP2_LOGIC_AND , HLSL_OP2_LOGIC_OR , HLSL_OP2_LSHIFT , HLSL_OP2_MAX ,
  HLSL_OP2_MIN , HLSL_OP2_MOD , HLSL_OP2_MUL , HLSL_OP2_NEQUAL ,
  HLSL_OP2_RSHIFT , HLSL_OP2_SLT , HLSL_OP3_DP2ADD , HLSL_OP3_CMP ,
  HLSL_OP3_TERNARY , HLSL_OP3_MAD
}
 
enum  hlsl_ir_jump_type {
  HLSL_IR_JUMP_BREAK , HLSL_IR_JUMP_CONTINUE , HLSL_IR_JUMP_DISCARD_NEG , HLSL_IR_JUMP_DISCARD_NZ ,
  HLSL_IR_JUMP_RETURN , HLSL_IR_JUMP_UNRESOLVED_CONTINUE
}
 
enum  hlsl_resource_load_type {
  HLSL_RESOURCE_LOAD , HLSL_RESOURCE_SAMPLE , HLSL_RESOURCE_SAMPLE_CMP , HLSL_RESOURCE_SAMPLE_CMP_LZ ,
  HLSL_RESOURCE_SAMPLE_LOD , HLSL_RESOURCE_SAMPLE_LOD_BIAS , HLSL_RESOURCE_SAMPLE_GRAD , HLSL_RESOURCE_SAMPLE_PROJ ,
  HLSL_RESOURCE_GATHER_RED , HLSL_RESOURCE_GATHER_GREEN , HLSL_RESOURCE_GATHER_BLUE , HLSL_RESOURCE_GATHER_ALPHA ,
  HLSL_RESOURCE_SAMPLE_INFO , HLSL_RESOURCE_RESINFO
}
 
enum  hlsl_buffer_type { HLSL_BUFFER_CONSTANT , HLSL_BUFFER_TEXTURE }
 

Functions

static unsigned int hlsl_swizzle_get_component (uint32_t swizzle, unsigned int idx)
 
static uint32_t vsir_swizzle_from_hlsl (uint32_t swizzle)
 
static bool hlsl_deref_is_lowered (const struct hlsl_deref *deref)
 
static bool hlsl_version_ge (const struct hlsl_ctx *ctx, unsigned int major, unsigned int minor)
 
static bool hlsl_version_lt (const struct hlsl_ctx *ctx, unsigned int major, unsigned int minor)
 
static struct hlsl_ir_call * hlsl_ir_call (const struct hlsl_ir_node *node)
 
static struct hlsl_ir_constant * hlsl_ir_constant (const struct hlsl_ir_node *node)
 
static struct hlsl_ir_string_constant * hlsl_ir_string_constant (const struct hlsl_ir_node *node)
 
static struct hlsl_ir_expr * hlsl_ir_expr (const struct hlsl_ir_node *node)
 
static struct hlsl_ir_if * hlsl_ir_if (const struct hlsl_ir_node *node)
 
static struct hlsl_ir_jump * hlsl_ir_jump (const struct hlsl_ir_node *node)
 
static struct hlsl_ir_load * hlsl_ir_load (const struct hlsl_ir_node *node)
 
static struct hlsl_ir_loop * hlsl_ir_loop (const struct hlsl_ir_node *node)
 
static struct hlsl_ir_resource_load * hlsl_ir_resource_load (const struct hlsl_ir_node *node)
 
static struct hlsl_ir_resource_store * hlsl_ir_resource_store (const struct hlsl_ir_node *node)
 
static struct hlsl_ir_store * hlsl_ir_store (const struct hlsl_ir_node *node)
 
static struct hlsl_ir_swizzle * hlsl_ir_swizzle (const struct hlsl_ir_node *node)
 
static struct hlsl_ir_index * hlsl_ir_index (const struct hlsl_ir_node *node)
 
static struct hlsl_ir_switch * hlsl_ir_switch (const struct hlsl_ir_node *node)
 
static struct hlsl_ir_compile * hlsl_ir_compile (const struct hlsl_ir_node *node)
 
static struct hlsl_ir_sampler_state * hlsl_ir_sampler_state (const struct hlsl_ir_node *node)
 
static struct hlsl_ir_stateblock_constant * hlsl_ir_stateblock_constant (const struct hlsl_ir_node *node)
 
static struct hlsl_ir_vsir_instruction_ref * hlsl_ir_vsir_instruction_ref (const struct hlsl_ir_node *node)
 
static void hlsl_block_init (struct hlsl_block *block)
 
static void hlsl_block_add_instr (struct hlsl_block *block, struct hlsl_ir_node *instr)
 
static void hlsl_block_add_block (struct hlsl_block *block, struct hlsl_block *add)
 
static void hlsl_src_from_node (struct hlsl_src *src, struct hlsl_ir_node *node)
 
static void hlsl_src_remove (struct hlsl_src *src)
 
static void * hlsl_alloc (struct hlsl_ctx *ctx, size_t size)
 
static void * hlsl_calloc (struct hlsl_ctx *ctx, size_t count, size_t size)
 
static void * hlsl_realloc (struct hlsl_ctx *ctx, void *ptr, size_t size)
 
static char * hlsl_strdup (struct hlsl_ctx *ctx, const char *string)
 
static bool hlsl_array_reserve (struct hlsl_ctx *ctx, void **elements, size_t *capacity, size_t element_count, size_t element_size)
 
static struct vkd3d_string_buffer * hlsl_get_string_buffer (struct hlsl_ctx *ctx)
 
static void hlsl_release_string_buffer (struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer)
 
static struct hlsl_type * hlsl_get_scalar_type (const struct hlsl_ctx *ctx, enum hlsl_base_type base_type)
 
static struct hlsl_type * hlsl_get_vector_type (const struct hlsl_ctx *ctx, enum hlsl_base_type base_type, unsigned int dimx)
 
static struct hlsl_type * hlsl_get_matrix_type (const struct hlsl_ctx *ctx, enum hlsl_base_type base_type, unsigned int dimx, unsigned int dimy)
 
static struct hlsl_type * hlsl_get_numeric_type (const struct hlsl_ctx *ctx, enum hlsl_type_class type, enum hlsl_base_type base_type, unsigned int dimx, unsigned int dimy)
 
static bool hlsl_is_numeric_type (const struct hlsl_type *type)
 
static unsigned int hlsl_sampler_dim_count (enum hlsl_sampler_dim dim)
 
static bool hlsl_var_has_buffer_offset_register_reservation (struct hlsl_ctx *ctx, const struct hlsl_ir_var *var)
 
char * hlsl_sprintf_alloc (struct hlsl_ctx *ctx, const char *fmt,...) VKD3D_PRINTF_FUNC(2
 
char const char * debug_hlsl_expr_op (enum hlsl_ir_expr_op op)
 
const char * debug_hlsl_type (struct hlsl_ctx *ctx, const struct hlsl_type *type)
 
const char * debug_hlsl_writemask (unsigned int writemask)
 
const char * debug_hlsl_swizzle (unsigned int swizzle, unsigned int count)
 
struct vkd3d_string_buffer * hlsl_type_to_string (struct hlsl_ctx *ctx, const struct hlsl_type *type)
 
struct vkd3d_string_buffer * hlsl_component_to_string (struct hlsl_ctx *ctx, const struct hlsl_ir_var *var, unsigned int index)
 
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_node * hlsl_add_conditional (struct hlsl_ctx *ctx, struct hlsl_block *block, 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)
 
void hlsl_block_cleanup (struct hlsl_block *block)
 
bool hlsl_clone_block (struct hlsl_ctx *ctx, struct hlsl_block *dst_block, const struct hlsl_block *src_block)
 
void hlsl_dump_function (struct hlsl_ctx *ctx, const struct hlsl_ir_function_decl *func)
 
void hlsl_dump_var_default_values (const struct hlsl_ir_var *var)
 
bool hlsl_state_block_add_entry (struct hlsl_state_block *state_block, struct hlsl_state_block_entry *entry)
 
bool hlsl_validate_state_block_entry (struct hlsl_ctx *ctx, struct hlsl_state_block_entry *entry, const struct vkd3d_shader_location *loc)
 
struct hlsl_state_block_entry * clone_stateblock_entry (struct hlsl_ctx *ctx, const struct hlsl_state_block_entry *src, const char *name, bool lhs_has_index, unsigned int lhs_index, bool single_arg, unsigned int arg_index)
 
void hlsl_lower_index_loads (struct hlsl_ctx *ctx, struct hlsl_block *body)
 
void hlsl_run_const_passes (struct hlsl_ctx *ctx, struct hlsl_block *body)
 
int hlsl_emit_bytecode (struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func, enum vkd3d_shader_target_type target_type, struct vkd3d_shader_code *out)
 
int hlsl_emit_effect_binary (struct hlsl_ctx *ctx, struct vkd3d_shader_code *out)
 
bool hlsl_init_deref_from_index_chain (struct hlsl_ctx *ctx, struct hlsl_deref *deref, struct hlsl_ir_node *chain)
 
bool hlsl_copy_deref (struct hlsl_ctx *ctx, struct hlsl_deref *deref, const struct hlsl_deref *other)
 
void hlsl_cleanup_deref (struct hlsl_deref *deref)
 
void hlsl_cleanup_semantic (struct hlsl_semantic *semantic)
 
bool hlsl_clone_semantic (struct hlsl_ctx *ctx, struct hlsl_semantic *dst, const struct hlsl_semantic *src)
 
void hlsl_cleanup_ir_switch_cases (struct list *cases)
 
void hlsl_free_ir_switch_case (struct hlsl_ir_switch_case *c)
 
void hlsl_replace_node (struct hlsl_ir_node *old, struct hlsl_ir_node *new)
 
void hlsl_free_attribute (struct hlsl_attribute *attr)
 
void hlsl_free_instr (struct hlsl_ir_node *node)
 
void hlsl_free_instr_list (struct list *list)
 
void hlsl_free_state_block (struct hlsl_state_block *state_block)
 
void hlsl_free_state_block_entry (struct hlsl_state_block_entry *state_block_entry)
 
void hlsl_free_type (struct hlsl_type *type)
 
void hlsl_free_var (struct hlsl_ir_var *decl)
 
struct hlsl_ir_function * hlsl_get_function (struct hlsl_ctx *ctx, const char *name)
 
struct hlsl_ir_function_decl * hlsl_get_first_func_decl (struct hlsl_ctx *ctx, const char *name)
 
struct hlsl_ir_function_decl * hlsl_get_func_decl (struct hlsl_ctx *ctx, const char *name, const struct hlsl_func_parameters *parameters)
 
const struct hlsl_profile_info * hlsl_get_target_info (const char *target)
 
struct hlsl_type * hlsl_get_type (struct hlsl_scope *scope, const char *name, bool recursive, bool case_insensitive)
 
struct hlsl_ir_var * hlsl_get_var (struct hlsl_scope *scope, const char *name)
 
struct hlsl_type * hlsl_get_element_type_from_path_index (struct hlsl_ctx *ctx, const struct hlsl_type *type, struct hlsl_ir_node *idx)
 
const char * hlsl_jump_type_to_string (enum hlsl_ir_jump_type type)
 
struct hlsl_type * hlsl_new_array_type (struct hlsl_ctx *ctx, struct hlsl_type *basic_type, unsigned int array_size)
 
struct hlsl_ir_node * hlsl_new_binary_expr (struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2)
 
struct hlsl_ir_node * hlsl_new_bool_constant (struct hlsl_ctx *ctx, bool b, const struct vkd3d_shader_location *loc)
 
struct hlsl_buffer * hlsl_new_buffer (struct hlsl_ctx *ctx, enum hlsl_buffer_type type, const char *name, uint32_t modifiers, const struct hlsl_reg_reservation *reservation, struct hlsl_scope *annotations, const struct vkd3d_shader_location *loc)
 
struct hlsl_ir_node * hlsl_new_call (struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *decl, const struct vkd3d_shader_location *loc)
 
struct hlsl_ir_node * hlsl_new_cast (struct hlsl_ctx *ctx, struct hlsl_ir_node *node, struct hlsl_type *type, const struct vkd3d_shader_location *loc)
 
struct hlsl_ir_node * hlsl_new_constant (struct hlsl_ctx *ctx, struct hlsl_type *type, const struct hlsl_constant_value *value, const struct vkd3d_shader_location *loc)
 
struct hlsl_ir_node * hlsl_new_copy (struct hlsl_ctx *ctx, struct hlsl_ir_node *node)
 
struct hlsl_ir_node * hlsl_new_expr (struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS], struct hlsl_type *data_type, const struct vkd3d_shader_location *loc)
 
struct hlsl_ir_node * hlsl_new_float_constant (struct hlsl_ctx *ctx, float f, const struct vkd3d_shader_location *loc)
 
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 * hlsl_new_if (struct hlsl_ctx *ctx, struct hlsl_ir_node *condition, struct hlsl_block *then_block, struct hlsl_block *else_block, const struct vkd3d_shader_location *loc)
 
struct hlsl_ir_node * hlsl_new_int_constant (struct hlsl_ctx *ctx, int32_t n, const struct vkd3d_shader_location *loc)
 
struct hlsl_ir_node * hlsl_new_jump (struct hlsl_ctx *ctx, enum hlsl_ir_jump_type type, struct hlsl_ir_node *condition, const struct vkd3d_shader_location *loc)
 
struct hlsl_ir_node * hlsl_new_ternary_expr (struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2, struct hlsl_ir_node *arg3)
 
void hlsl_init_simple_deref_from_var (struct hlsl_deref *deref, struct hlsl_ir_var *var)
 
struct hlsl_ir_load * hlsl_new_var_load (struct hlsl_ctx *ctx, struct hlsl_ir_var *var, const struct vkd3d_shader_location *loc)
 
struct hlsl_ir_load * hlsl_new_load_index (struct hlsl_ctx *ctx, const struct hlsl_deref *deref, struct hlsl_ir_node *idx, const struct vkd3d_shader_location *loc)
 
struct hlsl_ir_load * hlsl_new_load_parent (struct hlsl_ctx *ctx, const struct hlsl_deref *deref, const struct vkd3d_shader_location *loc)
 
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_node * hlsl_add_load_component (struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_node *var_instr, unsigned int comp, const struct vkd3d_shader_location *loc)
 
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)
 
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)
 
bool hlsl_index_is_resource_access (struct hlsl_ir_index *index)
 
bool hlsl_index_chain_has_resource_access (struct hlsl_ir_index *index)
 
struct hlsl_ir_node * hlsl_new_compile (struct hlsl_ctx *ctx, enum hlsl_compile_type compile_type, const char *profile_name, struct hlsl_ir_node **args, unsigned int args_count, struct hlsl_block *args_instrs, const struct vkd3d_shader_location *loc)
 
struct hlsl_ir_node * hlsl_new_index (struct hlsl_ctx *ctx, struct hlsl_ir_node *val, struct hlsl_ir_node *idx, const struct vkd3d_shader_location *loc)
 
struct hlsl_ir_node * hlsl_new_loop (struct hlsl_ctx *ctx, struct hlsl_block *block, enum hlsl_ir_loop_unroll_type unroll_type, unsigned int unroll_limit, const struct vkd3d_shader_location *loc)
 
struct hlsl_ir_node * hlsl_new_resource_load (struct hlsl_ctx *ctx, const struct hlsl_resource_load_params *params, const struct vkd3d_shader_location *loc)
 
struct hlsl_ir_node * hlsl_new_resource_store (struct hlsl_ctx *ctx, const struct hlsl_deref *resource, 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_node * hlsl_new_swizzle (struct hlsl_ctx *ctx, uint32_t s, unsigned int components, struct hlsl_ir_node *val, const struct vkd3d_shader_location *loc)
 
struct hlsl_ir_node * hlsl_new_sampler_state (struct hlsl_ctx *ctx, const struct hlsl_state_block *state_block, struct vkd3d_shader_location *loc)
 
struct hlsl_ir_node * hlsl_new_stateblock_constant (struct hlsl_ctx *ctx, const char *name, struct vkd3d_shader_location *loc)
 
struct hlsl_ir_node * hlsl_new_string_constant (struct hlsl_ctx *ctx, const char *str, 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_ir_var * hlsl_new_synthetic_var_named (struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type, const struct vkd3d_shader_location *loc, bool dummy_scope)
 
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, bool rasteriser_ordered)
 
struct hlsl_type * hlsl_new_cb_type (struct hlsl_ctx *ctx, struct hlsl_type *format)
 
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_null_constant (struct hlsl_ctx *ctx, 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)
 
struct hlsl_ir_var * hlsl_new_var (struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type, const struct vkd3d_shader_location *loc, const struct hlsl_semantic *semantic, uint32_t modifiers, const struct hlsl_reg_reservation *reg_reservation)
 
struct hlsl_ir_switch_case * hlsl_new_switch_case (struct hlsl_ctx *ctx, unsigned int value, bool is_default, struct hlsl_block *body, const struct vkd3d_shader_location *loc)
 
struct hlsl_ir_node * hlsl_new_switch (struct hlsl_ctx *ctx, struct hlsl_ir_node *selector, struct list *cases, const struct vkd3d_shader_location *loc)
 
struct hlsl_ir_node * hlsl_new_vsir_instruction_ref (struct hlsl_ctx *ctx, unsigned int vsir_instr_idx, struct hlsl_type *type, const struct hlsl_reg *reg, const struct vkd3d_shader_location *loc)
 
void hlsl_error (struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_error error, const char *fmt,...) VKD3D_PRINTF_FUNC(4
 
void void hlsl_fixme (struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, const char *fmt,...) VKD3D_PRINTF_FUNC(3
 
void void void hlsl_warning (struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_error error, const char *fmt,...) VKD3D_PRINTF_FUNC(4
 
void void void void hlsl_note (struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_log_level level, const char *fmt,...) VKD3D_PRINTF_FUNC(4
 
void void void void void hlsl_push_scope (struct hlsl_ctx *ctx)
 
void hlsl_pop_scope (struct hlsl_ctx *ctx)
 
bool hlsl_scope_add_type (struct hlsl_scope *scope, struct hlsl_type *type)
 
struct hlsl_type * hlsl_type_clone (struct hlsl_ctx *ctx, struct hlsl_type *old, unsigned int default_majority, uint32_t modifiers)
 
unsigned int hlsl_type_component_count (const struct hlsl_type *type)
 
unsigned int hlsl_type_get_array_element_reg_size (const struct hlsl_type *type, enum hlsl_regset regset)
 
struct hlsl_type * hlsl_type_get_component_type (struct hlsl_ctx *ctx, struct hlsl_type *type, unsigned int index)
 
unsigned int hlsl_type_get_component_offset (struct hlsl_ctx *ctx, struct hlsl_type *type, unsigned int index, enum hlsl_regset *regset)
 
bool hlsl_type_is_row_major (const struct hlsl_type *type)
 
unsigned int hlsl_type_minor_size (const struct hlsl_type *type)
 
unsigned int hlsl_type_major_size (const struct hlsl_type *type)
 
unsigned int hlsl_type_element_count (const struct hlsl_type *type)
 
bool hlsl_type_is_resource (const struct hlsl_type *type)
 
bool hlsl_type_is_shader (const struct hlsl_type *type)
 
unsigned int hlsl_type_get_sm4_offset (const struct hlsl_type *type, unsigned int offset)
 
bool hlsl_types_are_equal (const struct hlsl_type *t1, const struct hlsl_type *t2)
 
void hlsl_calculate_buffer_offsets (struct hlsl_ctx *ctx)
 
const struct hlsl_type * hlsl_get_multiarray_element_type (const struct hlsl_type *type)
 
unsigned int hlsl_get_multiarray_size (const struct hlsl_type *type)
 
uint32_t hlsl_combine_swizzles (uint32_t first, uint32_t second, unsigned int dim)
 
unsigned int hlsl_combine_writemasks (unsigned int first, unsigned int second)
 
uint32_t hlsl_map_swizzle (uint32_t swizzle, unsigned int writemask)
 
uint32_t hlsl_swizzle_from_writemask (unsigned int writemask)
 
struct hlsl_type * hlsl_deref_get_type (struct hlsl_ctx *ctx, const struct hlsl_deref *deref)
 
enum hlsl_regset hlsl_deref_get_regset (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)
 
bool hlsl_copy_propagation_execute (struct hlsl_ctx *ctx, struct hlsl_block *block)
 
bool hlsl_fold_constant_exprs (struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
 
bool hlsl_fold_constant_identities (struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
 
bool hlsl_fold_constant_swizzles (struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
 
bool hlsl_transform_ir (struct hlsl_ctx *ctx, bool(*func)(struct hlsl_ctx *ctx, struct hlsl_ir_node *, void *), struct hlsl_block *block, void *context)
 
D3DXPARAMETER_CLASS hlsl_sm1_class (const struct hlsl_type *type)
 
D3DXPARAMETER_TYPE hlsl_sm1_base_type (const struct hlsl_type *type)
 
void write_sm1_uniforms (struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer)
 
int d3dbc_compile (struct vsir_program *program, uint64_t config_flags, const struct vkd3d_shader_compile_info *compile_info, const struct vkd3d_shader_code *ctab, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
 
int tpf_compile (struct vsir_program *program, uint64_t config_flags, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context, struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func)
 
enum vkd3d_shader_interpolation_mode sm4_get_interpolation_mode (struct hlsl_type *type, unsigned int storage_modifiers)
 
struct hlsl_ir_function_decl * hlsl_compile_internal_function (struct hlsl_ctx *ctx, const char *name, const char *hlsl)
 
int hlsl_lexer_compile (struct hlsl_ctx *ctx, const struct vkd3d_shader_code *hlsl)
 

Macro Definition Documentation

◆ HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT

#define HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT   0

Definition at line 429 of file hlsl.h.

◆ HLSL_INTERPOLATION_MODIFIERS_MASK

#define HLSL_INTERPOLATION_MODIFIERS_MASK
Value:
#define HLSL_STORAGE_CENTROID
Definition: hlsl.h:411
#define HLSL_STORAGE_LINEAR
Definition: hlsl.h:413
#define HLSL_STORAGE_NOINTERPOLATION
Definition: hlsl.h:398
#define HLSL_STORAGE_NOPERSPECTIVE
Definition: hlsl.h:412

Definition at line 424 of file hlsl.h.

◆ HLSL_MAX_OPERANDS

#define HLSL_MAX_OPERANDS   3

Definition at line 750 of file hlsl.h.

◆ HLSL_MODIFIER_COLUMN_MAJOR

#define HLSL_MODIFIER_COLUMN_MAJOR   0x00000400

Definition at line 407 of file hlsl.h.

◆ HLSL_MODIFIER_CONST

#define HLSL_MODIFIER_CONST   0x00000100

Definition at line 405 of file hlsl.h.

◆ HLSL_MODIFIER_EXPORT

#define HLSL_MODIFIER_EXPORT   0x00040000

Definition at line 415 of file hlsl.h.

◆ HLSL_MODIFIER_INLINE

#define HLSL_MODIFIER_INLINE   0x00002000

Definition at line 410 of file hlsl.h.

◆ HLSL_MODIFIER_PRECISE

#define HLSL_MODIFIER_PRECISE   0x00000004

Definition at line 399 of file hlsl.h.

◆ HLSL_MODIFIER_ROW_MAJOR

#define HLSL_MODIFIER_ROW_MAJOR   0x00000200

Definition at line 406 of file hlsl.h.

◆ HLSL_MODIFIER_SINGLE

#define HLSL_MODIFIER_SINGLE   0x00020000

Definition at line 414 of file hlsl.h.

◆ HLSL_MODIFIER_SNORM

#define HLSL_MODIFIER_SNORM   0x00200000

Definition at line 418 of file hlsl.h.

◆ HLSL_MODIFIER_UNORM

#define HLSL_MODIFIER_UNORM   0x00100000

Definition at line 417 of file hlsl.h.

◆ HLSL_MODIFIER_VOLATILE

#define HLSL_MODIFIER_VOLATILE   0x00000080

Definition at line 404 of file hlsl.h.

◆ HLSL_MODIFIERS_MAJORITY_MASK

#define HLSL_MODIFIERS_MAJORITY_MASK   (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)

Definition at line 427 of file hlsl.h.

◆ HLSL_STORAGE_ANNOTATION

#define HLSL_STORAGE_ANNOTATION   0x00080000

Definition at line 416 of file hlsl.h.

◆ HLSL_STORAGE_CENTROID

#define HLSL_STORAGE_CENTROID   0x00004000

Definition at line 411 of file hlsl.h.

◆ HLSL_STORAGE_EXTERN

#define HLSL_STORAGE_EXTERN   0x00000001

Definition at line 397 of file hlsl.h.

◆ HLSL_STORAGE_GROUPSHARED

#define HLSL_STORAGE_GROUPSHARED   0x00000010

Definition at line 401 of file hlsl.h.

◆ HLSL_STORAGE_IN

#define HLSL_STORAGE_IN   0x00000800

Definition at line 408 of file hlsl.h.

◆ HLSL_STORAGE_LINEAR

#define HLSL_STORAGE_LINEAR   0x00010000

Definition at line 413 of file hlsl.h.

◆ HLSL_STORAGE_NOINTERPOLATION

#define HLSL_STORAGE_NOINTERPOLATION   0x00000002

Definition at line 398 of file hlsl.h.

◆ HLSL_STORAGE_NOPERSPECTIVE

#define HLSL_STORAGE_NOPERSPECTIVE   0x00008000

Definition at line 412 of file hlsl.h.

◆ HLSL_STORAGE_OUT

#define HLSL_STORAGE_OUT   0x00001000

Definition at line 409 of file hlsl.h.

◆ HLSL_STORAGE_SHARED

#define HLSL_STORAGE_SHARED   0x00000008

Definition at line 400 of file hlsl.h.

◆ HLSL_STORAGE_STATIC

#define HLSL_STORAGE_STATIC   0x00000020

Definition at line 402 of file hlsl.h.

◆ HLSL_STORAGE_UNIFORM

#define HLSL_STORAGE_UNIFORM   0x00000040

Definition at line 403 of file hlsl.h.

◆ HLSL_SWIZZLE

#define HLSL_SWIZZLE (   x,
  y,
  z,
  w 
)
Value:
(((HLSL_SWIZZLE_ ## x) << 0) \
| ((HLSL_SWIZZLE_ ## y) << 2) \
| ((HLSL_SWIZZLE_ ## z) << 4) \
| ((HLSL_SWIZZLE_ ## w) << 6))
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLdouble GLdouble z
Definition: glext.h:5874

Definition at line 59 of file hlsl.h.

◆ HLSL_SWIZZLE_MASK

#define HLSL_SWIZZLE_MASK   (0x3u)

Definition at line 65 of file hlsl.h.

◆ HLSL_SWIZZLE_SHIFT

#define HLSL_SWIZZLE_SHIFT (   idx)    (2u * (idx))

Definition at line 66 of file hlsl.h.

◆ HLSL_SWIZZLE_W

#define HLSL_SWIZZLE_W   (3u)

Definition at line 57 of file hlsl.h.

◆ HLSL_SWIZZLE_X

#define HLSL_SWIZZLE_X   (0u)

Definition at line 54 of file hlsl.h.

◆ HLSL_SWIZZLE_Y

#define HLSL_SWIZZLE_Y   (1u)

Definition at line 55 of file hlsl.h.

◆ HLSL_SWIZZLE_Z

#define HLSL_SWIZZLE_Z   (2u)

Definition at line 56 of file hlsl.h.

◆ HLSL_TYPE_MODIFIERS_MASK

#define HLSL_TYPE_MODIFIERS_MASK
Value:
#define HLSL_MODIFIER_UNORM
Definition: hlsl.h:417
#define HLSL_MODIFIER_PRECISE
Definition: hlsl.h:399
#define HLSL_MODIFIER_SNORM
Definition: hlsl.h:418
#define HLSL_MODIFIER_CONST
Definition: hlsl.h:405
#define HLSL_MODIFIER_ROW_MAJOR
Definition: hlsl.h:406
#define HLSL_MODIFIER_COLUMN_MAJOR
Definition: hlsl.h:407
#define HLSL_MODIFIER_VOLATILE
Definition: hlsl.h:404

Definition at line 420 of file hlsl.h.

Enumeration Type Documentation

◆ hlsl_base_type

Enumerator
HLSL_TYPE_FLOAT 
HLSL_TYPE_HALF 
HLSL_TYPE_DOUBLE 
HLSL_TYPE_INT 
HLSL_TYPE_UINT 
HLSL_TYPE_BOOL 
HLSL_TYPE_LAST_SCALAR 

Definition at line 113 of file hlsl.h.

114{
122};
@ HLSL_TYPE_HALF
Definition: hlsl.h:116
@ HLSL_TYPE_BOOL
Definition: hlsl.h:120
@ HLSL_TYPE_UINT
Definition: hlsl.h:119
@ HLSL_TYPE_LAST_SCALAR
Definition: hlsl.h:121
@ HLSL_TYPE_INT
Definition: hlsl.h:118
@ HLSL_TYPE_FLOAT
Definition: hlsl.h:115
@ HLSL_TYPE_DOUBLE
Definition: hlsl.h:117

◆ hlsl_buffer_type

Enumerator
HLSL_BUFFER_CONSTANT 
HLSL_BUFFER_TEXTURE 

Definition at line 983 of file hlsl.h.

984{
987};
@ HLSL_BUFFER_CONSTANT
Definition: hlsl.h:985
@ HLSL_BUFFER_TEXTURE
Definition: hlsl.h:986

◆ hlsl_ir_expr_op

Enumerator
HLSL_OP0_ERROR 
HLSL_OP0_VOID 
HLSL_OP0_RASTERIZER_SAMPLE_COUNT 
HLSL_OP1_ABS 
HLSL_OP1_BIT_NOT 
HLSL_OP1_CAST 
HLSL_OP1_CEIL 
HLSL_OP1_COS 
HLSL_OP1_COS_REDUCED 
HLSL_OP1_DSX 
HLSL_OP1_DSX_COARSE 
HLSL_OP1_DSX_FINE 
HLSL_OP1_DSY 
HLSL_OP1_DSY_COARSE 
HLSL_OP1_DSY_FINE 
HLSL_OP1_EXP2 
HLSL_OP1_F16TOF32 
HLSL_OP1_F32TOF16 
HLSL_OP1_FLOOR 
HLSL_OP1_FRACT 
HLSL_OP1_LOG2 
HLSL_OP1_LOGIC_NOT 
HLSL_OP1_NEG 
HLSL_OP1_NRM 
HLSL_OP1_RCP 
HLSL_OP1_REINTERPRET 
HLSL_OP1_ROUND 
HLSL_OP1_RSQ 
HLSL_OP1_SAT 
HLSL_OP1_SIGN 
HLSL_OP1_SIN 
HLSL_OP1_SIN_REDUCED 
HLSL_OP1_SQRT 
HLSL_OP1_TRUNC 
HLSL_OP2_ADD 
HLSL_OP2_BIT_AND 
HLSL_OP2_BIT_OR 
HLSL_OP2_BIT_XOR 
HLSL_OP2_CRS 
HLSL_OP2_DIV 
HLSL_OP2_DOT 
HLSL_OP2_EQUAL 
HLSL_OP2_GEQUAL 
HLSL_OP2_LESS 
HLSL_OP2_LOGIC_AND 
HLSL_OP2_LOGIC_OR 
HLSL_OP2_LSHIFT 
HLSL_OP2_MAX 
HLSL_OP2_MIN 
HLSL_OP2_MOD 
HLSL_OP2_MUL 
HLSL_OP2_NEQUAL 
HLSL_OP2_RSHIFT 
HLSL_OP2_SLT 
HLSL_OP3_DP2ADD 
HLSL_OP3_CMP 
HLSL_OP3_TERNARY 
HLSL_OP3_MAD 

Definition at line 680 of file hlsl.h.

681{
685
691 HLSL_OP1_COS_REDUCED, /* Reduced range [-pi, pi], writes to .x */
714 HLSL_OP1_SIN_REDUCED, /* Reduced range [-pi, pi], writes to .y */
717
737 /* SLT(a, b) retrieves 1.0 if (a < b), else 0.0. Only used for SM1-SM3 target vertex shaders. */
739
740 /* DP2ADD(a, b, c) computes the scalar product of a.xy and b.xy,
741 * then adds c, where c must have dimx=1. */
743 /* TERNARY(a, b, c) returns 'b' if 'a' is true and 'c' otherwise. 'a' must always be boolean.
744 * CMP(a, b, c) returns 'b' if 'a' >= 0, and 'c' otherwise. It's used only for SM1-SM3 targets. */
748};
@ HLSL_OP2_LESS
Definition: hlsl.h:727
@ HLSL_OP1_DSY
Definition: hlsl.h:695
@ HLSL_OP2_LOGIC_AND
Definition: hlsl.h:728
@ HLSL_OP2_LOGIC_OR
Definition: hlsl.h:729
@ HLSL_OP1_NEG
Definition: hlsl.h:705
@ HLSL_OP1_F32TOF16
Definition: hlsl.h:700
@ HLSL_OP2_DIV
Definition: hlsl.h:723
@ HLSL_OP1_NRM
Definition: hlsl.h:706
@ HLSL_OP1_DSY_COARSE
Definition: hlsl.h:696
@ HLSL_OP1_DSY_FINE
Definition: hlsl.h:697
@ HLSL_OP2_LSHIFT
Definition: hlsl.h:730
@ HLSL_OP2_ADD
Definition: hlsl.h:718
@ HLSL_OP1_SAT
Definition: hlsl.h:711
@ HLSL_OP1_F16TOF32
Definition: hlsl.h:699
@ HLSL_OP2_NEQUAL
Definition: hlsl.h:735
@ HLSL_OP1_DSX_FINE
Definition: hlsl.h:694
@ HLSL_OP1_COS_REDUCED
Definition: hlsl.h:691
@ HLSL_OP2_MIN
Definition: hlsl.h:732
@ HLSL_OP1_BIT_NOT
Definition: hlsl.h:687
@ HLSL_OP1_ABS
Definition: hlsl.h:686
@ HLSL_OP1_CEIL
Definition: hlsl.h:689
@ HLSL_OP2_MAX
Definition: hlsl.h:731
@ HLSL_OP1_TRUNC
Definition: hlsl.h:716
@ HLSL_OP1_FRACT
Definition: hlsl.h:702
@ HLSL_OP2_BIT_XOR
Definition: hlsl.h:721
@ HLSL_OP0_RASTERIZER_SAMPLE_COUNT
Definition: hlsl.h:684
@ HLSL_OP2_BIT_AND
Definition: hlsl.h:719
@ HLSL_OP2_MOD
Definition: hlsl.h:733
@ HLSL_OP3_MAD
Definition: hlsl.h:747
@ HLSL_OP2_RSHIFT
Definition: hlsl.h:736
@ HLSL_OP1_FLOOR
Definition: hlsl.h:701
@ HLSL_OP0_ERROR
Definition: hlsl.h:682
@ HLSL_OP1_COS
Definition: hlsl.h:690
@ HLSL_OP2_MUL
Definition: hlsl.h:734
@ HLSL_OP2_GEQUAL
Definition: hlsl.h:726
@ HLSL_OP2_SLT
Definition: hlsl.h:738
@ HLSL_OP2_EQUAL
Definition: hlsl.h:725
@ HLSL_OP1_ROUND
Definition: hlsl.h:709
@ HLSL_OP1_RCP
Definition: hlsl.h:707
@ HLSL_OP1_DSX
Definition: hlsl.h:692
@ HLSL_OP3_TERNARY
Definition: hlsl.h:746
@ HLSL_OP1_LOG2
Definition: hlsl.h:703
@ HLSL_OP1_EXP2
Definition: hlsl.h:698
@ HLSL_OP0_VOID
Definition: hlsl.h:683
@ HLSL_OP3_DP2ADD
Definition: hlsl.h:742
@ HLSL_OP2_CRS
Definition: hlsl.h:722
@ HLSL_OP3_CMP
Definition: hlsl.h:745
@ HLSL_OP1_LOGIC_NOT
Definition: hlsl.h:704
@ HLSL_OP1_RSQ
Definition: hlsl.h:710
@ HLSL_OP1_DSX_COARSE
Definition: hlsl.h:693
@ HLSL_OP1_SQRT
Definition: hlsl.h:715
@ HLSL_OP2_DOT
Definition: hlsl.h:724
@ HLSL_OP1_SIN
Definition: hlsl.h:713
@ HLSL_OP1_SIGN
Definition: hlsl.h:712
@ HLSL_OP2_BIT_OR
Definition: hlsl.h:720
@ HLSL_OP1_CAST
Definition: hlsl.h:688
@ HLSL_OP1_SIN_REDUCED
Definition: hlsl.h:714
@ HLSL_OP1_REINTERPRET
Definition: hlsl.h:708

◆ hlsl_ir_jump_type

Enumerator
HLSL_IR_JUMP_BREAK 
HLSL_IR_JUMP_CONTINUE 
HLSL_IR_JUMP_DISCARD_NEG 
HLSL_IR_JUMP_DISCARD_NZ 
HLSL_IR_JUMP_RETURN 
HLSL_IR_JUMP_UNRESOLVED_CONTINUE 

Definition at line 759 of file hlsl.h.

760{
766 /* UNRESOLVED_CONTINUE type is used by the parser when 'continue' statement is found,
767 it never reaches code generation, and is resolved to CONTINUE type once iteration
768 and loop exit logic was properly applied. */
770};
@ HLSL_IR_JUMP_DISCARD_NZ
Definition: hlsl.h:764
@ HLSL_IR_JUMP_UNRESOLVED_CONTINUE
Definition: hlsl.h:769
@ HLSL_IR_JUMP_RETURN
Definition: hlsl.h:765
@ HLSL_IR_JUMP_CONTINUE
Definition: hlsl.h:762
@ HLSL_IR_JUMP_DISCARD_NEG
Definition: hlsl.h:763
@ HLSL_IR_JUMP_BREAK
Definition: hlsl.h:761

◆ hlsl_ir_loop_unroll_type

Enumerator
HLSL_IR_LOOP_UNROLL 
HLSL_IR_LOOP_FORCE_UNROLL 
HLSL_IR_LOOP_FORCE_LOOP 

Definition at line 647 of file hlsl.h.

648{
652};
@ HLSL_IR_LOOP_UNROLL
Definition: hlsl.h:649
@ HLSL_IR_LOOP_FORCE_UNROLL
Definition: hlsl.h:650
@ HLSL_IR_LOOP_FORCE_LOOP
Definition: hlsl.h:651

◆ hlsl_ir_node_type

Enumerator
HLSL_IR_CALL 
HLSL_IR_CONSTANT 
HLSL_IR_EXPR 
HLSL_IR_IF 
HLSL_IR_INDEX 
HLSL_IR_LOAD 
HLSL_IR_LOOP 
HLSL_IR_JUMP 
HLSL_IR_RESOURCE_LOAD 
HLSL_IR_RESOURCE_STORE 
HLSL_IR_STRING_CONSTANT 
HLSL_IR_STORE 
HLSL_IR_SWIZZLE 
HLSL_IR_SWITCH 
HLSL_IR_COMPILE 
HLSL_IR_SAMPLER_STATE 
HLSL_IR_STATEBLOCK_CONSTANT 
HLSL_IR_VSIR_INSTRUCTION_REF 

Definition at line 313 of file hlsl.h.

314{
329
333
335};
@ HLSL_IR_LOOP
Definition: hlsl.h:321
@ HLSL_IR_SWIZZLE
Definition: hlsl.h:327
@ HLSL_IR_IF
Definition: hlsl.h:318
@ HLSL_IR_STATEBLOCK_CONSTANT
Definition: hlsl.h:332
@ HLSL_IR_INDEX
Definition: hlsl.h:319
@ HLSL_IR_CALL
Definition: hlsl.h:315
@ HLSL_IR_LOAD
Definition: hlsl.h:320
@ HLSL_IR_CONSTANT
Definition: hlsl.h:316
@ HLSL_IR_VSIR_INSTRUCTION_REF
Definition: hlsl.h:334
@ HLSL_IR_COMPILE
Definition: hlsl.h:330
@ HLSL_IR_RESOURCE_LOAD
Definition: hlsl.h:323
@ HLSL_IR_SAMPLER_STATE
Definition: hlsl.h:331
@ HLSL_IR_SWITCH
Definition: hlsl.h:328
@ HLSL_IR_RESOURCE_STORE
Definition: hlsl.h:324
@ HLSL_IR_STORE
Definition: hlsl.h:326
@ HLSL_IR_EXPR
Definition: hlsl.h:317
@ HLSL_IR_JUMP
Definition: hlsl.h:322
@ HLSL_IR_STRING_CONSTANT
Definition: hlsl.h:325

◆ hlsl_regset

Enumerator
HLSL_REGSET_SAMPLERS 
HLSL_REGSET_TEXTURES 
HLSL_REGSET_UAVS 
HLSL_REGSET_LAST_OBJECT 
HLSL_REGSET_NUMERIC 
HLSL_REGSET_LAST 

Definition at line 145 of file hlsl.h.

146{
153};
@ HLSL_REGSET_NUMERIC
Definition: hlsl.h:151
@ HLSL_REGSET_LAST
Definition: hlsl.h:152
@ HLSL_REGSET_UAVS
Definition: hlsl.h:149
@ HLSL_REGSET_TEXTURES
Definition: hlsl.h:148
@ HLSL_REGSET_SAMPLERS
Definition: hlsl.h:147
@ HLSL_REGSET_LAST_OBJECT
Definition: hlsl.h:150

◆ hlsl_resource_load_type

Enumerator
HLSL_RESOURCE_LOAD 
HLSL_RESOURCE_SAMPLE 
HLSL_RESOURCE_SAMPLE_CMP 
HLSL_RESOURCE_SAMPLE_CMP_LZ 
HLSL_RESOURCE_SAMPLE_LOD 
HLSL_RESOURCE_SAMPLE_LOD_BIAS 
HLSL_RESOURCE_SAMPLE_GRAD 
HLSL_RESOURCE_SAMPLE_PROJ 
HLSL_RESOURCE_GATHER_RED 
HLSL_RESOURCE_GATHER_GREEN 
HLSL_RESOURCE_GATHER_BLUE 
HLSL_RESOURCE_GATHER_ALPHA 
HLSL_RESOURCE_SAMPLE_INFO 
HLSL_RESOURCE_RESINFO 

Definition at line 833 of file hlsl.h.

834{
849};
@ HLSL_RESOURCE_SAMPLE
Definition: hlsl.h:836
@ HLSL_RESOURCE_GATHER_BLUE
Definition: hlsl.h:845
@ HLSL_RESOURCE_SAMPLE_GRAD
Definition: hlsl.h:841
@ HLSL_RESOURCE_SAMPLE_CMP
Definition: hlsl.h:837
@ HLSL_RESOURCE_SAMPLE_CMP_LZ
Definition: hlsl.h:838
@ HLSL_RESOURCE_RESINFO
Definition: hlsl.h:848
@ HLSL_RESOURCE_SAMPLE_LOD_BIAS
Definition: hlsl.h:840
@ HLSL_RESOURCE_SAMPLE_PROJ
Definition: hlsl.h:842
@ HLSL_RESOURCE_SAMPLE_INFO
Definition: hlsl.h:847
@ HLSL_RESOURCE_GATHER_GREEN
Definition: hlsl.h:844
@ HLSL_RESOURCE_GATHER_RED
Definition: hlsl.h:843
@ HLSL_RESOURCE_SAMPLE_LOD
Definition: hlsl.h:839
@ HLSL_RESOURCE_LOAD
Definition: hlsl.h:835
@ HLSL_RESOURCE_GATHER_ALPHA
Definition: hlsl.h:846

◆ hlsl_sampler_dim

Enumerator
HLSL_SAMPLER_DIM_GENERIC 
HLSL_SAMPLER_DIM_COMPARISON 
HLSL_SAMPLER_DIM_1D 
HLSL_SAMPLER_DIM_2D 
HLSL_SAMPLER_DIM_3D 
HLSL_SAMPLER_DIM_CUBE 
HLSL_SAMPLER_DIM_LAST_SAMPLER 
HLSL_SAMPLER_DIM_1DARRAY 
HLSL_SAMPLER_DIM_2DARRAY 
HLSL_SAMPLER_DIM_2DMS 
HLSL_SAMPLER_DIM_2DMSARRAY 
HLSL_SAMPLER_DIM_CUBEARRAY 
HLSL_SAMPLER_DIM_BUFFER 
HLSL_SAMPLER_DIM_STRUCTURED_BUFFER 
HLSL_SAMPLER_DIM_RAW_BUFFER 
HLSL_SAMPLER_DIM_MAX 

Definition at line 124 of file hlsl.h.

125{
142 /* NOTE: Remember to update object_methods[] in hlsl.y if this enum is modified. */
143};
@ HLSL_SAMPLER_DIM_GENERIC
Definition: hlsl.h:126
@ HLSL_SAMPLER_DIM_1DARRAY
Definition: hlsl.h:133
@ HLSL_SAMPLER_DIM_CUBEARRAY
Definition: hlsl.h:137
@ HLSL_SAMPLER_DIM_2DMSARRAY
Definition: hlsl.h:136
@ HLSL_SAMPLER_DIM_BUFFER
Definition: hlsl.h:138
@ HLSL_SAMPLER_DIM_2DMS
Definition: hlsl.h:135
@ HLSL_SAMPLER_DIM_MAX
Definition: hlsl.h:141
@ HLSL_SAMPLER_DIM_LAST_SAMPLER
Definition: hlsl.h:132
@ HLSL_SAMPLER_DIM_2DARRAY
Definition: hlsl.h:134
@ HLSL_SAMPLER_DIM_CUBE
Definition: hlsl.h:131
@ HLSL_SAMPLER_DIM_3D
Definition: hlsl.h:130
@ HLSL_SAMPLER_DIM_2D
Definition: hlsl.h:129
@ HLSL_SAMPLER_DIM_RAW_BUFFER
Definition: hlsl.h:140
@ HLSL_SAMPLER_DIM_COMPARISON
Definition: hlsl.h:127
@ HLSL_SAMPLER_DIM_STRUCTURED_BUFFER
Definition: hlsl.h:139
@ HLSL_SAMPLER_DIM_1D
Definition: hlsl.h:128

◆ hlsl_type_class

Enumerator
HLSL_CLASS_SCALAR 
HLSL_CLASS_VECTOR 
HLSL_CLASS_MATRIX 
HLSL_CLASS_LAST_NUMERIC 
HLSL_CLASS_STRUCT 
HLSL_CLASS_ARRAY 
HLSL_CLASS_DEPTH_STENCIL_STATE 
HLSL_CLASS_DEPTH_STENCIL_VIEW 
HLSL_CLASS_EFFECT_GROUP 
HLSL_CLASS_PASS 
HLSL_CLASS_PIXEL_SHADER 
HLSL_CLASS_RASTERIZER_STATE 
HLSL_CLASS_RENDER_TARGET_VIEW 
HLSL_CLASS_SAMPLER 
HLSL_CLASS_STRING 
HLSL_CLASS_TECHNIQUE 
HLSL_CLASS_TEXTURE 
HLSL_CLASS_UAV 
HLSL_CLASS_VERTEX_SHADER 
HLSL_CLASS_COMPUTE_SHADER 
HLSL_CLASS_DOMAIN_SHADER 
HLSL_CLASS_HULL_SHADER 
HLSL_CLASS_GEOMETRY_SHADER 
HLSL_CLASS_CONSTANT_BUFFER 
HLSL_CLASS_BLEND_STATE 
HLSL_CLASS_VOID 
HLSL_CLASS_NULL 
HLSL_CLASS_ERROR 

Definition at line 81 of file hlsl.h.

82{
111};
@ HLSL_CLASS_COMPUTE_SHADER
Definition: hlsl.h:102
@ HLSL_CLASS_RASTERIZER_STATE
Definition: hlsl.h:94
@ HLSL_CLASS_RENDER_TARGET_VIEW
Definition: hlsl.h:95
@ HLSL_CLASS_VERTEX_SHADER
Definition: hlsl.h:101
@ HLSL_CLASS_MATRIX
Definition: hlsl.h:85
@ HLSL_CLASS_GEOMETRY_SHADER
Definition: hlsl.h:105
@ HLSL_CLASS_TECHNIQUE
Definition: hlsl.h:98
@ HLSL_CLASS_SAMPLER
Definition: hlsl.h:96
@ HLSL_CLASS_UAV
Definition: hlsl.h:100
@ HLSL_CLASS_VECTOR
Definition: hlsl.h:84
@ HLSL_CLASS_TEXTURE
Definition: hlsl.h:99
@ HLSL_CLASS_DEPTH_STENCIL_VIEW
Definition: hlsl.h:90
@ HLSL_CLASS_STRUCT
Definition: hlsl.h:87
@ HLSL_CLASS_LAST_NUMERIC
Definition: hlsl.h:86
@ HLSL_CLASS_CONSTANT_BUFFER
Definition: hlsl.h:106
@ HLSL_CLASS_VOID
Definition: hlsl.h:108
@ HLSL_CLASS_SCALAR
Definition: hlsl.h:83
@ HLSL_CLASS_EFFECT_GROUP
Definition: hlsl.h:91
@ HLSL_CLASS_PIXEL_SHADER
Definition: hlsl.h:93
@ HLSL_CLASS_BLEND_STATE
Definition: hlsl.h:107
@ HLSL_CLASS_STRING
Definition: hlsl.h:97
@ HLSL_CLASS_HULL_SHADER
Definition: hlsl.h:104
@ HLSL_CLASS_DOMAIN_SHADER
Definition: hlsl.h:103
@ HLSL_CLASS_NULL
Definition: hlsl.h:109
@ HLSL_CLASS_ARRAY
Definition: hlsl.h:88
@ HLSL_CLASS_DEPTH_STENCIL_STATE
Definition: hlsl.h:89
@ HLSL_CLASS_PASS
Definition: hlsl.h:92
@ HLSL_CLASS_ERROR
Definition: hlsl.h:110

Function Documentation

◆ clone_stateblock_entry()

struct hlsl_state_block_entry * clone_stateblock_entry ( struct hlsl_ctx *  ctx,
const struct hlsl_state_block_entry *  src,
const char *  name,
bool  lhs_has_index,
unsigned int  lhs_index,
bool  single_arg,
unsigned int  arg_index 
)

Definition at line 2379 of file hlsl.c.

2382{
2384 struct clone_instr_map map = { 0 };
2385
2386 if (!(entry = hlsl_alloc(ctx, sizeof(*entry))))
2387 return NULL;
2388 entry->name = hlsl_strdup(ctx, name);
2389 entry->lhs_has_index = lhs_has_index;
2390 entry->lhs_index = lhs_index;
2391 if (!(entry->instrs = hlsl_alloc(ctx, sizeof(*entry->instrs))))
2392 {
2394 return NULL;
2395 }
2396
2397 if (single_arg)
2398 entry->args_count = 1;
2399 else
2400 entry->args_count = src->args_count;
2401
2402 if (!(entry->args = hlsl_alloc(ctx, sizeof(*entry->args) * entry->args_count)))
2403 {
2405 return NULL;
2406 }
2407
2408 hlsl_block_init(entry->instrs);
2409 if (!clone_block(ctx, entry->instrs, src->instrs, &map))
2410 {
2412 return NULL;
2413 }
2414
2415 if (single_arg)
2416 {
2417 clone_src(&map, entry->args, &src->args[arg_index]);
2418 }
2419 else
2420 {
2421 for (unsigned int i = 0; i < src->args_count; ++i)
2422 clone_src(&map, &entry->args[i], &src->args[i]);
2423 }
2424 vkd3d_free(map.instrs);
2425
2426 return entry;
2427}
Definition: _map.h:48
#define NULL
Definition: types.h:112
GLenum src
Definition: glext.h:6340
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static bool clone_block(struct hlsl_ctx *ctx, struct hlsl_block *dst_block, const struct hlsl_block *src_block, struct clone_instr_map *map)
Definition: hlsl.c:2087
void hlsl_free_state_block_entry(struct hlsl_state_block_entry *entry)
Definition: hlsl.c:137
static void clone_src(struct clone_instr_map *map, struct hlsl_src *dst, const struct hlsl_src *src)
Definition: hlsl.c:2152
static char * hlsl_strdup(struct hlsl_ctx *ctx, const char *string)
Definition: hlsl.h:1327
static void hlsl_block_init(struct hlsl_block *block)
Definition: hlsl.h:1268
static void * hlsl_alloc(struct hlsl_ctx *ctx, size_t size)
Definition: hlsl.h:1300
uint32_t entry
Definition: isohybrid.c:63
Definition: hlsl.h:549
Definition: name.c:39
static void vkd3d_free(void *ptr)
Definition: vkd3d_memory.h:52

Referenced by decompose_fx_4_state_block_expand_array(), decompose_fx_4_state_function_call(), and hlsl_new_sampler_state().

◆ d3dbc_compile()

int d3dbc_compile ( struct vsir_program *  program,
uint64_t  config_flags,
const struct vkd3d_shader_compile_info *  compile_info,
const struct vkd3d_shader_code *  ctab,
struct vkd3d_shader_code *  out,
struct vkd3d_shader_message_context *  message_context 
)

Definition at line 2359 of file d3dbc.c.

2362{
2363 const struct vkd3d_shader_version *version = &program->shader_version;
2364 struct d3dbc_compiler d3dbc = {0};
2365 struct vkd3d_bytecode_buffer *buffer = &d3dbc.buffer;
2366 int result;
2367
2368 d3dbc.program = program;
2369 d3dbc.message_context = message_context;
2370 switch (version->type)
2371 {
2374 break;
2375
2378 break;
2379
2380 default:
2382 "Invalid shader type %u.", version->type);
2384 }
2385
2386 put_u32(buffer, sm1_version(version->type, version->major, version->minor));
2387
2388 bytecode_put_bytes(buffer, ctab->code, ctab->size);
2389
2392
2394
2395 result = VKD3D_OK;
2396 if (buffer->status)
2397 result = buffer->status;
2398 if (d3dbc.failed)
2400
2401 if (!result)
2402 {
2403 out->code = buffer->data;
2404 out->size = buffer->size;
2405 }
2406 else
2407 {
2408 vkd3d_free(buffer->data);
2409 }
2410 return result;
2411}
static void put_u32(struct bytecode_buffer *buffer, uint32_t value)
static const struct vkd3d_sm1_opcode_info ps_opcode_table[]
Definition: d3dbc.c:301
@ VKD3D_SM1_OP_END
Definition: d3dbc.c:201
static const struct vkd3d_sm1_opcode_info vs_opcode_table[]
Definition: d3dbc.c:233
static void d3dbc_write_semantic_dcls(struct d3dbc_compiler *d3dbc)
Definition: d3dbc.c:2323
static void d3dbc_write_program_instructions(struct d3dbc_compiler *d3dbc)
Definition: d3dbc.c:2350
static uint32_t sm1_version(enum vkd3d_shader_type type, unsigned int major, unsigned int minor)
Definition: d3dbc.c:1522
static const WCHAR version[]
Definition: asmname.c:66
GLuint buffer
Definition: glext.h:5915
GLuint program
Definition: glext.h:6723
GLuint64EXT * result
Definition: glext.h:11304
struct vkd3d_bytecode_buffer buffer
Definition: d3dbc.c:1517
struct vkd3d_shader_message_context * message_context
Definition: d3dbc.c:1518
struct vsir_program * program
Definition: d3dbc.c:1516
const struct vkd3d_sm1_opcode_info * opcode_table
Definition: d3dbc.c:1515
bool failed
Definition: d3dbc.c:1519
const void * code
Definition: vkd3d_shader.h:413
size_t bytecode_put_bytes(struct vkd3d_bytecode_buffer *buffer, const void *bytes, size_t size)
@ VKD3D_SHADER_TYPE_VERTEX
@ VKD3D_SHADER_TYPE_PIXEL
vkd3d_shader_error
@ VKD3D_SHADER_ERROR_D3DBC_INVALID_PROFILE
@ VKD3D_ERROR_INVALID_SHADER
Definition: vkd3d_types.h:53
@ VKD3D_OK
Definition: vkd3d_types.h:43
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

Referenced by hlsl_emit_bytecode().

◆ debug_hlsl_expr_op()

char const char * debug_hlsl_expr_op ( enum hlsl_ir_expr_op  op)

Definition at line 3176 of file hlsl.c.

3177{
3178 static const char *const op_names[] =
3179 {
3180 [HLSL_OP0_ERROR] = "error",
3181 [HLSL_OP0_VOID] = "void",
3182 [HLSL_OP0_RASTERIZER_SAMPLE_COUNT] = "GetRenderTargetSampleCount",
3183
3184 [HLSL_OP1_ABS] = "abs",
3185 [HLSL_OP1_BIT_NOT] = "~",
3186 [HLSL_OP1_CAST] = "cast",
3187 [HLSL_OP1_CEIL] = "ceil",
3188 [HLSL_OP1_COS] = "cos",
3189 [HLSL_OP1_COS_REDUCED] = "cos_reduced",
3190 [HLSL_OP1_DSX] = "dsx",
3191 [HLSL_OP1_DSX_COARSE] = "dsx_coarse",
3192 [HLSL_OP1_DSX_FINE] = "dsx_fine",
3193 [HLSL_OP1_DSY] = "dsy",
3194 [HLSL_OP1_DSY_COARSE] = "dsy_coarse",
3195 [HLSL_OP1_DSY_FINE] = "dsy_fine",
3196 [HLSL_OP1_EXP2] = "exp2",
3197 [HLSL_OP1_F16TOF32] = "f16tof32",
3198 [HLSL_OP1_F32TOF16] = "f32tof16",
3199 [HLSL_OP1_FLOOR] = "floor",
3200 [HLSL_OP1_FRACT] = "fract",
3201 [HLSL_OP1_LOG2] = "log2",
3202 [HLSL_OP1_LOGIC_NOT] = "!",
3203 [HLSL_OP1_NEG] = "-",
3204 [HLSL_OP1_NRM] = "nrm",
3205 [HLSL_OP1_RCP] = "rcp",
3206 [HLSL_OP1_REINTERPRET] = "reinterpret",
3207 [HLSL_OP1_ROUND] = "round",
3208 [HLSL_OP1_RSQ] = "rsq",
3209 [HLSL_OP1_SAT] = "sat",
3210 [HLSL_OP1_SIGN] = "sign",
3211 [HLSL_OP1_SIN] = "sin",
3212 [HLSL_OP1_SIN_REDUCED] = "sin_reduced",
3213 [HLSL_OP1_SQRT] = "sqrt",
3214 [HLSL_OP1_TRUNC] = "trunc",
3215
3216 [HLSL_OP2_ADD] = "+",
3217 [HLSL_OP2_BIT_AND] = "&",
3218 [HLSL_OP2_BIT_OR] = "|",
3219 [HLSL_OP2_BIT_XOR] = "^",
3220 [HLSL_OP2_CRS] = "crs",
3221 [HLSL_OP2_DIV] = "/",
3222 [HLSL_OP2_DOT] = "dot",
3223 [HLSL_OP2_EQUAL] = "==",
3224 [HLSL_OP2_GEQUAL] = ">=",
3225 [HLSL_OP2_LESS] = "<",
3226 [HLSL_OP2_LOGIC_AND] = "&&",
3227 [HLSL_OP2_LOGIC_OR] = "||",
3228 [HLSL_OP2_LSHIFT] = "<<",
3229 [HLSL_OP2_MAX] = "max",
3230 [HLSL_OP2_MIN] = "min",
3231 [HLSL_OP2_MOD] = "%",
3232 [HLSL_OP2_MUL] = "*",
3233 [HLSL_OP2_NEQUAL] = "!=",
3234 [HLSL_OP2_RSHIFT] = ">>",
3235 [HLSL_OP2_SLT] = "slt",
3236
3237 [HLSL_OP3_CMP] = "cmp",
3238 [HLSL_OP3_DP2ADD] = "dp2add",
3239 [HLSL_OP3_TERNARY] = "ternary",
3240 [HLSL_OP3_MAD] = "mad",
3241 };
3242
3243 return op_names[op];
3244}
UINT op
Definition: effect.c:235

Referenced by dump_ir_expr(), hlsl_fold_constant_exprs(), sm1_generate_vsir_instr_expr(), and sm4_generate_vsir_instr_expr().

◆ debug_hlsl_swizzle()

const char * debug_hlsl_swizzle ( unsigned int  swizzle,
unsigned int  count 
)

◆ debug_hlsl_type()

const char * debug_hlsl_type ( struct hlsl_ctx *  ctx,
const struct hlsl_type *  type 
)

Definition at line 2889 of file hlsl.c.

2890{
2892 const char *ret;
2893
2894 if (!(string = hlsl_type_to_string(ctx, type)))
2895 return NULL;
2896 ret = vkd3d_dbg_sprintf("%s", string->buffer);
2898 return ret;
2899}
return ret
Definition: mutex.c:147
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
struct vkd3d_string_buffer * hlsl_type_to_string(struct hlsl_ctx *ctx, const struct hlsl_type *type)
Definition: hlsl.c:2696
static void hlsl_release_string_buffer(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer)
Definition: hlsl.h:1355
char string[160]
Definition: util.h:11
const char * vkd3d_dbg_sprintf(const char *fmt,...) VKD3D_PRINTF_FUNC(1

Referenced by dump_instr(), dump_ir_var(), fold_abs(), fold_add(), fold_and(), fold_bit_xor(), fold_cast(), fold_ceil(), fold_div(), fold_dot(), fold_dp2add(), fold_exp2(), fold_floor(), fold_fract(), fold_log2(), fold_max(), fold_min(), fold_mod(), fold_mul(), fold_neg(), fold_not(), fold_or(), fold_rcp(), fold_rsq(), fold_sat(), fold_sqrt(), sm1_generate_vsir_instr_expr_cast(), and sm4_generate_vsir_instr_expr().

◆ debug_hlsl_writemask()

const char * debug_hlsl_writemask ( unsigned int  writemask)

Definition at line 3074 of file hlsl.c.

3075{
3076 static const char components[] = {'x', 'y', 'z', 'w'};
3077 char string[5];
3078 unsigned int i = 0, pos = 0;
3079
3080 VKD3D_ASSERT(!(writemask & ~VKD3DSP_WRITEMASK_ALL));
3081
3082 while (writemask)
3083 {
3084 if (writemask & 1)
3085 string[pos++] = components[i];
3086 writemask >>= 1;
3087 i++;
3088 }
3089 string[pos] = '\0';
3090 return vkd3d_dbg_sprintf(".%s", string);
3091}
GLenum GLenum GLuint components
Definition: glext.h:9620
#define VKD3D_ASSERT(cond)
Definition: vkd3d_common.h:49
#define VKD3DSP_WRITEMASK_ALL

Referenced by copy_propagation_invalidate_variable(), copy_propagation_set_value(), debug_register(), and dump_ir_store().

◆ hlsl_add_conditional()

struct hlsl_ir_node * hlsl_add_conditional ( struct hlsl_ctx *  ctx,
struct hlsl_block *  block,
struct hlsl_ir_node *  condition,
struct hlsl_ir_node *  if_true,
struct hlsl_ir_node *  if_false 
)

Definition at line 3667 of file hlsl_codegen.c.

3669{
3670 struct hlsl_type *cond_type = condition->data_type;
3671 struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS];
3672 struct hlsl_ir_node *cond;
3673
3674 VKD3D_ASSERT(hlsl_types_are_equal(if_true->data_type, if_false->data_type));
3675
3676 if (cond_type->e.numeric.type != HLSL_TYPE_BOOL)
3677 {
3678 cond_type = hlsl_get_numeric_type(ctx, cond_type->class, HLSL_TYPE_BOOL, cond_type->dimx, cond_type->dimy);
3679
3680 if (!(condition = hlsl_new_cast(ctx, condition, cond_type, &condition->loc)))
3681 return NULL;
3683 }
3684
3685 operands[0] = condition;
3686 operands[1] = if_true;
3687 operands[2] = if_false;
3688 if (!(cond = hlsl_new_expr(ctx, HLSL_OP3_TERNARY, operands, if_true->data_type, &condition->loc)))
3689 return false;
3690 hlsl_block_add_instr(instrs, cond);
3691
3692 return cond;
3693}
GLenum condition
Definition: glext.h:9255
bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2)
Definition: hlsl.c:1095
struct hlsl_ir_node * hlsl_new_cast(struct hlsl_ctx *ctx, struct hlsl_ir_node *node, struct hlsl_type *type, const struct vkd3d_shader_location *loc)
Definition: hlsl.c:1294
struct hlsl_ir_node * hlsl_new_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS], struct hlsl_type *data_type, const struct vkd3d_shader_location *loc)
Definition: hlsl.c:1595
static struct hlsl_type * hlsl_get_numeric_type(const struct hlsl_ctx *ctx, enum hlsl_type_class type, enum hlsl_base_type base_type, unsigned int dimx, unsigned int dimy)
Definition: hlsl.h:1377
static void hlsl_block_add_instr(struct hlsl_block *block, struct hlsl_ir_node *instr)
Definition: hlsl.h:1274
#define HLSL_MAX_OPERANDS
Definition: hlsl.h:750
unsigned int dimx
Definition: hlsl.h:187
struct hlsl_type::@5997::@5998 numeric
union hlsl_type::@5997 e
enum hlsl_type_class class
Definition: hlsl.h:163
unsigned int dimy
Definition: hlsl.h:188
@ if_true
Definition: wpp_private.h:102
@ if_false
Definition: wpp_private.h:101

Referenced by lower_float_modulus(), lower_int_division(), and lower_int_modulus().

◆ hlsl_add_function()

void hlsl_add_function ( struct hlsl_ctx *  ctx,
char *  name,
struct hlsl_ir_function_decl *  decl 
)

Definition at line 3946 of file hlsl.c.

3947{
3948 struct hlsl_ir_function *func;
3949 struct rb_entry *func_entry;
3950
3951 if (ctx->internal_func_name)
3952 {
3953 char *internal_name;
3954
3955 if (!(internal_name = hlsl_strdup(ctx, ctx->internal_func_name)))
3956 return;
3958 name = internal_name;
3959 }
3960
3961 func_entry = rb_get(&ctx->functions, name);
3962 if (func_entry)
3963 {
3964 func = RB_ENTRY_VALUE(func_entry, struct hlsl_ir_function, entry);
3965 decl->func = func;
3966 list_add_tail(&func->overloads, &decl->entry);
3968 return;
3969 }
3970 func = hlsl_alloc(ctx, sizeof(*func));
3971 func->name = name;
3972 list_init(&func->overloads);
3973 decl->func = func;
3974 list_add_tail(&func->overloads, &decl->entry);
3975 rb_put(&ctx->functions, func->name, &func->entry);
3976}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static void list_init(struct list_entry *head)
Definition: list.h:51
GLenum func
Definition: glext.h:6028
#define RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:26
static int rb_put(struct rb_tree *tree, const void *key, struct rb_entry *entry)
Definition: rbtree.h:204
static struct rb_entry * rb_get(const struct rb_tree *tree, const void *key)
Definition: rbtree.h:192
struct list entry
Definition: hlsl.h:605
struct hlsl_ir_function * func
Definition: hlsl.h:608
Definition: rbtree.h:30

◆ hlsl_add_load_component()

struct hlsl_ir_node * hlsl_add_load_component ( struct hlsl_ctx *  ctx,
struct hlsl_block *  block,
struct hlsl_ir_node *  var_instr,
unsigned int  comp,
const struct vkd3d_shader_location *  loc 
)

◆ hlsl_add_var()

bool hlsl_add_var ( struct hlsl_ctx *  ctx,
struct hlsl_ir_var *  decl,
bool  local_var 
)

Definition at line 96 of file hlsl.c.

97{
98 struct hlsl_scope *scope = ctx->cur_scope;
99 struct hlsl_ir_var *var;
100
101 if (decl->name)
102 {
104 {
105 if (var->name && !strcmp(decl->name, var->name))
106 return false;
107 }
108 if (local_var && scope->upper->upper == ctx->globals)
109 {
110 /* Check whether the variable redefines a function parameter. */
111 LIST_FOR_EACH_ENTRY(var, &scope->upper->vars, struct hlsl_ir_var, scope_entry)
112 {
113 if (var->name && !strcmp(decl->name, var->name))
114 return false;
115 }
116 }
117 }
118
119 list_add_tail(&scope->vars, &decl->scope_entry);
120 return true;
121}
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
const char * var
Definition: shader.c:5879
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:236
const char * name
Definition: hlsl.h:456
struct hlsl_scope * scope
Definition: hlsl.h:470
struct list scope_entry
Definition: hlsl.h:466

◆ hlsl_alloc()

◆ hlsl_array_reserve()

static bool hlsl_array_reserve ( struct hlsl_ctx *  ctx,
void **  elements,
size_t *  capacity,
size_t  element_count,
size_t  element_size 
)
inlinestatic

Definition at line 1336 of file hlsl.h.

1338{
1339 bool ret = vkd3d_array_reserve(elements, capacity, element_count, element_size);
1340
1341 if (!ret)
1343 return ret;
1344}
size_t const element_size
Definition: debug_heap.cpp:510
static ULONG ** element_count
Definition: exception.c:124
bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t element_count, size_t element_size)
Definition: memory.c:22

Referenced by clone_block(), copy_propagation_trace_record_value(), find_recursive_calls(), record_allocation(), record_constant(), and sm4_get_extern_resources().

◆ hlsl_block_add_block()

static void hlsl_block_add_block ( struct hlsl_block *  block,
struct hlsl_block *  add 
)
inlinestatic

Definition at line 1280 of file hlsl.h.

1281{
1282 list_move_tail(&block->instrs, &add->instrs);
1283 block->value = add->value;
1284}
static void list_move_tail(struct list_head *list, struct list_head *head)
Definition: list.h:122
__forceinline bool __cdecl add(big_integer &x, uint32_t const value)
static unsigned int block
Definition: xmlmemory.c:101

Referenced by hlsl_new_compile(), hlsl_new_if(), hlsl_new_load_component(), hlsl_new_loop(), hlsl_new_store_component(), hlsl_new_switch_case(), lower_matrix_swizzles(), lower_trig(), new_offset_instr_from_deref(), and transform_unroll_loops().

◆ hlsl_block_add_instr()

◆ hlsl_block_cleanup()

◆ hlsl_block_init()

◆ hlsl_calculate_buffer_offsets()

void hlsl_calculate_buffer_offsets ( struct hlsl_ctx *  ctx)

Definition at line 5551 of file hlsl_codegen.c.

5552{
5553 struct hlsl_ir_var *var;
5554
5555 LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
5556 {
5557 if (!var->is_uniform || hlsl_type_is_resource(var->data_type))
5558 continue;
5559
5562 }
5563
5564 LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
5565 {
5566 if (!var->is_uniform || hlsl_type_is_resource(var->data_type))
5567 continue;
5568
5571 }
5572}
bool hlsl_type_is_resource(const struct hlsl_type *type)
Definition: hlsl.c:240
static bool hlsl_var_has_buffer_offset_register_reservation(struct hlsl_ctx *ctx, const struct hlsl_ir_var *var)
Definition: hlsl.h:1418
static void hlsl_calculate_buffer_offset(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, bool register_reservation)
struct list extern_entry
Definition: hlsl.h:468

Referenced by allocate_buffers(), and fx_write_context_init().

◆ hlsl_calloc()

static void * hlsl_calloc ( struct hlsl_ctx *  ctx,
size_t  count,
size_t  size 
)
inlinestatic

Definition at line 1309 of file hlsl.h.

1310{
1311 void *ptr = vkd3d_calloc(count, size);
1312
1313 if (!ptr)
1315 return ptr;
1316}
GLuint GLuint GLsizei count
Definition: gl.h:1545

Referenced by hlsl_new_var(), hlsl_type_clone(), init_deref(), and write_fx_4_type().

◆ hlsl_cleanup_deref()

void hlsl_cleanup_deref ( struct hlsl_deref *  deref)

Definition at line 1408 of file hlsl.c.

1409{
1410 unsigned int i;
1411
1412 for (i = 0; i < deref->path_len; ++i)
1413 hlsl_src_remove(&deref->path[i]);
1414 vkd3d_free(deref->path);
1415
1416 deref->path = NULL;
1417 deref->path_len = 0;
1418
1419 hlsl_src_remove(&deref->rel_offset);
1420 deref->const_offset = 0;
1421}
static void hlsl_src_remove(struct hlsl_src *src)
Definition: hlsl.h:1293
unsigned int path_len
Definition: hlsl.h:805
struct hlsl_src rel_offset
Definition: hlsl.h:816
struct hlsl_src * path
Definition: hlsl.h:806
unsigned int const_offset
Definition: hlsl.h:817

Referenced by clone_resource_load(), copy_propagation_transform_object_load(), free_ir_load(), free_ir_resource_load(), free_ir_resource_store(), free_ir_store(), hlsl_new_resource_load(), lower_nonconstant_array_loads(), and replace_deref_path_with_offset().

◆ hlsl_cleanup_ir_switch_cases()

void hlsl_cleanup_ir_switch_cases ( struct list *  cases)

Definition at line 2436 of file hlsl.c.

2437{
2438 struct hlsl_ir_switch_case *c, *next;
2439
2441 {
2443 }
2444}
const GLubyte * c
Definition: glext.h:8905
void hlsl_free_ir_switch_case(struct hlsl_ir_switch_case *c)
Definition: hlsl.c:2429
#define c
Definition: ke_i.h:80
static unsigned __int64 next
Definition: rand_nt.c:6
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:242

Referenced by clone_switch(), and free_ir_switch().

◆ hlsl_cleanup_semantic()

void hlsl_cleanup_semantic ( struct hlsl_semantic *  semantic)

Definition at line 3896 of file hlsl.c.

3897{
3898 vkd3d_free((void *)semantic->name);
3899 vkd3d_free((void *)semantic->raw_name);
3900 memset(semantic, 0, sizeof(*semantic));
3901}
#define memset(x, y, z)
Definition: compat.h:39
const char * name
Definition: hlsl.h:241
const char * raw_name
Definition: hlsl.h:245

Referenced by add_semantic_var(), hlsl_clone_semantic(), hlsl_free_type(), and hlsl_free_var().

◆ hlsl_clone_block()

bool hlsl_clone_block ( struct hlsl_ctx *  ctx,
struct hlsl_block *  dst_block,
const struct hlsl_block *  src_block 
)

Definition at line 2544 of file hlsl.c.

2545{
2546 struct clone_instr_map map = {0};
2547 bool ret;
2548
2549 ret = clone_block(ctx, dst_block, src_block, &map);
2550 vkd3d_free(map.instrs);
2551 return ret;
2552}

Referenced by loop_unrolling_unroll_loop(), lower_calls(), process_entry_function(), and transform_unroll_loops().

◆ hlsl_clone_semantic()

bool hlsl_clone_semantic ( struct hlsl_ctx *  ctx,
struct hlsl_semantic *  dst,
const struct hlsl_semantic *  src 
)

Definition at line 3903 of file hlsl.c.

3904{
3905 *dst = *src;
3906 dst->name = dst->raw_name = NULL;
3907 if (src->name && !(dst->name = hlsl_strdup(ctx, src->name)))
3908 return false;
3909 if (src->raw_name && !(dst->raw_name = hlsl_strdup(ctx, src->raw_name)))
3910 {
3912 return false;
3913 }
3914
3915 return true;
3916}
GLenum GLenum dst
Definition: glext.h:6340
void hlsl_cleanup_semantic(struct hlsl_semantic *semantic)
Definition: hlsl.c:3896

Referenced by add_semantic_var().

◆ hlsl_combine_swizzles()

uint32_t hlsl_combine_swizzles ( uint32_t  first,
uint32_t  second,
unsigned int  dim 
)

Definition at line 4042 of file hlsl.c.

4043{
4044 uint32_t ret = 0;
4045 unsigned int i;
4046 for (i = 0; i < dim; ++i)
4047 {
4048 unsigned int s = hlsl_swizzle_get_component(second, i);
4050 }
4051 return ret;
4052}
UINT32 uint32_t
Definition: types.h:75
GLdouble s
Definition: gl.h:2039
const GLint * first
Definition: glext.h:5794
#define HLSL_SWIZZLE_SHIFT(idx)
Definition: hlsl.h:66
static unsigned int hlsl_swizzle_get_component(uint32_t swizzle, unsigned int idx)
Definition: hlsl.h:68

Referenced by fold_swizzle_chains(), generate_vsir_instr_swizzle(), and write_sm4_swizzle().

◆ hlsl_combine_writemasks()

unsigned int hlsl_combine_writemasks ( unsigned int  first,
unsigned int  second 
)

Definition at line 4026 of file hlsl.c.

4027{
4028 unsigned int ret = 0, i, j = 0;
4029
4030 for (i = 0; i < 4; ++i)
4031 {
4032 if (first & (1 << i))
4033 {
4034 if (second & (1 << j++))
4035 ret |= (1 << i);
4036 }
4037 }
4038
4039 return ret;
4040}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250

Referenced by allocate_register(), hlsl_reg_from_deref(), sm1_generate_vsir_init_dst_param_from_deref(), sm4_numeric_register_from_deref(), and write_sm4_store().

◆ hlsl_compile_internal_function()

struct hlsl_ir_function_decl * hlsl_compile_internal_function ( struct hlsl_ctx *  ctx,
const char *  name,
const char *  hlsl 
)

Definition at line 4642 of file hlsl.c.

4643{
4644 const struct hlsl_ir_function_decl *saved_cur_function = ctx->cur_function;
4645 struct vkd3d_shader_code code = {.code = hlsl, .size = strlen(hlsl)};
4646 const char *saved_internal_func_name = ctx->internal_func_name;
4647 struct vkd3d_string_buffer *internal_name;
4649 void *saved_scanner = ctx->scanner;
4650 int ret;
4651
4652 TRACE("name %s, hlsl %s.\n", debugstr_a(name), debugstr_a(hlsl));
4653
4654 /* The actual name of the function is mangled with a unique prefix, both to
4655 * allow defining multiple variants of a function with the same name, and to
4656 * avoid polluting the user name space. */
4657
4658 if (!(internal_name = hlsl_get_string_buffer(ctx)))
4659 return NULL;
4660 vkd3d_string_buffer_printf(internal_name, "<%s-%u>", name, ctx->internal_name_counter++);
4661
4662 /* Save and restore everything that matters.
4663 * Note that saving the scope stack is hard, and shouldn't be necessary. */
4664
4666 ctx->scanner = NULL;
4667 ctx->internal_func_name = internal_name->buffer;
4668 ctx->cur_function = NULL;
4670 ctx->scanner = saved_scanner;
4671 ctx->internal_func_name = saved_internal_func_name;
4672 ctx->cur_function = saved_cur_function;
4674 if (ret)
4675 {
4676 ERR("Failed to compile intrinsic, error %u.\n", ret);
4677 hlsl_release_string_buffer(ctx, internal_name);
4678 return NULL;
4679 }
4680 func = hlsl_get_first_func_decl(ctx, internal_name->buffer);
4681 hlsl_release_string_buffer(ctx, internal_name);
4682 return func;
4683}
#define ERR(fmt,...)
Definition: precomp.h:57
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
struct hlsl_ir_function_decl * hlsl_get_first_func_decl(struct hlsl_ctx *ctx, const char *name)
Definition: hlsl.c:1028
void hlsl_pop_scope(struct hlsl_ctx *ctx)
Definition: hlsl.c:2653
void hlsl_push_scope(struct hlsl_ctx *ctx)
Definition: hlsl.c:2642
static struct vkd3d_string_buffer * hlsl_get_string_buffer(struct hlsl_ctx *ctx)
Definition: hlsl.h:1346
int hlsl_lexer_compile(struct hlsl_ctx *ctx, const struct vkd3d_shader_code *hlsl)
#define debugstr_a
Definition: kernel32.h:31
#define TRACE(s)
Definition: solgame.cpp:4
Definition: inflate.c:139
int vkd3d_string_buffer_printf(struct vkd3d_string_buffer *buffer, const char *format,...)

Referenced by lower_f16tof32(), and lower_f32tof16().

◆ hlsl_component_index_range_from_deref()

bool hlsl_component_index_range_from_deref ( struct hlsl_ctx *  ctx,
const struct hlsl_deref *  deref,
unsigned int *  start,
unsigned int *  count 
)

Definition at line 5811 of file hlsl_codegen.c.

5813{
5814 struct hlsl_type *type = deref->var->data_type;
5815 unsigned int i, k;
5816
5817 *start = 0;
5818 *count = 0;
5819
5820 for (i = 0; i < deref->path_len; ++i)
5821 {
5822 struct hlsl_ir_node *path_node = deref->path[i].node;
5823 unsigned int idx = 0;
5824
5825 VKD3D_ASSERT(path_node);
5826 if (path_node->type != HLSL_IR_CONSTANT)
5827 return false;
5828
5829 /* We should always have generated a cast to UINT. */
5830 VKD3D_ASSERT(path_node->data_type->class == HLSL_CLASS_SCALAR
5831 && path_node->data_type->e.numeric.type == HLSL_TYPE_UINT);
5832
5833 idx = hlsl_ir_constant(path_node)->value.u[0].u;
5834
5835 switch (type->class)
5836 {
5837 case HLSL_CLASS_VECTOR:
5838 if (idx >= type->dimx)
5839 return false;
5840 *start += idx;
5841 break;
5842
5843 case HLSL_CLASS_MATRIX:
5845 return false;
5847 *start += idx * type->dimx;
5848 else
5849 *start += idx * type->dimy;
5850 break;
5851
5852 case HLSL_CLASS_ARRAY:
5853 if (idx >= type->e.array.elements_count)
5854 return false;
5855 *start += idx * hlsl_type_component_count(type->e.array.type);
5856 break;
5857
5858 case HLSL_CLASS_STRUCT:
5859 for (k = 0; k < idx; ++k)
5860 *start += hlsl_type_component_count(type->e.record.fields[k].type);
5861 break;
5862
5863 default:
5865 }
5866
5868 }
5869
5871 return true;
5872}
unsigned int idx
Definition: utils.c:40
GLuint start
Definition: gl.h:1545
unsigned int hlsl_type_component_count(const struct hlsl_type *type)
Definition: hlsl.c:1042
bool hlsl_type_is_row_major(const struct hlsl_type *type)
Definition: hlsl.c:186
struct hlsl_type * hlsl_get_element_type_from_path_index(struct hlsl_ctx *ctx, const struct hlsl_type *type, struct hlsl_ir_node *idx)
Definition: hlsl.c:848
unsigned int hlsl_type_major_size(const struct hlsl_type *type)
Definition: hlsl.c:201
int k
Definition: mpi.c:3369
struct hlsl_ir_var * var
Definition: hlsl.h:796
struct hlsl_ir_constant::hlsl_constant_value value
enum hlsl_ir_node_type type
Definition: hlsl.h:345
#define vkd3d_unreachable()
Definition: vkd3d_common.h:119

Referenced by copy_propagation_record_store(), copy_propagation_replace_with_constant_vector(), copy_propagation_replace_with_single_instr(), and copy_propagation_transform_object_load().

◆ hlsl_component_to_string()

struct vkd3d_string_buffer * hlsl_component_to_string ( struct hlsl_ctx *  ctx,
const struct hlsl_ir_var *  var,
unsigned int  index 
)

Definition at line 2864 of file hlsl.c.

2866{
2867 struct hlsl_type *type = var->data_type, *current_type;
2869 unsigned int element_index;
2870
2872 return NULL;
2873
2875
2877 {
2878 current_type = type;
2879 element_index = traverse_path_from_component_index(ctx, &type, &index);
2880 if (current_type->class == HLSL_CLASS_STRUCT)
2881 vkd3d_string_buffer_printf(buffer, ".%s", current_type->e.record.fields[element_index].name);
2882 else
2883 vkd3d_string_buffer_printf(buffer, "[%u]", element_index);
2884 }
2885
2886 return buffer;
2887}
GLuint index
Definition: glext.h:6031
static unsigned int traverse_path_from_component_index(struct hlsl_ctx *ctx, struct hlsl_type **type_ptr, unsigned int *index_ptr)
Definition: hlsl.c:540
static bool type_is_single_component(const struct hlsl_type *type)
Definition: hlsl.c:493

Referenced by sm4_get_extern_resources().

◆ hlsl_copy_deref()

bool hlsl_copy_deref ( struct hlsl_ctx *  ctx,
struct hlsl_deref *  deref,
const struct hlsl_deref *  other 
)

Definition at line 1388 of file hlsl.c.

1389{
1390 unsigned int i;
1391
1392 memset(deref, 0, sizeof(*deref));
1393
1394 if (!other)
1395 return true;
1396
1398
1399 if (!init_deref(ctx, deref, other->var, other->path_len))
1400 return false;
1401
1402 for (i = 0; i < deref->path_len; ++i)
1403 hlsl_src_from_node(&deref->path[i], other->path[i].node);
1404
1405 return true;
1406}
static bool init_deref(struct hlsl_ctx *ctx, struct hlsl_deref *deref, struct hlsl_ir_var *var, unsigned int path_len)
Definition: hlsl.c:692
static void hlsl_src_from_node(struct hlsl_src *src, struct hlsl_ir_node *node)
Definition: hlsl.h:1286
static bool hlsl_deref_is_lowered(const struct hlsl_deref *deref)
Definition: hlsl.h:822
int other
Definition: msacm.c:1376

Referenced by copy_propagation_transform_object_load(), hlsl_new_resource_store(), lower_combined_samples(), and lower_nonconstant_array_loads().

◆ hlsl_copy_propagation_execute()

bool hlsl_copy_propagation_execute ( struct hlsl_ctx *  ctx,
struct hlsl_block *  block 
)

Definition at line 2009 of file hlsl_codegen.c.

2010{
2012 bool progress;
2013
2015
2017
2019
2021
2022 return progress;
2023}
static int state
Definition: maze.c:121
cd_progress_ptr progress
Definition: cdjpeg.h:152
static void copy_propagation_state_destroy(struct copy_propagation_state *state)
static void copy_propagation_state_init(struct hlsl_ctx *ctx, struct copy_propagation_state *state, struct copy_propagation_state *parent)
static bool copy_propagation_transform_block(struct hlsl_ctx *ctx, struct hlsl_block *block, struct copy_propagation_state *state)
static unsigned int index_instructions(struct hlsl_block *block, unsigned int index)

Referenced by hlsl_run_const_passes().

◆ hlsl_deref_get_regset()

enum hlsl_regset hlsl_deref_get_regset ( struct hlsl_ctx *  ctx,
const struct hlsl_deref *  deref 
)

Definition at line 327 of file hlsl.c.

328{
330}
struct hlsl_type * hlsl_deref_get_type(struct hlsl_ctx *ctx, const struct hlsl_deref *deref)
Definition: hlsl.c:783
static enum hlsl_regset type_get_regset(const struct hlsl_type *type)
Definition: hlsl.c:299

Referenced by clean_constant_deref_offset_srcs(), hlsl_offset_from_deref(), lower_combined_samples(), new_offset_instr_from_deref(), register_deref_usage(), sm4_register_from_deref(), track_components_usage(), track_object_components_sampler_dim(), and write_sm4_ld().

◆ hlsl_deref_get_type()

struct hlsl_type * hlsl_deref_get_type ( struct hlsl_ctx *  ctx,
const struct hlsl_deref *  deref 
)

Definition at line 783 of file hlsl.c.

784{
785 struct hlsl_type *type;
786 unsigned int i;
787
788 VKD3D_ASSERT(deref);
789
790 if (hlsl_deref_is_lowered(deref))
791 return deref->data_type;
792
793 type = deref->var->data_type;
794 for (i = 0; i < deref->path_len; ++i)
796 return type;
797}
struct hlsl_type * data_type
Definition: hlsl.h:818

Referenced by hlsl_deref_get_regset(), hlsl_new_load_component(), hlsl_new_load_index(), hlsl_new_resource_load(), init_deref_from_component_index(), lower_combined_samples(), register_deref_usage(), replace_deref_path_with_offset(), sm4_register_from_deref(), write_sm4_ld(), and write_sm4_resource_store().

◆ hlsl_deref_is_lowered()

static bool hlsl_deref_is_lowered ( const struct hlsl_deref *  deref)
inlinestatic

◆ hlsl_dump_function()

void hlsl_dump_function ( struct hlsl_ctx *  ctx,
const struct hlsl_ir_function_decl *  func 
)

Definition at line 3573 of file hlsl.c.

3574{
3576 size_t i;
3577
3579 vkd3d_string_buffer_printf(&buffer, "Dumping function %s.\n", func->func->name);
3580 vkd3d_string_buffer_printf(&buffer, "Function parameters:\n");
3581 for (i = 0; i < func->parameters.count; ++i)
3582 {
3583 dump_ir_var(ctx, &buffer, func->parameters.vars[i]);
3585 }
3586 if (func->has_body)
3587 dump_block(ctx, &buffer, &func->body);
3588
3591}
static void dump_ir_var(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_ir_var *var)
Definition: hlsl.c:3015
static void dump_block(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_block *block)
Definition: hlsl.c:2996
void vkd3d_string_buffer_init(struct vkd3d_string_buffer *buffer)
void vkd3d_string_buffer_cleanup(struct vkd3d_string_buffer *buffer)
#define vkd3d_string_buffer_trace(buffer)

Referenced by dump_function().

◆ hlsl_dump_var_default_values()

void hlsl_dump_var_default_values ( const struct hlsl_ir_var *  var)

Definition at line 3593 of file hlsl.c.

3594{
3595 unsigned int k, component_count = hlsl_type_component_count(var->data_type);
3597
3599 if (!var->default_values)
3600 {
3601 vkd3d_string_buffer_printf(&buffer, "var \"%s\" has no default values.\n", var->name);
3604 return;
3605 }
3606
3607 vkd3d_string_buffer_printf(&buffer, "var \"%s\" default values:", var->name);
3608 for (k = 0; k < component_count; ++k)
3609 {
3610 bool is_string = var->default_values[k].string;
3611
3612 if (k % 4 == 0 || is_string)
3614
3615 if (is_string)
3616 vkd3d_string_buffer_printf(&buffer, " %s", debugstr_a(var->default_values[k].string));
3617 else
3618 vkd3d_string_buffer_printf(&buffer, " 0x%08x", var->default_values[k].number.u);
3619 }
3621
3624}
unsigned int component_count
static BOOL is_string(parse_buffer *buf)
Definition: parsing.c:581

◆ hlsl_emit_bytecode()

int hlsl_emit_bytecode ( struct hlsl_ctx *  ctx,
struct hlsl_ir_function_decl *  entry_func,
enum vkd3d_shader_target_type  target_type,
struct vkd3d_shader_code *  out 
)

Definition at line 9202 of file hlsl_codegen.c.

9204{
9205 const struct hlsl_profile_info *profile = ctx->profile;
9206 struct hlsl_block global_uniform_block;
9207 struct hlsl_ir_var *var;
9208
9210 if (ctx->result)
9211 return ctx->result;
9212
9213 if (profile->type == VKD3D_SHADER_TYPE_HULL)
9215 else if (profile->type == VKD3D_SHADER_TYPE_COMPUTE && !ctx->found_numthreads)
9217 "Entry point \"%s\" is missing a [numthreads] attribute.", entry_func->func->name);
9220 "Entry point \"%s\" is missing a [domain] attribute.", entry_func->func->name);
9221
9222 hlsl_block_init(&global_uniform_block);
9223
9224 LIST_FOR_EACH_ENTRY(var, &ctx->globals->vars, struct hlsl_ir_var, scope_entry)
9225 {
9226 if (var->storage_modifiers & HLSL_STORAGE_UNIFORM)
9227 prepend_uniform_copy(ctx, &global_uniform_block, var);
9228 }
9229
9230 process_entry_function(ctx, &global_uniform_block, entry_func);
9231 if (ctx->result)
9232 return ctx->result;
9233
9234 if (profile->type == VKD3D_SHADER_TYPE_HULL)
9235 {
9236 process_entry_function(ctx, &global_uniform_block, ctx->patch_constant_func);
9237 if (ctx->result)
9238 return ctx->result;
9239 }
9240
9241 hlsl_block_cleanup(&global_uniform_block);
9242
9243 if (profile->major_version < 4)
9244 {
9245 mark_indexable_vars(ctx, entry_func);
9246 allocate_temp_registers(ctx, entry_func);
9247 allocate_const_registers(ctx, entry_func);
9248 }
9249 else
9250 {
9254 }
9256
9257 if (TRACE_ON())
9258 rb_for_each_entry(&ctx->functions, dump_function, ctx);
9259
9260 if (ctx->result)
9261 return ctx->result;
9262
9263 switch (target_type)
9264 {
9266 {
9268 struct vkd3d_shader_code ctab = {0};
9269 struct vsir_program program;
9270 int result;
9271
9272 sm1_generate_vsir(ctx, entry_func, config_flags, &program, &ctab);
9273 if (ctx->result)
9274 {
9277 return ctx->result;
9278 }
9279
9280 result = d3dbc_compile(&program, config_flags, NULL, &ctab, out, ctx->message_context);
9283 return result;
9284 }
9285
9287 {
9289 struct vsir_program program;
9290 int result;
9291
9292 sm4_generate_vsir(ctx, entry_func, config_flags, &program);
9293 if (ctx->result)
9294 {
9296 return ctx->result;
9297 }
9298
9299 result = tpf_compile(&program, config_flags, out, ctx->message_context, ctx, entry_func);
9301 return result;
9302 }
9303
9304 default:
9305 ERR("Unsupported shader target type %#x.\n", target_type);
9307 }
9308}
int d3dbc_compile(struct vsir_program *program, uint64_t config_flags, const struct vkd3d_shader_compile_info *compile_info, const struct vkd3d_shader_code *ctab, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
Definition: d3dbc.c:2359
#define TRACE_ON(x)
Definition: compat.h:75
void hlsl_block_cleanup(struct hlsl_block *block)
Definition: hlsl.c:3675
void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_error error, const char *fmt,...)
Definition: hlsl.c:35
#define HLSL_STORAGE_UNIFORM
Definition: hlsl.h:403
int tpf_compile(struct vsir_program *program, uint64_t config_flags, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context, struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func)
Definition: tpf.c:6046
static void allocate_objects(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *func, enum hlsl_regset regset)
static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_var *temp)
Definition: hlsl_codegen.c:204
static void process_entry_function(struct hlsl_ctx *ctx, const struct hlsl_block *global_uniform_block, struct hlsl_ir_function_decl *entry_func)
static void dump_function(struct rb_entry *entry, void *context)
static void validate_hull_shader_attributes(struct hlsl_ctx *ctx, const struct hlsl_ir_function_decl *entry_func)
static void sm1_generate_vsir(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func, uint64_t config_flags, struct vsir_program *program, struct vkd3d_shader_code *ctab)
static void allocate_const_registers(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func)
static void sm4_generate_vsir(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *func, uint64_t config_flags, struct vsir_program *program)
static void mark_indexable_vars(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func)
static void allocate_buffers(struct hlsl_ctx *ctx)
static void parse_entry_function_attributes(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func)
static uint32_t allocate_temp_registers(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func)
void vsir_program_cleanup(struct vsir_program *program)
Definition: ir.c:105
#define profile
Definition: kernel32.h:12
static const char * target_type(DWORD dwType)
Definition: mixer.c:95
static void rb_for_each_entry(struct rb_tree *tree, rb_traverse_func_t *callback, void *context)
Definition: rbtree.h:179
struct vkd3d_shader_location loc
Definition: hlsl.h:603
VKD3D_SHADER_API void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code)
@ VKD3D_SHADER_TARGET_DXBC_TPF
@ VKD3D_SHADER_TARGET_D3D_BYTECODE
uint64_t vkd3d_shader_init_config_flags(void)
@ VKD3D_SHADER_TYPE_HULL
@ VKD3D_SHADER_TYPE_COMPUTE
@ VKD3D_SHADER_TYPE_DOMAIN
@ VKD3D_SHADER_ERROR_HLSL_MISSING_ATTRIBUTE
@ VKD3D_TESSELLATOR_DOMAIN_INVALID
@ VKD3D_ERROR_INVALID_ARGUMENT
Definition: vkd3d_types.h:51

Referenced by hlsl_compile_shader().

◆ hlsl_emit_effect_binary()

int hlsl_emit_effect_binary ( struct hlsl_ctx *  ctx,
struct vkd3d_shader_code *  out 
)

Definition at line 2865 of file fx.c.

2866{
2867 if (ctx->profile->major_version == 2)
2868 {
2869 return hlsl_fx_2_write(ctx, out);
2870 }
2871 else if (ctx->profile->major_version == 4)
2872 {
2873 return hlsl_fx_4_write(ctx, out);
2874 }
2875 else if (ctx->profile->major_version == 5)
2876 {
2877 return hlsl_fx_5_write(ctx, out);
2878 }
2879 else
2880 {
2882 }
2883}
static int hlsl_fx_2_write(struct hlsl_ctx *ctx, struct vkd3d_shader_code *out)
Definition: fx.c:1362
static int hlsl_fx_5_write(struct hlsl_ctx *ctx, struct vkd3d_shader_code *out)
Definition: fx.c:2802
static int hlsl_fx_4_write(struct hlsl_ctx *ctx, struct vkd3d_shader_code *out)
Definition: fx.c:2743

Referenced by hlsl_compile_shader().

◆ hlsl_error()

void hlsl_error ( struct hlsl_ctx *  ctx,
const struct vkd3d_shader_location *  loc,
enum vkd3d_shader_error  error,
const char *  fmt,
  ... 
)

◆ hlsl_fixme()

void void hlsl_fixme ( struct hlsl_ctx *  ctx,
const struct vkd3d_shader_location *  loc,
const char *  fmt,
  ... 
)

◆ hlsl_fold_constant_exprs()

bool hlsl_fold_constant_exprs ( struct hlsl_ctx *  ctx,
struct hlsl_ir_node *  instr,
void *  context 
)

Definition at line 1218 of file hlsl_constant_ops.c.

1219{
1220 struct hlsl_ir_constant *arg1, *arg2 = NULL, *arg3 = NULL;
1221 struct hlsl_constant_value res = {0};
1222 struct hlsl_ir_node *res_node;
1223 struct hlsl_ir_expr *expr;
1224 unsigned int i;
1225 bool success;
1226
1227 if (instr->type != HLSL_IR_EXPR)
1228 return false;
1229 expr = hlsl_ir_expr(instr);
1230 if (!expr->operands[0].node)
1231 return false;
1232
1233 if (instr->data_type->class > HLSL_CLASS_VECTOR)
1234 return false;
1235
1236 for (i = 0; i < ARRAY_SIZE(expr->operands); ++i)
1237 {
1238 if (expr->operands[i].node)
1239 {
1240 if (expr->operands[i].node->type != HLSL_IR_CONSTANT)
1241 return false;
1242 VKD3D_ASSERT(expr->operands[i].node->data_type->class <= HLSL_CLASS_VECTOR);
1243 }
1244 }
1245 arg1 = hlsl_ir_constant(expr->operands[0].node);
1246 if (expr->operands[1].node)
1247 arg2 = hlsl_ir_constant(expr->operands[1].node);
1248 if (expr->operands[2].node)
1249 arg3 = hlsl_ir_constant(expr->operands[2].node);
1250
1251 switch (expr->op)
1252 {
1253 case HLSL_OP1_ABS:
1254 success = fold_abs(ctx, &res, instr->data_type, arg1);
1255 break;
1256
1257 case HLSL_OP1_BIT_NOT:
1258 success = fold_bit_not(ctx, &res, instr->data_type, arg1);
1259 break;
1260
1261 case HLSL_OP1_CAST:
1262 success = fold_cast(ctx, &res, instr->data_type, arg1);
1263 break;
1264
1265 case HLSL_OP1_CEIL:
1266 success = fold_ceil(ctx, &res, instr->data_type, arg1);
1267 break;
1268
1269 case HLSL_OP1_EXP2:
1270 success = fold_exp2(ctx, &res, instr->data_type, arg1);
1271 break;
1272
1273 case HLSL_OP1_FLOOR:
1274 success = fold_floor(ctx, &res, instr->data_type, arg1);
1275 break;
1276
1277 case HLSL_OP1_FRACT:
1278 success = fold_fract(ctx, &res, instr->data_type, arg1);
1279 break;
1280
1281 case HLSL_OP1_LOG2:
1282 success = fold_log2(ctx, &res, instr->data_type, arg1, &instr->loc);
1283 break;
1284
1285 case HLSL_OP1_NEG:
1286 success = fold_neg(ctx, &res, instr->data_type, arg1);
1287 break;
1288
1289 case HLSL_OP1_LOGIC_NOT:
1290 success = fold_not(ctx, &res, instr->data_type, arg1);
1291 break;
1292
1293 case HLSL_OP1_RCP:
1294 success = fold_rcp(ctx, &res, instr->data_type, arg1, &instr->loc);
1295 break;
1296
1297 case HLSL_OP1_RSQ:
1298 success = fold_rsq(ctx, &res, instr->data_type, arg1, &instr->loc);
1299 break;
1300
1301 case HLSL_OP1_SAT:
1302 success = fold_sat(ctx, &res, instr->data_type, arg1);
1303 break;
1304
1305 case HLSL_OP1_SQRT:
1306 success = fold_sqrt(ctx, &res, instr->data_type, arg1, &instr->loc);
1307 break;
1308
1309 case HLSL_OP2_ADD:
1310 success = fold_add(ctx, &res, instr->data_type, arg1, arg2);
1311 break;
1312
1313 case HLSL_OP2_BIT_AND:
1314 case HLSL_OP2_LOGIC_AND:
1315 success = fold_and(ctx, &res, instr->data_type, arg1, arg2);
1316 break;
1317
1318 case HLSL_OP2_BIT_OR:
1319 case HLSL_OP2_LOGIC_OR:
1320 success = fold_or(ctx, &res, instr->data_type, arg1, arg2);
1321 break;
1322
1323 case HLSL_OP2_BIT_XOR:
1324 success = fold_bit_xor(ctx, &res, instr->data_type, arg1, arg2);
1325 break;
1326
1327 case HLSL_OP2_DOT:
1328 success = fold_dot(ctx, &res, instr->data_type, arg1, arg2);
1329 break;
1330
1331 case HLSL_OP2_DIV:
1332 success = fold_div(ctx, &res, instr->data_type, arg1, arg2, &instr->loc);
1333 break;
1334
1335 case HLSL_OP2_EQUAL:
1336 success = fold_equal(ctx, &res, instr->data_type, arg1, arg2);
1337 break;
1338
1339 case HLSL_OP2_GEQUAL:
1340 success = fold_gequal(ctx, &res, instr->data_type, arg1, arg2);
1341 break;
1342
1343 case HLSL_OP2_LESS:
1344 success = fold_less(ctx, &res, instr->data_type, arg1, arg2);
1345 break;
1346
1347 case HLSL_OP2_LSHIFT:
1348 success = fold_lshift(ctx, &res, instr->data_type, arg1, arg2);
1349 break;
1350
1351 case HLSL_OP2_MAX:
1352 success = fold_max(ctx, &res, instr->data_type, arg1, arg2);
1353 break;
1354
1355 case HLSL_OP2_MIN:
1356 success = fold_min(ctx, &res, instr->data_type, arg1, arg2);
1357 break;
1358
1359 case HLSL_OP2_MOD:
1360 success = fold_mod(ctx, &res, instr->data_type, arg1, arg2, &instr->loc);
1361 break;
1362
1363 case HLSL_OP2_MUL:
1364 success = fold_mul(ctx, &res, instr->data_type, arg1, arg2);
1365 break;
1366
1367 case HLSL_OP2_NEQUAL:
1368 success = fold_nequal(ctx, &res, instr->data_type, arg1, arg2);
1369 break;
1370
1371 case HLSL_OP2_RSHIFT:
1372 success = fold_rshift(ctx, &res, instr->data_type, arg1, arg2);
1373 break;
1374
1375 case HLSL_OP3_DP2ADD:
1376 success = fold_dp2add(ctx, &res, instr->data_type, arg1, arg2, arg3);
1377 break;
1378
1379 case HLSL_OP3_TERNARY:
1381 break;
1382
1383 default:
1384 FIXME("Fold \"%s\" expression.\n", debug_hlsl_expr_op(expr->op));
1385 success = false;
1386 break;
1387 }
1388
1389 if (success)
1390 {
1391 if (!(res_node = hlsl_new_constant(ctx, instr->data_type, &res, &instr->loc)))
1392 return false;
1393 list_add_before(&expr->node.entry, &res_node->entry);
1394 hlsl_replace_node(&expr->node, res_node);
1395 }
1396 return success;
1397}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
GLuint res
Definition: glext.h:9613
GLuint GLuint GLuint GLuint arg1
Definition: glext.h:9513
GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg3
Definition: glext.h:9515
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
Definition: glext.h:9514
struct hlsl_ir_node * hlsl_new_constant(struct hlsl_ctx *ctx, struct hlsl_type *type, const struct hlsl_constant_value *value, const struct vkd3d_shader_location *loc)
Definition: hlsl.c:1521
void hlsl_replace_node(struct hlsl_ir_node *old, struct hlsl_ir_node *new)
Definition: hlsl.c:3626
const char * debug_hlsl_expr_op(enum hlsl_ir_expr_op op)
Definition: hlsl.c:3176
static bool fold_rsq(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src, const struct vkd3d_shader_location *loc)
static bool fold_equal(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2)
static bool fold_nequal(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2)
static bool fold_lshift(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2)
static bool fold_floor(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src)
static bool fold_rshift(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2)
static bool fold_ceil(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src)
static bool fold_bit_xor(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2)
static bool fold_sqrt(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src, const struct vkd3d_shader_location *loc)
static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src)
static bool fold_not(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src)
static bool fold_fract(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src)
static bool fold_mod(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2, const struct vkd3d_shader_location *loc)
static bool fold_min(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2)
static bool fold_sat(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src)
static bool fold_ternary(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2, const struct hlsl_ir_constant *src3)
static bool fold_dp2add(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2, const struct hlsl_ir_constant *src3)
static bool fold_gequal(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2)
static bool fold_less(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2)
static bool fold_bit_not(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src)
static bool fold_max(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2)
static bool fold_mul(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2)
static bool fold_div(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2, const struct vkd3d_shader_location *loc)
static bool fold_log2(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src, const struct vkd3d_shader_location *loc)
static bool fold_dot(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2)
static bool fold_neg(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src)
static bool fold_and(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2)
static bool fold_or(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2)
static bool fold_add(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2)
static bool fold_exp2(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src)
static bool fold_rcp(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src, const struct vkd3d_shader_location *loc)
static bool fold_abs(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src)
__WINE_SERVER_LIST_INLINE void list_add_before(struct list *elem, struct list *to_add)
Definition: list.h:89
Definition: query.h:86
int type
Definition: query.h:87
struct vkd3d_shader_location loc
Definition: hlsl.h:355
#define success(from, fromstr, to, tostr)

Referenced by hlsl_run_const_passes(), and process_entry_function().

◆ hlsl_fold_constant_identities()

bool hlsl_fold_constant_identities ( struct hlsl_ctx *  ctx,
struct hlsl_ir_node *  instr,
void *  context 
)

Definition at line 1471 of file hlsl_constant_ops.c.

1472{
1473 struct hlsl_ir_constant *const_arg = NULL;
1474 struct hlsl_ir_node *mut_arg = NULL;
1475 struct hlsl_ir_node *res_node;
1476 struct hlsl_ir_expr *expr;
1477 unsigned int i;
1478
1479 if (instr->type != HLSL_IR_EXPR)
1480 return false;
1481 expr = hlsl_ir_expr(instr);
1482
1483 if (instr->data_type->class > HLSL_CLASS_VECTOR)
1484 return false;
1485
1486 /* Verify that the expression has two operands. */
1487 for (i = 0; i < ARRAY_SIZE(expr->operands); ++i)
1488 {
1489 if (!!expr->operands[i].node != (i < 2))
1490 return false;
1491 }
1492
1493 if (expr->operands[0].node->type == HLSL_IR_CONSTANT)
1494 {
1495 const_arg = hlsl_ir_constant(expr->operands[0].node);
1496 mut_arg = expr->operands[1].node;
1497 }
1498 else if (expr->operands[1].node->type == HLSL_IR_CONSTANT)
1499 {
1500 mut_arg = expr->operands[0].node;
1501 const_arg = hlsl_ir_constant(expr->operands[1].node);
1502 }
1503 else
1504 {
1505 return false;
1506 }
1507
1508 res_node = NULL;
1509 switch (expr->op)
1510 {
1511 case HLSL_OP2_ADD:
1512 if (constant_is_zero(const_arg))
1513 res_node = mut_arg;
1514 break;
1515
1516 case HLSL_OP2_MUL:
1517 if (constant_is_one(const_arg))
1518 res_node = mut_arg;
1519 break;
1520
1521 case HLSL_OP2_LOGIC_AND:
1522 if (constant_is_zero(const_arg))
1523 res_node = &const_arg->node;
1524 else if (constant_is_one(const_arg))
1525 res_node = mut_arg;
1526 break;
1527
1528 case HLSL_OP2_LOGIC_OR:
1529 if (constant_is_zero(const_arg))
1530 res_node = mut_arg;
1531 else if (constant_is_one(const_arg))
1532 res_node = &const_arg->node;
1533 break;
1534
1535 default:
1536 break;
1537 }
1538
1539 if (res_node)
1540 {
1541 hlsl_replace_node(&expr->node, res_node);
1542 return true;
1543 }
1544 return false;
1545}
static bool constant_is_one(struct hlsl_ir_constant *const_arg)
static bool constant_is_zero(struct hlsl_ir_constant *const_arg)
struct hlsl_ir_node node
Definition: hlsl.h:877

Referenced by hlsl_run_const_passes().

◆ hlsl_fold_constant_swizzles()

bool hlsl_fold_constant_swizzles ( struct hlsl_ctx *  ctx,
struct hlsl_ir_node *  instr,
void *  context 
)

Definition at line 1547 of file hlsl_constant_ops.c.

1548{
1549 struct hlsl_constant_value value;
1550 struct hlsl_ir_swizzle *swizzle;
1551 struct hlsl_ir_constant *src;
1552 struct hlsl_ir_node *dst;
1553 unsigned int i;
1554
1555 if (instr->type != HLSL_IR_SWIZZLE)
1556 return false;
1557 swizzle = hlsl_ir_swizzle(instr);
1558 if (swizzle->val.node->type != HLSL_IR_CONSTANT)
1559 return false;
1560 src = hlsl_ir_constant(swizzle->val.node);
1561
1562 for (i = 0; i < swizzle->node.data_type->dimx; ++i)
1563 value.u[i] = src->value.u[hlsl_swizzle_get_component(swizzle->swizzle, i)];
1564
1565 if (!(dst = hlsl_new_constant(ctx, instr->data_type, &value, &instr->loc)))
1566 return false;
1567
1568 list_add_before(&swizzle->node.entry, &dst->entry);
1569 hlsl_replace_node(&swizzle->node, dst);
1570 return true;
1571}
GLuint GLenum swizzle
Definition: glext.h:9511
Definition: pdh_main.c:64

Referenced by hlsl_run_const_passes().

◆ hlsl_free_attribute()

void hlsl_free_attribute ( struct hlsl_attribute *  attr)

Definition at line 3885 of file hlsl.c.

3886{
3887 unsigned int i;
3888
3889 for (i = 0; i < attr->args_count; ++i)
3890 hlsl_src_remove(&attr->args[i]);
3891 hlsl_block_cleanup(&attr->instrs);
3892 vkd3d_free((void *)attr->name);
3894}
Definition: cookie.c:202
WCHAR * name
Definition: cookie.c:203

Referenced by free_function_decl().

◆ hlsl_free_instr()

void hlsl_free_instr ( struct hlsl_ir_node *  node)

Definition at line 3805 of file hlsl.c.

3806{
3807 VKD3D_ASSERT(list_empty(&node->uses));
3808
3809 switch (node->type)
3810 {
3811 case HLSL_IR_CALL:
3813 break;
3814
3815 case HLSL_IR_CONSTANT:
3817 break;
3818
3819 case HLSL_IR_EXPR:
3821 break;
3822
3823 case HLSL_IR_IF:
3825 break;
3826
3827 case HLSL_IR_INDEX:
3829 break;
3830
3831 case HLSL_IR_JUMP:
3833 break;
3834
3835 case HLSL_IR_LOAD:
3837 break;
3838
3839 case HLSL_IR_LOOP:
3841 break;
3842
3845 break;
3846
3849 break;
3850
3853 break;
3854
3855 case HLSL_IR_STORE:
3857 break;
3858
3859 case HLSL_IR_SWIZZLE:
3861 break;
3862
3863 case HLSL_IR_SWITCH:
3865 break;
3866
3867 case HLSL_IR_COMPILE:
3869 break;
3870
3873 break;
3874
3877 break;
3878
3881 break;
3882 }
3883}
static int list_empty(struct list_entry *head)
Definition: list.h:58
static void free_ir_loop(struct hlsl_ir_loop *loop)
Definition: hlsl.c:3719
static void free_ir_jump(struct hlsl_ir_jump *jump)
Definition: hlsl.c:3707
static void free_ir_compile(struct hlsl_ir_compile *compile)
Definition: hlsl.c:3781
static void free_ir_index(struct hlsl_ir_index *index)
Definition: hlsl.c:3774
static void free_ir_string_constant(struct hlsl_ir_string_constant *string)
Definition: hlsl.c:3739
static void free_ir_constant(struct hlsl_ir_constant *constant)
Definition: hlsl.c:3685
static void free_ir_load(struct hlsl_ir_load *load)
Definition: hlsl.c:3713
static void free_ir_resource_store(struct hlsl_ir_resource_store *store)
Definition: hlsl.c:3745
static void free_ir_swizzle(struct hlsl_ir_swizzle *swizzle)
Definition: hlsl.c:3760
static void free_ir_expr(struct hlsl_ir_expr *expr)
Definition: hlsl.c:3690
static void free_ir_resource_load(struct hlsl_ir_resource_load *load)
Definition: hlsl.c:3725
static void free_ir_call(struct hlsl_ir_call *call)
Definition: hlsl.c:3680
static void free_ir_switch(struct hlsl_ir_switch *s)
Definition: hlsl.c:3766
static void free_ir_stateblock_constant(struct hlsl_ir_stateblock_constant *constant)
Definition: hlsl.c:3799
static void free_ir_if(struct hlsl_ir_if *if_node)
Definition: hlsl.c:3699
static void free_ir_sampler_state(struct hlsl_ir_sampler_state *sampler_state)
Definition: hlsl.c:3792
static void free_ir_store(struct hlsl_ir_store *store)
Definition: hlsl.c:3753
Definition: dlist.c:348

Referenced by dce(), hlsl_free_instr_list(), hlsl_new_sampler_state(), hlsl_new_string_constant(), hlsl_replace_node(), loop_unrolling_unroll_loop(), lower_calls(), lower_return(), remove_trivial_conditional_branches(), split_array_copies(), split_matrix_copies(), and split_struct_copies().

◆ hlsl_free_instr_list()

void hlsl_free_instr_list ( struct list *  list)

Definition at line 3663 of file hlsl.c.

3664{
3665 struct hlsl_ir_node *node, *next_node;
3666
3667 if (!list)
3668 return;
3669 /* Iterate in reverse, to avoid use-after-free when unlinking sources from
3670 * the "uses" list. */
3673}
Definition: list.h:39
BOOL next_node(stream_t *stream, strbuf_t *buf)
Definition: stream.c:140
void hlsl_free_instr(struct hlsl_ir_node *node)
Definition: hlsl.c:3805
#define LIST_FOR_EACH_ENTRY_SAFE_REV(cursor, cursor2, list, type, field)
Definition: list.h:266

Referenced by hlsl_block_cleanup().

◆ hlsl_free_ir_switch_case()

void hlsl_free_ir_switch_case ( struct hlsl_ir_switch_case *  c)

Definition at line 2429 of file hlsl.c.

2430{
2431 hlsl_block_cleanup(&c->body);
2432 list_remove(&c->entry);
2433 vkd3d_free(c);
2434}
static void list_remove(struct list_entry *entry)
Definition: list.h:90

Referenced by hlsl_cleanup_ir_switch_cases(), and normalize_switch_cases().

◆ hlsl_free_state_block()

void hlsl_free_state_block ( struct hlsl_state_block *  state_block)

Definition at line 150 of file hlsl.c.

151{
152 unsigned int k;
153
154 VKD3D_ASSERT(state_block);
155 for (k = 0; k < state_block->count; ++k)
157 vkd3d_free(state_block->entries);
158 vkd3d_free(state_block);
159}
size_t count
Definition: hlsl.h:576
struct hlsl_state_block_entry ** entries
Definition: hlsl.h:575

Referenced by free_ir_sampler_state(), hlsl_ctx_cleanup(), and hlsl_free_var().

◆ hlsl_free_state_block_entry()

void hlsl_free_state_block_entry ( struct hlsl_state_block_entry *  state_block_entry)

Definition at line 137 of file hlsl.c.

138{
139 unsigned int i;
140
141 vkd3d_free(entry->name);
142 for (i = 0; i < entry->args_count; ++i)
143 hlsl_src_remove(&entry->args[i]);
144 vkd3d_free(entry->args);
145 hlsl_block_cleanup(entry->instrs);
146 vkd3d_free(entry->instrs);
148}

Referenced by clone_stateblock_entry(), decompose_fx_4_state_function_call(), and hlsl_free_state_block().

◆ hlsl_free_type()

void hlsl_free_type ( struct hlsl_type *  type)

Definition at line 3643 of file hlsl.c.

3644{
3645 struct hlsl_struct_field *field;
3646 size_t i;
3647
3648 vkd3d_free((void *)type->name);
3649 if (type->class == HLSL_CLASS_STRUCT)
3650 {
3651 for (i = 0; i < type->e.record.field_count; ++i)
3652 {
3653 field = &type->e.record.fields[i];
3654
3655 vkd3d_free((void *)field->name);
3656 hlsl_cleanup_semantic(&field->semantic);
3657 }
3658 vkd3d_free((void *)type->e.record.fields);
3659 }
3661}
Definition: parser.c:44

Referenced by hlsl_ctx_cleanup().

◆ hlsl_free_var()

void hlsl_free_var ( struct hlsl_ir_var *  decl)

Definition at line 161 of file hlsl.c.

162{
163 unsigned int k, i;
164
165 vkd3d_free((void *)decl->name);
167 for (k = 0; k <= HLSL_REGSET_LAST_OBJECT; ++k)
168 vkd3d_free((void *)decl->objects_usage[k]);
169
170 if (decl->default_values)
171 {
173
174 for (k = 0; k < component_count; ++k)
175 vkd3d_free((void *)decl->default_values[k].string);
177 }
178
179 for (i = 0; i < decl->state_block_count; ++i)
182
183 vkd3d_free(decl);
184}
void hlsl_free_state_block(struct hlsl_state_block *state_block)
Definition: hlsl.c:150
struct hlsl_ir_var::hlsl_default_value * default_values
struct hlsl_semantic semantic
Definition: hlsl.h:457
struct hlsl_ir_var::@6002 * objects_usage[HLSL_REGSET_LAST_OBJECT+1]
struct hlsl_type * data_type
Definition: hlsl.h:454
unsigned int state_block_count
Definition: hlsl.h:490
struct hlsl_state_block ** state_blocks
Definition: hlsl.h:489

Referenced by hlsl_ctx_cleanup().

◆ hlsl_get_element_type_from_path_index()

struct hlsl_type * hlsl_get_element_type_from_path_index ( struct hlsl_ctx *  ctx,
const struct hlsl_type *  type,
struct hlsl_ir_node *  idx 
)

Definition at line 848 of file hlsl.c.

850{
852
853 switch (type->class)
854 {
856 return hlsl_get_scalar_type(ctx, type->e.numeric.type);
857
860 return hlsl_get_vector_type(ctx, type->e.numeric.type, type->dimx);
861 else
862 return hlsl_get_vector_type(ctx, type->e.numeric.type, type->dimy);
863
864 case HLSL_CLASS_ARRAY:
865 return type->e.array.type;
866
868 {
870
871 VKD3D_ASSERT(c->value.u[0].u < type->e.record.field_count);
872 return type->e.record.fields[c->value.u[0].u].type;
873 }
874
875 default:
877 }
878}
static struct hlsl_type * hlsl_get_vector_type(const struct hlsl_ctx *ctx, enum hlsl_base_type base_type, unsigned int dimx)
Definition: hlsl.h:1365
static struct hlsl_type * hlsl_get_scalar_type(const struct hlsl_ctx *ctx, enum hlsl_base_type base_type)
Definition: hlsl.h:1360

Referenced by copy_propagation_invalidate_variable_from_deref_recurse(), hlsl_component_index_range_from_deref(), hlsl_deref_get_type(), hlsl_new_index(), hlsl_new_load_index(), hlsl_regset_index_from_deref(), lower_nonconstant_array_loads(), lower_nonconstant_vector_derefs(), new_offset_instr_from_deref(), validate_component_index_range_from_deref(), and validate_nonconstant_vector_store_derefs().

◆ hlsl_get_first_func_decl()

struct hlsl_ir_function_decl * hlsl_get_first_func_decl ( struct hlsl_ctx *  ctx,
const char *  name 
)

Definition at line 1028 of file hlsl.c.

1029{
1030 struct hlsl_ir_function *func;
1031 struct rb_entry *entry;
1032
1033 if ((entry = rb_get(&ctx->functions, name)))
1034 {
1036 return LIST_ENTRY(list_head(&func->overloads), struct hlsl_ir_function_decl, entry);
1037 }
1038
1039 return NULL;
1040}
Definition: list.h:15
#define LIST_ENTRY(type)
Definition: queue.h:175

Referenced by hlsl_compile_internal_function().

◆ hlsl_get_func_decl()

struct hlsl_ir_function_decl * hlsl_get_func_decl ( struct hlsl_ctx *  ctx,
const char *  name,
const struct hlsl_func_parameters *  parameters 
)

Definition at line 2678 of file hlsl.c.

2680{
2681 struct hlsl_ir_function_decl *decl;
2682 struct hlsl_ir_function *func;
2683
2684 if (!(func = hlsl_get_function(ctx, name)))
2685 return NULL;
2686
2687 LIST_FOR_EACH_ENTRY(decl, &func->overloads, struct hlsl_ir_function_decl, entry)
2688 {
2689 if (func_decl_matches(decl, parameters))
2690 return decl;
2691 }
2692
2693 return NULL;
2694}
static bool func_decl_matches(const struct hlsl_ir_function_decl *decl, const struct hlsl_func_parameters *parameters)
Definition: hlsl.c:2662
struct hlsl_ir_function * hlsl_get_function(struct hlsl_ctx *ctx, const char *name)
Definition: hlsl.c:1019
static BYTE parameters[]
Definition: asn.c:558

◆ hlsl_get_function()

struct hlsl_ir_function * hlsl_get_function ( struct hlsl_ctx *  ctx,
const char *  name 
)

Definition at line 1019 of file hlsl.c.

1020{
1021 struct rb_entry *entry;
1022
1023 if ((entry = rb_get(&ctx->functions, name)))
1024 return RB_ENTRY_VALUE(entry, struct hlsl_ir_function, entry);
1025 return NULL;
1026}

Referenced by hlsl_compile_shader(), hlsl_get_func_decl(), and parse_patchconstantfunc_attribute().

◆ hlsl_get_matrix_type()

static struct hlsl_type * hlsl_get_matrix_type ( const struct hlsl_ctx *  ctx,
enum hlsl_base_type  base_type,
unsigned int  dimx,
unsigned int  dimy 
)
inlinestatic

Definition at line 1371 of file hlsl.h.

1373{
1374 return ctx->builtin_types.matrix[base_type][dimx - 1][dimy - 1];
1375}

Referenced by hlsl_get_numeric_type().

◆ hlsl_get_multiarray_element_type()

◆ hlsl_get_multiarray_size()

◆ hlsl_get_numeric_type()

static struct hlsl_type * hlsl_get_numeric_type ( const struct hlsl_ctx *  ctx,
enum hlsl_type_class  type,
enum hlsl_base_type  base_type,
unsigned int  dimx,
unsigned int  dimy 
)
inlinestatic

Definition at line 1377 of file hlsl.h.

1379{
1380 if (type == HLSL_CLASS_SCALAR)
1381 return hlsl_get_scalar_type(ctx, base_type);
1382 else if (type == HLSL_CLASS_VECTOR)
1383 return hlsl_get_vector_type(ctx, base_type, dimx);
1384 else
1385 return hlsl_get_matrix_type(ctx, base_type, dimx, dimy);
1386}
static struct hlsl_type * hlsl_get_matrix_type(const struct hlsl_ctx *ctx, enum hlsl_base_type base_type, unsigned int dimx, unsigned int dimy)
Definition: hlsl.h:1371

Referenced by hlsl_add_conditional(), lower_discard_neg(), lower_float_modulus(), lower_int_division(), lower_int_modulus(), and lower_ternary().

◆ hlsl_get_scalar_type()

◆ hlsl_get_string_buffer()

static struct vkd3d_string_buffer * hlsl_get_string_buffer ( struct hlsl_ctx *  ctx)
inlinestatic

Definition at line 1346 of file hlsl.h.

1347{
1348 struct vkd3d_string_buffer *ret = vkd3d_string_buffer_get(&ctx->string_buffers);
1349
1350 if (!ret)
1352 return ret;
1353}
struct vkd3d_string_buffer * vkd3d_string_buffer_get(struct vkd3d_string_buffer_cache *cache)

Referenced by declare_predefined_types(), hlsl_compile_internal_function(), hlsl_component_to_string(), hlsl_fixme(), hlsl_modifiers_to_string(), hlsl_new_synthetic_var(), hlsl_sprintf_alloc(), hlsl_type_to_string(), and lower_combined_samples().

◆ hlsl_get_target_info()

const struct hlsl_profile_info * hlsl_get_target_info ( const char *  target)

Definition at line 4054 of file hlsl.c.

4055{
4056 unsigned int i;
4057
4058 static const struct hlsl_profile_info profiles[] =
4059 {
4060 {"cs_4_0", VKD3D_SHADER_TYPE_COMPUTE, 4, 0, 0, 0, false},
4061 {"cs_4_1", VKD3D_SHADER_TYPE_COMPUTE, 4, 1, 0, 0, false},
4062 {"cs_5_0", VKD3D_SHADER_TYPE_COMPUTE, 5, 0, 0, 0, false},
4063 {"cs_5_1", VKD3D_SHADER_TYPE_COMPUTE, 5, 1, 0, 0, false},
4064 {"ds_5_0", VKD3D_SHADER_TYPE_DOMAIN, 5, 0, 0, 0, false},
4065 {"ds_5_1", VKD3D_SHADER_TYPE_DOMAIN, 5, 1, 0, 0, false},
4066 {"fx_2_0", VKD3D_SHADER_TYPE_EFFECT, 2, 0, 0, 0, false},
4067 {"fx_4_0", VKD3D_SHADER_TYPE_EFFECT, 4, 0, 0, 0, false},
4068 {"fx_4_1", VKD3D_SHADER_TYPE_EFFECT, 4, 1, 0, 0, false},
4069 {"fx_5_0", VKD3D_SHADER_TYPE_EFFECT, 5, 0, 0, 0, false},
4070 {"gs_4_0", VKD3D_SHADER_TYPE_GEOMETRY, 4, 0, 0, 0, false},
4071 {"gs_4_1", VKD3D_SHADER_TYPE_GEOMETRY, 4, 1, 0, 0, false},
4072 {"gs_5_0", VKD3D_SHADER_TYPE_GEOMETRY, 5, 0, 0, 0, false},
4073 {"gs_5_1", VKD3D_SHADER_TYPE_GEOMETRY, 5, 1, 0, 0, false},
4074 {"hs_5_0", VKD3D_SHADER_TYPE_HULL, 5, 0, 0, 0, false},
4075 {"hs_5_1", VKD3D_SHADER_TYPE_HULL, 5, 1, 0, 0, false},
4076 {"ps.1.0", VKD3D_SHADER_TYPE_PIXEL, 1, 0, 0, 0, false},
4077 {"ps.1.1", VKD3D_SHADER_TYPE_PIXEL, 1, 1, 0, 0, false},
4078 {"ps.1.2", VKD3D_SHADER_TYPE_PIXEL, 1, 2, 0, 0, false},
4079 {"ps.1.3", VKD3D_SHADER_TYPE_PIXEL, 1, 3, 0, 0, false},
4080 {"ps.1.4", VKD3D_SHADER_TYPE_PIXEL, 1, 4, 0, 0, false},
4081 {"ps.2.0", VKD3D_SHADER_TYPE_PIXEL, 2, 0, 0, 0, false},
4082 {"ps.2.a", VKD3D_SHADER_TYPE_PIXEL, 2, 1, 0, 0, false},
4083 {"ps.2.b", VKD3D_SHADER_TYPE_PIXEL, 2, 2, 0, 0, false},
4084 {"ps.2.sw", VKD3D_SHADER_TYPE_PIXEL, 2, 0, 0, 0, true},
4085 {"ps.3.0", VKD3D_SHADER_TYPE_PIXEL, 3, 0, 0, 0, false},
4086 {"ps_1_0", VKD3D_SHADER_TYPE_PIXEL, 1, 0, 0, 0, false},
4087 {"ps_1_1", VKD3D_SHADER_TYPE_PIXEL, 1, 1, 0, 0, false},
4088 {"ps_1_2", VKD3D_SHADER_TYPE_PIXEL, 1, 2, 0, 0, false},
4089 {"ps_1_3", VKD3D_SHADER_TYPE_PIXEL, 1, 3, 0, 0, false},
4090 {"ps_1_4", VKD3D_SHADER_TYPE_PIXEL, 1, 4, 0, 0, false},
4091 {"ps_2_0", VKD3D_SHADER_TYPE_PIXEL, 2, 0, 0, 0, false},
4092 {"ps_2_a", VKD3D_SHADER_TYPE_PIXEL, 2, 1, 0, 0, false},
4093 {"ps_2_b", VKD3D_SHADER_TYPE_PIXEL, 2, 2, 0, 0, false},
4094 {"ps_2_sw", VKD3D_SHADER_TYPE_PIXEL, 2, 0, 0, 0, true},
4095 {"ps_3_0", VKD3D_SHADER_TYPE_PIXEL, 3, 0, 0, 0, false},
4096 {"ps_3_sw", VKD3D_SHADER_TYPE_PIXEL, 3, 0, 0, 0, true},
4097 {"ps_4_0", VKD3D_SHADER_TYPE_PIXEL, 4, 0, 0, 0, false},
4098 {"ps_4_0_level_9_0", VKD3D_SHADER_TYPE_PIXEL, 4, 0, 9, 0, false},
4099 {"ps_4_0_level_9_1", VKD3D_SHADER_TYPE_PIXEL, 4, 0, 9, 1, false},
4100 {"ps_4_0_level_9_3", VKD3D_SHADER_TYPE_PIXEL, 4, 0, 9, 3, false},
4101 {"ps_4_1", VKD3D_SHADER_TYPE_PIXEL, 4, 1, 0, 0, false},
4102 {"ps_5_0", VKD3D_SHADER_TYPE_PIXEL, 5, 0, 0, 0, false},
4103 {"ps_5_1", VKD3D_SHADER_TYPE_PIXEL, 5, 1, 0, 0, false},
4104 {"tx_1_0", VKD3D_SHADER_TYPE_TEXTURE, 1, 0, 0, 0, false},
4105 {"vs.1.0", VKD3D_SHADER_TYPE_VERTEX, 1, 0, 0, 0, false},
4106 {"vs.1.1", VKD3D_SHADER_TYPE_VERTEX, 1, 1, 0, 0, false},
4107 {"vs.2.0", VKD3D_SHADER_TYPE_VERTEX, 2, 0, 0, 0, false},
4108 {"vs.2.a", VKD3D_SHADER_TYPE_VERTEX, 2, 1, 0, 0, false},
4109 {"vs.2.sw", VKD3D_SHADER_TYPE_VERTEX, 2, 0, 0, 0, true},
4110 {"vs.3.0", VKD3D_SHADER_TYPE_VERTEX, 3, 0, 0, 0, false},
4111 {"vs.3.sw", VKD3D_SHADER_TYPE_VERTEX, 3, 0, 0, 0, true},
4112 {"vs_1_0", VKD3D_SHADER_TYPE_VERTEX, 1, 0, 0, 0, false},
4113 {"vs_1_1", VKD3D_SHADER_TYPE_VERTEX, 1, 1, 0, 0, false},
4114 {"vs_2_0", VKD3D_SHADER_TYPE_VERTEX, 2, 0, 0, 0, false},
4115 {"vs_2_a", VKD3D_SHADER_TYPE_VERTEX, 2, 1, 0, 0, false},
4116 {"vs_2_sw", VKD3D_SHADER_TYPE_VERTEX, 2, 0, 0, 0, true},
4117 {"vs_3_0", VKD3D_SHADER_TYPE_VERTEX, 3, 0, 0, 0, false},
4118 {"vs_3_sw", VKD3D_SHADER_TYPE_VERTEX, 3, 0, 0, 0, true},
4119 {"vs_4_0", VKD3D_SHADER_TYPE_VERTEX, 4, 0, 0, 0, false},
4120 {"vs_4_0_level_9_0", VKD3D_SHADER_TYPE_VERTEX, 4, 0, 9, 0, false},
4121 {"vs_4_0_level_9_1", VKD3D_SHADER_TYPE_VERTEX, 4, 0, 9, 1, false},
4122 {"vs_4_0_level_9_3", VKD3D_SHADER_TYPE_VERTEX, 4, 0, 9, 3, false},
4123 {"vs_4_1", VKD3D_SHADER_TYPE_VERTEX, 4, 1, 0, 0, false},
4124 {"vs_5_0", VKD3D_SHADER_TYPE_VERTEX, 5, 0, 0, 0, false},
4125 {"vs_5_1", VKD3D_SHADER_TYPE_VERTEX, 5, 1, 0, 0, false},
4126 };
4127
4128 for (i = 0; i < ARRAY_SIZE(profiles); ++i)
4129 {
4130 if (!strcmp(target, profiles[i].name))
4131 return &profiles[i];
4132 }
4133
4134 return NULL;
4135}
Definition: tools.h:99
@ VKD3D_SHADER_TYPE_GEOMETRY
@ VKD3D_SHADER_TYPE_TEXTURE
@ VKD3D_SHADER_TYPE_EFFECT

Referenced by hlsl_compile_shader(), and hlsl_new_compile().

◆ hlsl_get_type()

struct hlsl_type * hlsl_get_type ( struct hlsl_scope *  scope,
const char *  name,
bool  recursive,
bool  case_insensitive 
)

Definition at line 995 of file hlsl.c.

996{
997 struct rb_entry *entry = rb_get(&scope->types, name);
998
999 if (entry)
1000 return RB_ENTRY_VALUE(entry, struct hlsl_type, scope_entry);
1001
1002 if (scope->upper)
1003 {
1004 if (recursive)
1005 return hlsl_get_type(scope->upper, name, recursive, case_insensitive);
1006 }
1007 else
1008 {
1009 if (case_insensitive && (name = get_case_insensitive_typename(name)))
1010 {
1011 if ((entry = rb_get(&scope->types, name)))
1012 return RB_ENTRY_VALUE(entry, struct hlsl_type, scope_entry);
1013 }
1014 }
1015
1016 return NULL;
1017}
static const char * get_case_insensitive_typename(const char *name)
Definition: hlsl.c:970
struct hlsl_type * hlsl_get_type(struct hlsl_scope *scope, const char *name, bool recursive, bool case_insensitive)
Definition: hlsl.c:995
struct rb_tree types
Definition: hlsl.h:956
struct hlsl_scope * upper
Definition: hlsl.h:958

Referenced by hlsl_get_type(), hlsl_new_compile(), and hlsl_scope_add_type().

◆ hlsl_get_var()

struct hlsl_ir_var * hlsl_get_var ( struct hlsl_scope *  scope,
const char *  name 
)

Definition at line 123 of file hlsl.c.

124{
125 struct hlsl_ir_var *var;
126
128 {
129 if (var->name && !strcmp(name, var->name))
130 return var;
131 }
132 if (!scope->upper)
133 return NULL;
134 return hlsl_get_var(scope->upper, name);
135}
struct hlsl_ir_var * hlsl_get_var(struct hlsl_scope *scope, const char *name)
Definition: hlsl.c:123

Referenced by hlsl_get_var(), and lower_combined_samples().

◆ hlsl_get_vector_type()

◆ hlsl_index_chain_has_resource_access()

bool hlsl_index_chain_has_resource_access ( struct hlsl_ir_index *  index)

Definition at line 2013 of file hlsl.c.

2014{
2016 return true;
2017 if (index->val.node->type == HLSL_IR_INDEX)
2019 return false;
2020}
bool hlsl_index_chain_has_resource_access(struct hlsl_ir_index *index)
Definition: hlsl.c:2013
bool hlsl_index_is_resource_access(struct hlsl_ir_index *index)
Definition: hlsl.c:2006

Referenced by hlsl_index_chain_has_resource_access().

◆ hlsl_index_is_noncontiguous()

bool hlsl_index_is_noncontiguous ( struct hlsl_ir_index *  index)

Definition at line 1999 of file hlsl.c.

2000{
2001 struct hlsl_type *type = index->val.node->data_type;
2002
2004}

Referenced by hlsl_init_deref_from_index_chain(), and lower_index_loads().

◆ hlsl_index_is_resource_access()

bool hlsl_index_is_resource_access ( struct hlsl_ir_index *  index)

Definition at line 2006 of file hlsl.c.

2007{
2008 const struct hlsl_type *type = index->val.node->data_type;
2009
2010 return type->class == HLSL_CLASS_TEXTURE || type->class == HLSL_CLASS_UAV;
2011}

Referenced by hlsl_index_chain_has_resource_access(), and lower_index_loads().

◆ hlsl_init_deref_from_index_chain()

bool hlsl_init_deref_from_index_chain ( struct hlsl_ctx *  ctx,
struct hlsl_deref *  deref,
struct hlsl_ir_node *  chain 
)

Definition at line 717 of file hlsl.c.

718{
719 struct hlsl_ir_index *index;
720 struct hlsl_ir_load *load;
721 unsigned int chain_len, i;
722 struct hlsl_ir_node *ptr;
723
724 deref->path = NULL;
725 deref->path_len = 0;
726 deref->rel_offset.node = NULL;
727 deref->const_offset = 0;
728
730 if (chain->type == HLSL_IR_INDEX)
732
733 /* Find the length of the index chain */
734 chain_len = 0;
735 ptr = chain;
736 while (ptr->type == HLSL_IR_INDEX)
737 {
739
740 chain_len++;
741 ptr = index->val.node;
742 }
743
744 if (ptr->type != HLSL_IR_LOAD)
745 {
746 hlsl_error(ctx, &chain->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_LVALUE, "Invalid l-value.");
747 return false;
748 }
750
751 if (!init_deref(ctx, deref, load->src.var, load->src.path_len + chain_len))
752 return false;
753
754 for (i = 0; i < load->src.path_len; ++i)
755 hlsl_src_from_node(&deref->path[i], load->src.path[i].node);
756
757 chain_len = 0;
758 ptr = chain;
759 while (ptr->type == HLSL_IR_INDEX)
760 {
761 unsigned int p = deref->path_len - 1 - chain_len;
762
765 {
766 hlsl_src_from_node(&deref->path[p], deref->path[p + 1].node);
767 hlsl_src_remove(&deref->path[p + 1]);
768 hlsl_src_from_node(&deref->path[p + 1], index->idx.node);
769 }
770 else
771 {
772 hlsl_src_from_node(&deref->path[p], index->idx.node);
773 }
774
775 chain_len++;
776 ptr = index->val.node;
777 }
778 VKD3D_ASSERT(deref->path_len == load->src.path_len + chain_len);
779
780 return true;
781}
#define index(s, c)
Definition: various.h:29
GLfloat GLfloat p
Definition: glext.h:8902
bool hlsl_index_is_noncontiguous(struct hlsl_ir_index *index)
Definition: hlsl.c:1999
int load
Definition: msacm.c:1365
struct sock * chain
Definition: tcpcore.h:1
@ VKD3D_SHADER_ERROR_HLSL_INVALID_LVALUE

Referenced by hlsl_new_resource_load().

◆ hlsl_init_simple_deref_from_var()

void hlsl_init_simple_deref_from_var ( struct hlsl_deref *  deref,
struct hlsl_ir_var *  var 
)

Definition at line 1424 of file hlsl.c.

1425{
1426 memset(deref, 0, sizeof(*deref));
1427 deref->var = var;
1428}

Referenced by add_zero_mipmap_level(), hlsl_new_simple_store(), hlsl_new_var_load(), lower_index_loads(), lower_matrix_swizzles(), and lower_trig().

◆ hlsl_ir_call()

static struct hlsl_ir_call * hlsl_ir_call ( const struct hlsl_ir_node *  node)
inlinestatic

Definition at line 1160 of file hlsl.h.

1161{
1162 VKD3D_ASSERT(node->type == HLSL_IR_CALL);
1163 return CONTAINING_RECORD(node, struct hlsl_ir_call, node);
1164}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

◆ hlsl_ir_compile()

static struct hlsl_ir_compile * hlsl_ir_compile ( const struct hlsl_ir_node *  node)
inlinestatic

Definition at line 1244 of file hlsl.h.

1245{
1247 return CONTAINING_RECORD(node, struct hlsl_ir_compile, node);
1248}

◆ hlsl_ir_constant()

static struct hlsl_ir_constant * hlsl_ir_constant ( const struct hlsl_ir_node *  node)
inlinestatic

Definition at line 1166 of file hlsl.h.

1167{
1170}

◆ hlsl_ir_expr()

static struct hlsl_ir_expr * hlsl_ir_expr ( const struct hlsl_ir_node *  node)
inlinestatic

Definition at line 1178 of file hlsl.h.

1179{
1180 VKD3D_ASSERT(node->type == HLSL_IR_EXPR);
1181 return CONTAINING_RECORD(node, struct hlsl_ir_expr, node);
1182}

◆ hlsl_ir_if()

static struct hlsl_ir_if * hlsl_ir_if ( const struct hlsl_ir_node *  node)
inlinestatic

Definition at line 1184 of file hlsl.h.

1185{
1186 VKD3D_ASSERT(node->type == HLSL_IR_IF);
1187 return CONTAINING_RECORD(node, struct hlsl_ir_if, node);
1188}

◆ hlsl_ir_index()

static struct hlsl_ir_index * hlsl_ir_index ( const struct hlsl_ir_node *  node)
inlinestatic

Definition at line 1232 of file hlsl.h.

1233{
1235 return CONTAINING_RECORD(node, struct hlsl_ir_index, node);
1236}

◆ hlsl_ir_jump()

static struct hlsl_ir_jump * hlsl_ir_jump ( const struct hlsl_ir_node *  node)
inlinestatic

Definition at line 1190 of file hlsl.h.

1191{
1192 VKD3D_ASSERT(node->type == HLSL_IR_JUMP);
1193 return CONTAINING_RECORD(node, struct hlsl_ir_jump, node);
1194}

◆ hlsl_ir_load()

static struct hlsl_ir_load * hlsl_ir_load ( const struct hlsl_ir_node *  node)
inlinestatic

Definition at line 1196 of file hlsl.h.

1197{
1198 VKD3D_ASSERT(node->type == HLSL_IR_LOAD);
1199 return CONTAINING_RECORD(node, struct hlsl_ir_load, node);
1200}

◆ hlsl_ir_loop()

static struct hlsl_ir_loop * hlsl_ir_loop ( const struct hlsl_ir_node *  node)
inlinestatic

Definition at line 1202 of file hlsl.h.

1203{
1204 VKD3D_ASSERT(node->type == HLSL_IR_LOOP);
1205 return CONTAINING_RECORD(node, struct hlsl_ir_loop, node);
1206}

◆ hlsl_ir_resource_load()

Definition at line 1208 of file hlsl.h.

1209{
1212}

◆ hlsl_ir_resource_store()

Definition at line 1214 of file hlsl.h.

1215{
1218}

◆ hlsl_ir_sampler_state()

Definition at line 1250 of file hlsl.h.

1251{
1254};

◆ hlsl_ir_stateblock_constant()

Definition at line 1256 of file hlsl.h.

◆ hlsl_ir_store()

static struct hlsl_ir_store * hlsl_ir_store ( const struct hlsl_ir_node *  node)
inlinestatic

Definition at line 1220 of file hlsl.h.

1221{
1223 return CONTAINING_RECORD(node, struct hlsl_ir_store, node);
1224}

◆ hlsl_ir_string_constant()

Definition at line 1172 of file hlsl.h.

1173{
1176}

◆ hlsl_ir_switch()

static struct hlsl_ir_switch * hlsl_ir_switch ( const struct hlsl_ir_node *  node)
inlinestatic

Definition at line 1238 of file hlsl.h.

1239{
1241 return CONTAINING_RECORD(node, struct hlsl_ir_switch, node);
1242}

◆ hlsl_ir_swizzle()

static struct hlsl_ir_swizzle * hlsl_ir_swizzle ( const struct hlsl_ir_node *  node)
inlinestatic

Definition at line 1226 of file hlsl.h.

1227{
1229 return CONTAINING_RECORD(node, struct hlsl_ir_swizzle, node);
1230}

◆ hlsl_ir_vsir_instruction_ref()

Definition at line 1262 of file hlsl.h.

◆ hlsl_is_numeric_type()

◆ hlsl_jump_type_to_string()

const char * hlsl_jump_type_to_string ( enum hlsl_ir_jump_type  type)

Definition at line 2979 of file hlsl.c.

2980{
2981 static const char * const names[] =
2982 {
2983 [HLSL_IR_JUMP_BREAK] = "HLSL_IR_JUMP_BREAK",
2984 [HLSL_IR_JUMP_CONTINUE] = "HLSL_IR_JUMP_CONTINUE",
2985 [HLSL_IR_JUMP_DISCARD_NEG] = "HLSL_IR_JUMP_DISCARD_NEG",
2986 [HLSL_IR_JUMP_DISCARD_NZ] = "HLSL_IR_JUMP_DISCARD_NZ",
2987 [HLSL_IR_JUMP_RETURN] = "HLSL_IR_JUMP_RETURN",
2988 };
2989
2991 return names[type];
2992}
GLuint GLuint * names
Definition: glext.h:11545

Referenced by sm1_generate_vsir_instr_jump(), and write_sm4_jump().

◆ hlsl_lexer_compile()

int hlsl_lexer_compile ( struct hlsl_ctx *  ctx,
const struct vkd3d_shader_code *  hlsl 
)

◆ hlsl_lower_index_loads()

void hlsl_lower_index_loads ( struct hlsl_ctx *  ctx,
struct hlsl_block *  body 
)

Definition at line 6392 of file hlsl_codegen.c.

6393{
6395}
static bool lower_ir(struct hlsl_ctx *ctx, PFN_lower_func func, struct hlsl_block *block)
Definition: hlsl_codegen.c:704
static bool lower_index_loads(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
static const void * body(MD5_CTX *ctx, const void *data, unsigned long size)
Definition: md5.c:100

◆ hlsl_map_swizzle()

uint32_t hlsl_map_swizzle ( uint32_t  swizzle,
unsigned int  writemask 
)

Definition at line 3978 of file hlsl.c.

3979{
3980 uint32_t ret = 0;
3981 unsigned int i;
3982
3983 /* Leave replicate swizzles alone; some instructions need them. */
3984 if (swizzle == HLSL_SWIZZLE(X, X, X, X)
3985 || swizzle == HLSL_SWIZZLE(Y, Y, Y, Y)
3986 || swizzle == HLSL_SWIZZLE(Z, Z, Z, Z)
3987 || swizzle == HLSL_SWIZZLE(W, W, W, W))
3988 return swizzle;
3989
3990 for (i = 0; i < 4; ++i)
3991 {
3992 if (writemask & (1 << i))
3993 {
3994 ret |= (swizzle & 3) << (i * 2);
3995 swizzle >>= 2;
3996 }
3997 }
3998 return ret;
3999}
#define Z(I)
#define Y(I)
#define HLSL_SWIZZLE(x, y, z, w)
Definition: hlsl.h:59
Definition: polytest.cpp:36

Referenced by generate_vsir_get_src_swizzle(), generate_vsir_instr_swizzle(), sm4_src_from_deref(), sm4_src_from_node(), and write_sm4_swizzle().

◆ hlsl_modifiers_to_string()

struct vkd3d_string_buffer * hlsl_modifiers_to_string ( struct hlsl_ctx *  ctx,
unsigned int  modifiers 
)

◆ hlsl_new_array_type()

struct hlsl_type * hlsl_new_array_type ( struct hlsl_ctx *  ctx,
struct hlsl_type *  basic_type,
unsigned int  array_size 
)

Definition at line 880 of file hlsl.c.

881{
882 struct hlsl_type *type;
883
884 if (!(type = hlsl_alloc(ctx, sizeof(*type))))
885 return NULL;
886
887 type->class = HLSL_CLASS_ARRAY;
888 type->modifiers = basic_type->modifiers;
889 type->e.array.elements_count = array_size;
890 type->e.array.type = basic_type;
891 type->dimx = basic_type->dimx;
892 type->dimy = basic_type->dimy;
893 type->sampler_dim = basic_type->sampler_dim;
895
896 list_add_tail(&ctx->types, &type->entry);
897
898 return type;
899}
static void hlsl_type_calculate_reg_size(struct hlsl_ctx *ctx, struct hlsl_type *type)
Definition: hlsl.c:345
static UINT array_size
Definition: msctf.cpp:39
enum hlsl_sampler_dim sampler_dim
Definition: hlsl.h:172
uint32_t modifiers
Definition: hlsl.h:178

Referenced by lower_combined_samples().

◆ hlsl_new_binary_expr()

◆ hlsl_new_bool_constant()

struct hlsl_ir_node * hlsl_new_bool_constant ( struct hlsl_ctx *  ctx,
bool  b,
const struct vkd3d_shader_location *  loc 
)

Definition at line 1537 of file hlsl.c.

1538{
1539 struct hlsl_constant_value value;
1540
1541 value.u[0].u = b ? ~0u : 0;
1543}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240

Referenced by hlsl_new_func_decl(), and lower_return().

◆ hlsl_new_buffer()

struct hlsl_buffer * hlsl_new_buffer ( struct hlsl_ctx *  ctx,
enum hlsl_buffer_type  type,
const char *  name,
uint32_t  modifiers,
const struct hlsl_reg_reservation *  reservation,
struct hlsl_scope *  annotations,
const struct vkd3d_shader_location *  loc 
)

Definition at line 2594 of file hlsl.c.

2597{
2598 struct hlsl_buffer *buffer;
2599
2600 if (!(buffer = hlsl_alloc(ctx, sizeof(*buffer))))
2601 return NULL;
2602 buffer->type = type;
2603 buffer->name = name;
2604 buffer->modifiers = modifiers;
2605 if (reservation)
2606 buffer->reservation = *reservation;
2607 buffer->annotations = annotations;
2608 buffer->loc = *loc;
2609 list_add_tail(&ctx->buffers, &buffer->entry);
2610 return buffer;
2611}
struct hlsl_reg_reservation reservation
Definition: hlsl.h:1001
uint32_t modifiers
Definition: hlsl.h:997
struct vkd3d_shader_location loc
Definition: hlsl.h:994
const char * name
Definition: hlsl.h:996
struct hlsl_scope * annotations
Definition: hlsl.h:1003

Referenced by hlsl_ctx_init().

◆ hlsl_new_call()

Definition at line 1508 of file hlsl.c.

1510{
1511 struct hlsl_ir_call *call;
1512
1513 if (!(call = hlsl_alloc(ctx, sizeof(*call))))
1514 return NULL;
1515
1516 init_node(&call->node, HLSL_IR_CALL, NULL, loc);
1517 call->decl = decl;
1518 return &call->node;
1519}
static void init_node(struct hlsl_ir_node *node, enum hlsl_ir_node_type type, struct hlsl_type *data_type, const struct vkd3d_shader_location *loc)
Definition: hlsl.c:1430
struct hlsl_ir_node node
Definition: hlsl.h:635
struct hlsl_ir_function_decl * decl
Definition: hlsl.h:636

Referenced by clone_call(), lower_f16tof32(), and lower_f32tof16().

◆ hlsl_new_cast()

struct hlsl_ir_node * hlsl_new_cast ( struct hlsl_ctx *  ctx,
struct hlsl_ir_node *  node,
struct hlsl_type *  type,
const struct vkd3d_shader_location *  loc 
)

Definition at line 1294 of file hlsl.c.

1296{
1297 struct hlsl_ir_node *cast;
1298
1300 if (cast)
1301 cast->data_type = type;
1302 return cast;
1303}
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)
Definition: hlsl.c:1611

Referenced by hlsl_add_conditional(), hlsl_new_copy(), lower_broadcasts(), lower_cmp(), lower_comparison_operators(), lower_discard_nz(), lower_int_division(), lower_int_modulus(), lower_logic_not(), lower_narrowing_casts(), lower_nonconstant_vector_derefs(), lower_nonfloat_exprs(), lower_slt(), lower_ternary(), prepend_input_copy(), and resolve_fx_4_state_block_values().

◆ hlsl_new_cb_type()

struct hlsl_type * hlsl_new_cb_type ( struct hlsl_ctx *  ctx,
struct hlsl_type *  format 
)

Definition at line 956 of file hlsl.c.

957{
958 struct hlsl_type *type;
959
960 if (!(type = hlsl_alloc(ctx, sizeof(*type))))
961 return NULL;
963 type->dimy = 1;
964 type->e.resource.format = format;
966 list_add_tail(&ctx->types, &type->entry);
967 return type;
968}
struct hlsl_type * format
Definition: hlsl.h:217

◆ hlsl_new_compile()

struct hlsl_ir_node * hlsl_new_compile ( struct hlsl_ctx *  ctx,
enum hlsl_compile_type  compile_type,
const char *  profile_name,
struct hlsl_ir_node **  args,
unsigned int  args_count,
struct hlsl_block *  args_instrs,
const struct vkd3d_shader_location *  loc 
)

Definition at line 1866 of file hlsl.c.

1869{
1870 const struct hlsl_profile_info *profile_info = NULL;
1871 struct hlsl_ir_compile *compile;
1872 struct hlsl_type *type = NULL;
1873 unsigned int i;
1874
1875 switch (compile_type)
1876 {
1877 case HLSL_COMPILE_TYPE_COMPILE:
1878 if (!(profile_info = hlsl_get_target_info(profile_name)))
1879 {
1880 hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_PROFILE, "Unknown profile \"%s\".", profile_name);
1881 return NULL;
1882 }
1883
1884 if (profile_info->type == VKD3D_SHADER_TYPE_PIXEL)
1885 type = hlsl_get_type(ctx->cur_scope, "PixelShader", true, true);
1886 else if (profile_info->type == VKD3D_SHADER_TYPE_VERTEX)
1887 type = hlsl_get_type(ctx->cur_scope, "VertexShader", true, true);
1888
1889 if (!type)
1890 {
1891 hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_PROFILE, "Invalid profile \"%s\".", profile_name);
1892 return NULL;
1893 }
1894
1895 break;
1896
1897 case HLSL_COMPILE_TYPE_CONSTRUCTGSWITHSO:
1898 type = hlsl_get_type(ctx->cur_scope, "GeometryShader", true, true);
1899 break;
1900 }
1901
1902 if (!(compile = hlsl_alloc(ctx, sizeof(*compile))))
1903 return NULL;
1904
1905 init_node(&compile->node, HLSL_IR_COMPILE, type, loc);
1906
1907 compile->compile_type = compile_type;
1908 compile->profile = profile_info;
1909
1910 hlsl_block_init(&compile->instrs);
1911 hlsl_block_add_block(&compile->instrs, args_instrs);
1912
1913 compile->args_count = args_count;
1914 if (!(compile->args = hlsl_alloc(ctx, sizeof(*compile->args) * args_count)))
1915 {
1916 vkd3d_free(compile);
1917 return NULL;
1918 }
1919 for (i = 0; i < compile->args_count; ++i)
1920 hlsl_src_from_node(&compile->args[i], args[i]);
1921
1922 return &compile->node;
1923}
const struct hlsl_profile_info * hlsl_get_target_info(const char *target)
Definition: hlsl.c:4054
static void hlsl_block_add_block(struct hlsl_block *block, struct hlsl_block *add)
Definition: hlsl.h:1280
Definition: match.c:390
unsigned int args_count
Definition: hlsl.h:918
struct hlsl_src * args
Definition: hlsl.h:917
struct hlsl_block instrs
Definition: hlsl.h:913
const struct hlsl_profile_info * profile
Definition: hlsl.h:909
enum hlsl_ir_compile::hlsl_compile_type compile_type
struct hlsl_ir_node node
Definition: hlsl.h:898
enum vkd3d_shader_type type
Definition: hlsl.h:970
@ VKD3D_SHADER_ERROR_HLSL_INVALID_PROFILE

Referenced by clone_compile().

◆ hlsl_new_constant()

◆ hlsl_new_copy()

struct hlsl_ir_node * hlsl_new_copy ( struct hlsl_ctx *  ctx,
struct hlsl_ir_node *  node 
)

Definition at line 1305 of file hlsl.c.

1306{
1307 /* Use a cast to the same type as a makeshift identity expression. */
1308 return hlsl_new_cast(ctx, node, node->data_type, &node->loc);
1309}

◆ hlsl_new_expr()

struct hlsl_ir_node * hlsl_new_expr ( struct hlsl_ctx *  ctx,
enum hlsl_ir_expr_op  op,
struct hlsl_ir_node *  operands[HLSL_MAX_OPERANDS],
struct hlsl_type *  data_type,
const struct vkd3d_shader_location *  loc 
)

Definition at line 1595 of file hlsl.c.

1598{
1599 struct hlsl_ir_expr *expr;
1600 unsigned int i;
1601
1602 if (!(expr = hlsl_alloc(ctx, sizeof(*expr))))
1603 return NULL;
1604 init_node(&expr->node, HLSL_IR_EXPR, data_type, loc);
1605 expr->op = op;
1606 for (i = 0; i < HLSL_MAX_OPERANDS; ++i)
1607 hlsl_src_from_node(&expr->operands[i], operands[i]);
1608 return &expr->node;
1609}
enum wined3d_data_type data_type
Definition: glsl_shader.c:71
struct hlsl_src operands[HLSL_MAX_OPERANDS]
Definition: hlsl.h:756

Referenced by clone_expr(), hlsl_add_conditional(), hlsl_new_binary_expr(), hlsl_new_error_expr(), hlsl_new_ternary_expr(), hlsl_new_unary_expr(), lower_casts_to_int(), lower_comparison_operators(), lower_discard_neg(), lower_dot(), lower_logic_not(), lower_nonconstant_array_loads(), lower_nonconstant_vector_derefs(), lower_nonfloat_exprs(), and lower_ternary().

◆ hlsl_new_float_constant()

struct hlsl_ir_node * hlsl_new_float_constant ( struct hlsl_ctx *  ctx,
float  f,
const struct vkd3d_shader_location *  loc 
)

Definition at line 1545 of file hlsl.c.

1547{
1548 struct hlsl_constant_value value;
1549
1550 value.u[0].f = f;
1552}
#define f
Definition: ke_i.h:83

Referenced by lower_dot().

◆ hlsl_new_func_decl()

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 
)

Definition at line 2554 of file hlsl.c.

2557{
2558 struct hlsl_ir_node *constant, *store;
2559 struct hlsl_ir_function_decl *decl;
2560
2561 if (!(decl = hlsl_alloc(ctx, sizeof(*decl))))
2562 return NULL;
2563 hlsl_block_init(&decl->body);
2564 decl->return_type = return_type;
2565 decl->parameters = *parameters;
2566 decl->loc = *loc;
2567 list_init(&decl->extern_vars);
2568
2569 if (!hlsl_types_are_equal(return_type, ctx->builtin_types.Void))
2570 {
2571 if (!(decl->return_var = hlsl_new_synthetic_var(ctx, "retval", return_type, loc)))
2572 {
2573 vkd3d_free(decl);
2574 return NULL;
2575 }
2576 decl->return_var->semantic = *semantic;
2577 }
2578
2579 if (!(decl->early_return_var = hlsl_new_synthetic_var(ctx, "early_return",
2581 return decl;
2582
2583 if (!(constant = hlsl_new_bool_constant(ctx, false, loc)))
2584 return decl;
2586
2587 if (!(store = hlsl_new_simple_store(ctx, decl->early_return_var, constant)))
2588 return decl;
2589 hlsl_block_add_instr(&decl->body, store);
2590
2591 return decl;
2592}
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)
Definition: hlsl.c:1349
struct hlsl_ir_node * hlsl_new_bool_constant(struct hlsl_ctx *ctx, bool b, const struct vkd3d_shader_location *loc)
Definition: hlsl.c:1537
struct hlsl_ir_node * hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir_var *lhs, struct hlsl_ir_node *rhs)
Definition: hlsl.c:1440
struct hlsl_func_parameters parameters
Definition: hlsl.h:610
struct hlsl_ir_var * return_var
Definition: hlsl.h:601
struct list extern_vars
Definition: hlsl.h:630
struct hlsl_ir_var * early_return_var
Definition: hlsl.h:624
struct hlsl_type * return_type
Definition: hlsl.h:599
struct hlsl_block body
Definition: hlsl.h:612

◆ hlsl_new_if()

struct hlsl_ir_node * hlsl_new_if ( struct hlsl_ctx *  ctx,
struct hlsl_ir_node *  condition,
struct hlsl_block *  then_block,
struct hlsl_block *  else_block,
const struct vkd3d_shader_location *  loc 
)

Definition at line 1647 of file hlsl.c.

1649{
1650 struct hlsl_ir_if *iff;
1651
1652 if (!(iff = hlsl_alloc(ctx, sizeof(*iff))))
1653 return NULL;
1654 init_node(&iff->node, HLSL_IR_IF, NULL, loc);
1659 if (else_block)
1661 return &iff->node;
1662}
struct hlsl_block then_block
Definition: hlsl.h:643
struct hlsl_src condition
Definition: hlsl.h:642
struct hlsl_ir_node node
Definition: hlsl.h:641
struct hlsl_block else_block
Definition: hlsl.h:644

Referenced by clone_if(), insert_early_return_break(), and lower_return().

◆ hlsl_new_index()

struct hlsl_ir_node * hlsl_new_index ( struct hlsl_ctx *  ctx,
struct hlsl_ir_node *  val,
struct hlsl_ir_node *  idx,
const struct vkd3d_shader_location *  loc 
)

Definition at line 2022 of file hlsl.c.

2024{
2025 struct hlsl_type *type = val->data_type;
2026 struct hlsl_ir_index *index;
2027
2028 if (!(index = hlsl_alloc(ctx, sizeof(*index))))
2029 return NULL;
2030
2031 if (type->class == HLSL_CLASS_TEXTURE || type->class == HLSL_CLASS_UAV)
2032 type = type->e.resource.format;
2033 else if (type->class == HLSL_CLASS_MATRIX)
2034 type = hlsl_get_vector_type(ctx, type->e.numeric.type, type->dimx);
2035 else
2037
2038 init_node(&index->node, HLSL_IR_INDEX, type, loc);
2041 return &index->node;
2042}
GLuint GLfloat * val
Definition: glext.h:7180

Referenced by clone_index().

◆ hlsl_new_int_constant()

struct hlsl_ir_node * hlsl_new_int_constant ( struct hlsl_ctx *  ctx,
int32_t  n,
const struct vkd3d_shader_location *  loc 
)

Definition at line 1554 of file hlsl.c.

1555{
1556 struct hlsl_constant_value value;
1557
1558 value.u[0].i = n;
1560}
GLdouble n
Definition: glext.h:7729

◆ hlsl_new_jump()

struct hlsl_ir_node * hlsl_new_jump ( struct hlsl_ctx *  ctx,
enum hlsl_ir_jump_type  type,
struct hlsl_ir_node *  condition,
const struct vkd3d_shader_location *  loc 
)

Definition at line 2044 of file hlsl.c.

2046{
2047 struct hlsl_ir_jump *jump;
2048
2049 if (!(jump = hlsl_alloc(ctx, sizeof(*jump))))
2050 return NULL;
2051 init_node(&jump->node, HLSL_IR_JUMP, NULL, loc);
2052 jump->type = type;
2054 return &jump->node;
2055}
struct hlsl_ir_node node
Definition: hlsl.h:774
struct hlsl_src condition
Definition: hlsl.h:777
enum hlsl_ir_jump_type type
Definition: hlsl.h:775

Referenced by clone_jump(), insert_early_return_break(), and normalize_switch_cases().

◆ hlsl_new_load_component()

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 
)

Definition at line 1766 of file hlsl.c.

1768{
1769 struct hlsl_type *type, *comp_type;
1770 struct hlsl_block comp_path_block;
1771 struct hlsl_ir_load *load;
1772
1774
1775 if (!(load = hlsl_alloc(ctx, sizeof(*load))))
1776 return NULL;
1777
1778 type = hlsl_deref_get_type(ctx, deref);
1779 comp_type = hlsl_type_get_component_type(ctx, type, comp);
1780 init_node(&load->node, HLSL_IR_LOAD, comp_type, loc);
1781
1782 if (!init_deref_from_component_index(ctx, &comp_path_block, &load->src, deref, comp, loc))
1783 {
1785 return NULL;
1786 }
1787 hlsl_block_add_block(block, &comp_path_block);
1788
1790
1791 return &load->node;
1792}
static bool init_deref_from_component_index(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_deref *deref, const struct hlsl_deref *prefix, unsigned int index, const struct vkd3d_shader_location *loc)
Definition: hlsl.c:801
struct hlsl_type * hlsl_type_get_component_type(struct hlsl_ctx *ctx, struct hlsl_type *type, unsigned int index)
Definition: hlsl.c:611

◆ hlsl_new_load_index()

struct hlsl_ir_load * hlsl_new_load_index ( struct hlsl_ctx *  ctx,
const struct hlsl_deref *  deref,
struct hlsl_ir_node *  idx,
const struct vkd3d_shader_location *  loc 
)

Definition at line 1714 of file hlsl.c.

1716{
1717 struct hlsl_ir_load *load;
1718 struct hlsl_type *type;
1719 unsigned int i;
1720
1722
1723 type = hlsl_deref_get_type(ctx, deref);
1724 if (idx)
1726
1727 if (!(load = hlsl_alloc(ctx, sizeof(*load))))
1728 return NULL;
1729 init_node(&load->node, HLSL_IR_LOAD, type, loc);
1730
1731 if (!init_deref(ctx, &load->src, deref->var, deref->path_len + !!idx))
1732 {
1734 return NULL;
1735 }
1736 for (i = 0; i < deref->path_len; ++i)
1737 hlsl_src_from_node(&load->src.path[i], deref->path[i].node);
1738 if (idx)
1739 hlsl_src_from_node(&load->src.path[deref->path_len], idx);
1740
1741 return load;
1742}

Referenced by append_output_copy(), append_output_copy_recurse(), hlsl_new_load_parent(), hlsl_new_var_load(), lower_index_loads(), lower_nonconstant_array_loads(), lower_trig(), prepend_input_copy_recurse(), and split_copy().

◆ hlsl_new_load_parent()

struct hlsl_ir_load * hlsl_new_load_parent ( struct hlsl_ctx *  ctx,
const struct hlsl_deref *  deref,
const struct vkd3d_shader_location *  loc 
)

Definition at line 1744 of file hlsl.c.

1746{
1747 /* This deref can only exists temporarily because it is not the real owner of its members. */
1748 struct hlsl_deref tmp_deref;
1749
1750 VKD3D_ASSERT(deref->path_len >= 1);
1751
1752 tmp_deref = *deref;
1753 tmp_deref.path_len = deref->path_len - 1;
1754 return hlsl_new_load_index(ctx, &tmp_deref, NULL, loc);
1755}
struct hlsl_ir_load * hlsl_new_load_index(struct hlsl_ctx *ctx, const struct hlsl_deref *deref, struct hlsl_ir_node *idx, const struct vkd3d_shader_location *loc)
Definition: hlsl.c:1714

Referenced by lower_nonconstant_vector_derefs().

◆ hlsl_new_loop()

struct hlsl_ir_node * hlsl_new_loop ( struct hlsl_ctx *  ctx,
struct hlsl_block *  block,
enum hlsl_ir_loop_unroll_type  unroll_type,
unsigned int  unroll_limit,
const struct vkd3d_shader_location *  loc 
)

Definition at line 2057 of file hlsl.c.

2060{
2061 struct hlsl_ir_loop *loop;
2062
2063 if (!(loop = hlsl_alloc(ctx, sizeof(*loop))))
2064 return NULL;
2065 init_node(&loop->node, HLSL_IR_LOOP, NULL, loc);
2066 hlsl_block_init(&loop->body);
2068
2069 loop->unroll_type = unroll_type;
2070 loop->unroll_limit = unroll_limit;
2071 return &loop->node;
2072}
enum hlsl_ir_loop_unroll_type unroll_type
Definition: hlsl.h:661
unsigned int unroll_limit
Definition: hlsl.h:660
struct hlsl_ir_node node
Definition: hlsl.h:656
struct hlsl_block body
Definition: hlsl.h:658

Referenced by clone_loop().

◆ hlsl_new_null_constant()

struct hlsl_ir_node * hlsl_new_null_constant ( struct hlsl_ctx *  ctx,
const struct vkd3d_shader_location *  loc 
)

Definition at line 1589 of file hlsl.c.

1590{
1591 struct hlsl_constant_value value = { 0 };
1592 return hlsl_new_constant(ctx, ctx->builtin_types.null, &value, loc);
1593}

◆ hlsl_new_resource_load()

struct hlsl_ir_node * hlsl_new_resource_load ( struct hlsl_ctx *  ctx,
const struct hlsl_resource_load_params *  params,
const struct vkd3d_shader_location *  loc 
)

Definition at line 1794 of file hlsl.c.

1796{
1798
1799 if (!(load = hlsl_alloc(ctx, sizeof(*load))))
1800 return NULL;
1801 init_node(&load->node, HLSL_IR_RESOURCE_LOAD, params->format, loc);
1802 load->load_type = params->type;
1803
1804 if (!hlsl_init_deref_from_index_chain(ctx, &load->resource, params->resource))
1805 {
1807 return NULL;
1808 }
1809
1810 if (params->sampler)
1811 {
1812 if (!hlsl_init_deref_from_index_chain(ctx, &load->sampler, params->sampler))
1813 {
1814 hlsl_cleanup_deref(&load->resource);
1816 return NULL;
1817 }
1818 }
1819
1820 hlsl_src_from_node(&load->coords, params->coords);
1821 hlsl_src_from_node(&load->sample_index, params->sample_index);
1822 hlsl_src_from_node(&load->texel_offset, params->texel_offset);
1823 hlsl_src_from_node(&load->lod, params->lod);
1824 hlsl_src_from_node(&load->ddx, params->ddx);
1825 hlsl_src_from_node(&load->ddy, params->ddy);
1826 hlsl_src_from_node(&load->cmp, params->cmp);
1827 load->sampling_dim = params->sampling_dim;
1828 if (load->sampling_dim == HLSL_SAMPLER_DIM_GENERIC)
1829 load->sampling_dim = hlsl_deref_get_type(ctx, &load->resource)->sampler_dim;
1830 return &load->node;
1831}
GLenum const GLfloat * params
Definition: glext.h:5645
void hlsl_cleanup_deref(struct hlsl_deref *deref)
Definition: hlsl.c:1408
bool hlsl_init_deref_from_index_chain(struct hlsl_ctx *ctx, struct hlsl_deref *deref, struct hlsl_ir_node *chain)
Definition: hlsl.c:717

Referenced by lower_index_loads().

◆ hlsl_new_resource_store()

struct hlsl_ir_node * hlsl_new_resource_store ( struct hlsl_ctx *  ctx,
const struct hlsl_deref *  resource,
struct hlsl_ir_node *  coords,
struct hlsl_ir_node *  value,
const struct vkd3d_shader_location *  loc 
)

Definition at line 1833 of file hlsl.c.

1835{
1836 struct hlsl_ir_resource_store *store;
1837
1838 if (!(store = hlsl_alloc(ctx, sizeof(*store))))
1839 return NULL;
1840 init_node(&store->node, HLSL_IR_RESOURCE_STORE, NULL, loc);
1842 hlsl_src_from_node(&store->coords, coords);
1843 hlsl_src_from_node(&store->value, value);
1844 return &store->node;
1845}
GLuint coords
Definition: glext.h:7368
bool hlsl_copy_deref(struct hlsl_ctx *ctx, struct hlsl_deref *deref, const struct hlsl_deref *other)
Definition: hlsl.c:1388
struct hlsl_ir_node node
Definition: hlsl.h:862
struct hlsl_src coords value
Definition: hlsl.h:864
struct hlsl_deref resource
Definition: hlsl.h:863

◆ hlsl_new_sampler_state()

struct hlsl_ir_node * hlsl_new_sampler_state ( struct hlsl_ctx *  ctx,
const struct hlsl_state_block *  state_block,
struct vkd3d_shader_location *  loc 
)

Definition at line 1937 of file hlsl.c.

1939{
1940 struct hlsl_ir_sampler_state *sampler_state;
1941 struct hlsl_type *type = ctx->builtin_types.sampler[HLSL_SAMPLER_DIM_GENERIC];
1942
1943 if (!(sampler_state = hlsl_alloc(ctx, sizeof(*sampler_state))))
1944 return NULL;
1945
1946 init_node(&sampler_state->node, HLSL_IR_SAMPLER_STATE, type, loc);
1947
1948 if (!(sampler_state->state_block = hlsl_alloc(ctx, sizeof(*sampler_state->state_block))))
1949 {
1950 vkd3d_free(sampler_state);
1951 return NULL;
1952 }
1953
1954 if (state_block)
1955 {
1956 for (unsigned int i = 0; i < state_block->count; ++i)
1957 {
1958 const struct hlsl_state_block_entry *src = state_block->entries[i];
1960
1961 if (!(entry = clone_stateblock_entry(ctx, src, src->name, src->lhs_has_index, src->lhs_index, false, 0)))
1962 {
1963 hlsl_free_instr(&sampler_state->node);
1964 return NULL;
1965 }
1966
1967 if (!hlsl_state_block_add_entry(sampler_state->state_block, entry))
1968 {
1969 hlsl_free_instr(&sampler_state->node);
1970 return NULL;
1971 }
1972 }
1973 }
1974
1975 return &sampler_state->node;
1976}
bool hlsl_state_block_add_entry(struct hlsl_state_block *state_block, struct hlsl_state_block_entry *entry)
Definition: hlsl.c:1925
struct hlsl_state_block_entry * clone_stateblock_entry(struct hlsl_ctx *ctx, const struct hlsl_state_block_entry *src, const char *name, bool lhs_has_index, unsigned int lhs_index, bool single_arg, unsigned int arg_index)
Definition: hlsl.c:2379
struct hlsl_ir_node node
Definition: hlsl.h:924
struct hlsl_state_block * state_block
Definition: hlsl.h:926

Referenced by clone_sampler_state().

◆ hlsl_new_simple_store()

struct hlsl_ir_node * hlsl_new_simple_store ( struct hlsl_ctx *  ctx,
struct hlsl_ir_var *  lhs,
struct hlsl_ir_node *  rhs 
)

Definition at line 1440 of file hlsl.c.

1441{
1442 struct hlsl_deref lhs_deref;
1443
1444 hlsl_init_simple_deref_from_var(&lhs_deref, lhs);
1445 return hlsl_new_store_index(ctx, &lhs_deref, NULL, rhs, 0, &rhs->loc);
1446}
void hlsl_init_simple_deref_from_var(struct hlsl_deref *deref, struct hlsl_ir_var *var)
Definition: hlsl.c:1424
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)
Definition: hlsl.c:1448

Referenced by append_output_copy(), hlsl_new_func_decl(), lower_f16tof32(), lower_f32tof16(), lower_index_loads(), lower_nonconstant_array_loads(), lower_return(), and prepend_uniform_copy().

◆ hlsl_new_stateblock_constant()

struct hlsl_ir_node * hlsl_new_stateblock_constant ( struct hlsl_ctx *  ctx,
const char *  name,
struct vkd3d_shader_location *  loc 
)

Definition at line 1978 of file hlsl.c.

1980{
1983
1984 if (!(constant = hlsl_alloc(ctx, sizeof(*constant))))
1985 return NULL;
1986
1988
1989 if (!(constant->name = hlsl_alloc(ctx, strlen(name) + 1)))
1990 {
1992 return NULL;
1993 }
1994 strcpy(constant->name, name);
1995
1996 return &constant->node;
1997}
strcpy
Definition: string.h:131

Referenced by clone_stateblock_constant().

◆ hlsl_new_store_component()

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 
)

Definition at line 1480 of file hlsl.c.

1482{
1483 struct hlsl_block comp_path_block;
1484 struct hlsl_ir_store *store;
1485
1487
1488 if (!(store = hlsl_alloc(ctx, sizeof(*store))))
1489 return false;
1490 init_node(&store->node, HLSL_IR_STORE, NULL, &rhs->loc);
1491
1492 if (!init_deref_from_component_index(ctx, &comp_path_block, &store->lhs, lhs, comp, &rhs->loc))
1493 {
1494 vkd3d_free(store);
1495 return false;
1496 }
1497 hlsl_block_add_block(block, &comp_path_block);
1498 hlsl_src_from_node(&store->rhs, rhs);
1499
1500 if (type_is_single_reg(rhs->data_type))
1501 store->writemask = (1 << rhs->data_type->dimx) - 1;
1502
1504
1505 return true;
1506}
static bool type_is_single_reg(const struct hlsl_type *type)
Definition: hlsl.c:1383
struct hlsl_src rhs
Definition: hlsl.h:871
struct hlsl_deref lhs
Definition: hlsl.h:870
struct hlsl_ir_node node
Definition: hlsl.h:869
unsigned char writemask
Definition: hlsl.h:872

Referenced by lower_matrix_swizzles(), and lower_trig().

◆ hlsl_new_store_index()

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 
)

Definition at line 1448 of file hlsl.c.

1450{
1451 struct hlsl_ir_store *store;
1452 unsigned int i;
1453
1456
1457 if (!(store = hlsl_alloc(ctx, sizeof(*store))))
1458 return NULL;
1459 init_node(&store->node, HLSL_IR_STORE, NULL, loc);
1460
1461 if (!init_deref(ctx, &store->lhs, lhs->var, lhs->path_len + !!idx))
1462 {
1463 vkd3d_free(store);
1464 return NULL;
1465 }
1466 for (i = 0; i < lhs->path_len; ++i)
1467 hlsl_src_from_node(&store->lhs.path[i], lhs->path[i].node);
1468 if (idx)
1469 hlsl_src_from_node(&store->lhs.path[lhs->path_len], idx);
1470
1471 hlsl_src_from_node(&store->rhs, rhs);
1472
1473 if (!writemask && type_is_single_reg(rhs->data_type))
1474 writemask = (1 << rhs->data_type->dimx) - 1;
1475 store->writemask = writemask;
1476
1477 return &store->node;
1478}

Referenced by add_zero_mipmap_level(), hlsl_new_simple_store(), lower_index_loads(), prepend_input_copy(), and split_copy().

◆ hlsl_new_string_constant()

struct hlsl_ir_node * hlsl_new_string_constant ( struct hlsl_ctx *  ctx,
const char *  str,
const struct vkd3d_shader_location *  loc 
)

Definition at line 1571 of file hlsl.c.

1573{
1574 struct hlsl_ir_string_constant *s;
1575
1576 if (!(s = hlsl_alloc(ctx, sizeof(*s))))
1577 return NULL;
1578
1579 init_node(&s->node, HLSL_IR_STRING_CONSTANT, ctx->builtin_types.string, loc);
1580
1581 if (!(s->string = hlsl_strdup(ctx, str)))
1582 {
1583 hlsl_free_instr(&s->node);
1584 return NULL;
1585 }
1586 return &s->node;
1587}
const WCHAR * str

Referenced by clone_string_constant().

◆ hlsl_new_struct_type()

struct hlsl_type * hlsl_new_struct_type ( struct hlsl_ctx *  ctx,
const char *  name,
struct hlsl_struct_field *  fields,
size_t  field_count 
)

Definition at line 901 of file hlsl.c.

903{
904 struct hlsl_type *type;
905
906 if (!(type = hlsl_alloc(ctx, sizeof(*type))))
907 return NULL;
908 type->class = HLSL_CLASS_STRUCT;
909 type->name = name;
910 type->dimy = 1;
911 type->e.record.fields = fields;
912 type->e.record.field_count = field_count;
914
915 list_add_tail(&ctx->types, &type->entry);
916
917 return type;
918}
const char * fields[10]
Definition: parser.c:313
size_t field_count
Definition: hlsl.h:203
const char * name
Definition: hlsl.h:174

◆ hlsl_new_switch()

struct hlsl_ir_node * hlsl_new_switch ( struct hlsl_ctx *  ctx,
struct hlsl_ir_node *  selector,
struct list *  cases,
const struct vkd3d_shader_location *  loc 
)

Definition at line 1682 of file hlsl.c.

1684{
1685 struct hlsl_ir_switch *s;
1686
1687 if (!(s = hlsl_alloc(ctx, sizeof(*s))))
1688 return NULL;
1689 init_node(&s->node, HLSL_IR_SWITCH, NULL, loc);
1690 hlsl_src_from_node(&s->selector, selector);
1691 list_init(&s->cases);
1692 if (cases)
1693 list_move_head(&s->cases, cases);
1694
1695 return &s->node;
1696}
__WINE_SERVER_LIST_INLINE void list_move_head(struct list *dst, struct list *src)
Definition: list.h:196
struct hlsl_src selector
Definition: hlsl.h:676
struct list cases
Definition: hlsl.h:677

Referenced by clone_switch().

◆ hlsl_new_switch_case()

struct hlsl_ir_switch_case * hlsl_new_switch_case ( struct hlsl_ctx *  ctx,
unsigned int  value,
bool  is_default,
struct hlsl_block *  body,
const struct vkd3d_shader_location *  loc 
)

Definition at line 1664 of file hlsl.c.

1666{
1667 struct hlsl_ir_switch_case *c;
1668
1669 if (!(c = hlsl_alloc(ctx, sizeof(*c))))
1670 return NULL;
1671
1672 c->value = value;
1673 c->is_default = is_default;
1674 hlsl_block_init(&c->body);
1675 if (body)
1676 hlsl_block_add_block(&c->body, body);
1677 c->loc = *loc;
1678
1679 return c;
1680}
char * value
Definition: wpp.c:53
struct vkd3d_shader_location loc
Definition: hlsl.h:670
unsigned int value
Definition: hlsl.h:666

Referenced by clone_switch(), and normalize_switch_cases().

◆ hlsl_new_swizzle()

struct hlsl_ir_node * hlsl_new_swizzle ( struct hlsl_ctx *  ctx,
uint32_t  s,
unsigned int  components,
struct hlsl_ir_node *  val,
const struct vkd3d_shader_location *  loc 
)

Definition at line 1847 of file hlsl.c.

1849{
1850 struct hlsl_ir_swizzle *swizzle;
1851 struct hlsl_type *type;
1852
1853 if (!(swizzle = hlsl_alloc(ctx, sizeof(*swizzle))))
1854 return NULL;
1856 if (components == 1)
1857 type = hlsl_get_scalar_type(ctx, val->data_type->e.numeric.type);
1858 else
1859 type = hlsl_get_vector_type(ctx, val->data_type->e.numeric.type, components);
1860 init_node(&swizzle->node, HLSL_IR_SWIZZLE, type, loc);
1862 swizzle->swizzle = s;
1863 return &swizzle->node;
1864}
static bool hlsl_is_numeric_type(const struct hlsl_type *type)
Definition: hlsl.h:1388

Referenced by clone_swizzle(), copy_propagation_replace_with_single_instr(), fold_swizzle_chains(), lower_broadcasts(), lower_dot(), lower_int_dot(), lower_narrowing_casts(), lower_nonconstant_array_loads(), lower_nonconstant_vector_derefs(), and lower_trig().

◆ hlsl_new_synthetic_var()

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 
)

Definition at line 1349 of file hlsl.c.

1351{
1353 struct hlsl_ir_var *var;
1354
1355 if (!(string = hlsl_get_string_buffer(ctx)))
1356 return NULL;
1357 vkd3d_string_buffer_printf(string, "<%s-%u>", template, ctx->internal_name_counter++);
1358 var = hlsl_new_synthetic_var_named(ctx, string->buffer, type, loc, true);
1360 return var;
1361}
struct hlsl_ir_var * hlsl_new_synthetic_var_named(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type, const struct vkd3d_shader_location *loc, bool dummy_scope)
Definition: hlsl.c:1363
struct vkd3d_shader_location loc
Definition: hlsl.h:455

Referenced by add_zero_mipmap_level(), hlsl_new_func_decl(), lower_index_loads(), lower_matrix_swizzles(), lower_nonconstant_array_loads(), and lower_trig().

◆ hlsl_new_synthetic_var_named()

struct hlsl_ir_var * hlsl_new_synthetic_var_named ( struct hlsl_ctx *  ctx,
const char *  name,
struct hlsl_type *  type,
const struct vkd3d_shader_location *  loc,
bool  dummy_scope 
)

Definition at line 1363 of file hlsl.c.

1365{
1366 struct hlsl_ir_var *var;
1367 const char *name_copy;
1368
1369 if (!(name_copy = hlsl_strdup(ctx, name)))
1370 return NULL;
1371 var = hlsl_new_var(ctx, name_copy, type, loc, NULL, 0, NULL);
1372 if (var)
1373 {
1374 if (dummy_scope)
1375 list_add_tail(&ctx->dummy_scope->vars, &var->scope_entry);
1376 else
1377 list_add_tail(&ctx->globals->vars, &var->scope_entry);
1378 var->is_synthetic = true;
1379 }
1380 return var;
1381}
struct hlsl_ir_var * hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type, const struct vkd3d_shader_location *loc, const struct hlsl_semantic *semantic, uint32_t modifiers, const struct hlsl_reg_reservation *reg_reservation)
Definition: hlsl.c:1311

Referenced by hlsl_new_synthetic_var(), and lower_combined_samples().

◆ hlsl_new_ternary_expr()

struct hlsl_ir_node * hlsl_new_ternary_expr ( struct hlsl_ctx *  ctx,
enum hlsl_ir_expr_op  op,
struct hlsl_ir_node *  arg1,
struct hlsl_ir_node *  arg2,
struct hlsl_ir_node *  arg3 
)

Definition at line 1627 of file hlsl.c.

1629{
1630 struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = {arg1, arg2, arg3};
1631
1632 VKD3D_ASSERT(hlsl_types_are_equal(arg1->data_type, arg2->data_type));
1633 VKD3D_ASSERT(hlsl_types_are_equal(arg1->data_type, arg3->data_type));
1634 return hlsl_new_expr(ctx, op, operands, arg1->data_type, &arg1->loc);
1635}

Referenced by lower_slt(), and lower_trig().

◆ hlsl_new_texture_type()

struct hlsl_type * hlsl_new_texture_type ( struct hlsl_ctx *  ctx,
enum hlsl_sampler_dim  dim,
struct hlsl_type *  format,
unsigned int  sample_count 
)

Definition at line 920 of file hlsl.c.

922{
923 struct hlsl_type *type;
924
925 if (!(type = hlsl_alloc(ctx, sizeof(*type))))
926 return NULL;
927 type->class = HLSL_CLASS_TEXTURE;
928 type->dimx = 4;
929 type->dimy = 1;
930 type->sampler_dim = dim;
931 type->e.resource.format = format;
932 type->sample_count = sample_count;
934 list_add_tail(&ctx->types, &type->entry);
935 return type;
936}
unsigned int sample_count
Definition: hlsl.h:190

Referenced by lower_combined_samples().

◆ hlsl_new_uav_type()

struct hlsl_type * hlsl_new_uav_type ( struct hlsl_ctx *  ctx,
enum hlsl_sampler_dim  dim,
struct hlsl_type *  format,
bool  rasteriser_ordered 
)

Definition at line 938 of file hlsl.c.

940{
941 struct hlsl_type *type;
942
943 if (!(type = hlsl_alloc(ctx, sizeof(*type))))
944 return NULL;
945 type->class = HLSL_CLASS_UAV;
946 type->dimx = format->dimx;
947 type->dimy = 1;
948 type->sampler_dim = dim;
949 type->e.resource.format = format;
950 type->e.resource.rasteriser_ordered = rasteriser_ordered;
952 list_add_tail(&ctx->types, &type->entry);
953 return type;
954}
bool rasteriser_ordered
Definition: hlsl.h:219

◆ hlsl_new_uint_constant()

◆ hlsl_new_unary_expr()

◆ hlsl_new_var()

struct hlsl_ir_var * hlsl_new_var ( struct hlsl_ctx *  ctx,
const char *  name,
struct hlsl_type *  type,
const struct vkd3d_shader_location *  loc,
const struct hlsl_semantic *  semantic,
uint32_t  modifiers,
const struct hlsl_reg_reservation *  reg_reservation 
)

Definition at line 1311 of file hlsl.c.

1314{
1315 struct hlsl_ir_var *var;
1316 unsigned int k;
1317
1318 if (!(var = hlsl_alloc(ctx, sizeof(*var))))
1319 return NULL;
1320
1321 var->name = name;
1322 var->data_type = type;
1323 var->loc = *loc;
1324 if (semantic)
1325 var->semantic = *semantic;
1326 var->storage_modifiers = modifiers;
1327 if (reg_reservation)
1328 var->reg_reservation = *reg_reservation;
1329
1330 for (k = 0; k <= HLSL_REGSET_LAST_OBJECT; ++k)
1331 {
1332 unsigned int i, obj_count = type->reg_size[k];
1333
1334 if (obj_count == 0)
1335 continue;
1336
1337 if (!(var->objects_usage[k] = hlsl_calloc(ctx, obj_count, sizeof(*var->objects_usage[0]))))
1338 {
1339 for (i = 0; i < k; ++i)
1340 vkd3d_free(var->objects_usage[i]);
1341 vkd3d_free(var);
1342 return NULL;
1343 }
1344 }
1345
1346 return var;
1347}
static void * hlsl_calloc(struct hlsl_ctx *ctx, size_t count, size_t size)
Definition: hlsl.h:1309
struct hlsl_reg_reservation reg_reservation
Definition: hlsl.h:463

Referenced by add_semantic_var(), hlsl_new_synthetic_var_named(), and prepend_uniform_copy().

◆ hlsl_new_var_load()

◆ hlsl_new_vsir_instruction_ref()

struct hlsl_ir_node * hlsl_new_vsir_instruction_ref ( struct hlsl_ctx *  ctx,
unsigned int  vsir_instr_idx,
struct hlsl_type *  type,
const struct hlsl_reg *  reg,
const struct vkd3d_shader_location *  loc 
)

Definition at line 1698 of file hlsl.c.

1700{
1701 struct hlsl_ir_vsir_instruction_ref *vsir_instr;
1702
1703 if (!(vsir_instr = hlsl_alloc(ctx, sizeof(*vsir_instr))))
1704 return NULL;
1705 init_node(&vsir_instr->node, HLSL_IR_VSIR_INSTRUCTION_REF, type, loc);
1706 vsir_instr->vsir_instr_idx = vsir_instr_idx;
1707
1708 if (reg)
1709 vsir_instr->node.reg = *reg;
1710
1711 return &vsir_instr->node;
1712}
static int reg
Definition: i386-dis.c:1290
struct hlsl_ir_node node
Definition: hlsl.h:941
unsigned int vsir_instr_idx
Definition: hlsl.h:944

Referenced by add_last_vsir_instr_to_block(), and replace_instr_with_last_vsir_instr().

◆ hlsl_node_type_to_string()

const char * hlsl_node_type_to_string ( enum hlsl_ir_node_type  type)

Definition at line 2949 of file hlsl.c.

2950{
2951 static const char * const names[] =
2952 {
2953 [HLSL_IR_CALL ] = "HLSL_IR_CALL",
2954 [HLSL_IR_CONSTANT ] = "HLSL_IR_CONSTANT",
2955 [HLSL_IR_EXPR ] = "HLSL_IR_EXPR",
2956 [HLSL_IR_IF ] = "HLSL_IR_IF",
2957 [HLSL_IR_INDEX ] = "HLSL_IR_INDEX",
2958 [HLSL_IR_LOAD ] = "HLSL_IR_LOAD",
2959 [HLSL_IR_LOOP ] = "HLSL_IR_LOOP",
2960 [HLSL_IR_JUMP ] = "HLSL_IR_JUMP",
2961 [HLSL_IR_RESOURCE_LOAD ] = "HLSL_IR_RESOURCE_LOAD",
2962 [HLSL_IR_RESOURCE_STORE ] = "HLSL_IR_RESOURCE_STORE",
2963 [HLSL_IR_STRING_CONSTANT] = "HLSL_IR_STRING_CONSTANT",
2964 [HLSL_IR_STORE ] = "HLSL_IR_STORE",
2965 [HLSL_IR_SWITCH ] = "HLSL_IR_SWITCH",
2966 [HLSL_IR_SWIZZLE ] = "HLSL_IR_SWIZZLE",
2967
2968 [HLSL_IR_COMPILE] = "HLSL_IR_COMPILE",
2969 [HLSL_IR_SAMPLER_STATE] = "HLSL_IR_SAMPLER_STATE",
2970 [HLSL_IR_STATEBLOCK_CONSTANT] = "HLSL_IR_STATEBLOCK_CONSTANT",
2971 [HLSL_IR_VSIR_INSTRUCTION_REF] = "HLSL_IR_VSIR_INSTRUCTION_REF",
2972 };
2973
2974 if (type >= ARRAY_SIZE(names))
2975 return "Unexpected node type";
2976 return names[type];
2977}

Referenced by hlsl_offset_from_deref_safe(), sm1_generate_vsir_block(), and write_sm4_block().

◆ hlsl_note()

void void void void hlsl_note ( struct hlsl_ctx *  ctx,
const struct vkd3d_shader_location *  loc,
enum vkd3d_shader_log_level  level,
const char *  fmt,
  ... 
)

◆ hlsl_offset_from_deref()

bool hlsl_offset_from_deref ( struct hlsl_ctx *  ctx,
const struct hlsl_deref *  deref,
unsigned int *  offset 
)

Definition at line 5949 of file hlsl_codegen.c.

5950{
5952 struct hlsl_ir_node *offset_node = deref->rel_offset.node;
5953 unsigned int size;
5954
5955 *offset = deref->const_offset;
5956
5957 if (offset_node)
5958 {
5959 /* We should always have generated a cast to UINT. */
5960 VKD3D_ASSERT(offset_node->data_type->class == HLSL_CLASS_SCALAR
5961 && offset_node->data_type->e.numeric.type == HLSL_TYPE_UINT);
5962 VKD3D_ASSERT(offset_node->type != HLSL_IR_CONSTANT);
5963 return false;
5964 }
5965
5966 size = deref->var->data_type->reg_size[regset];
5967 if (*offset >= size)
5968 {
5969 /* FIXME: Report a more specific location for the constant deref. */
5971 "Dereference is out of bounds. %u/%u", *offset, size);
5972 return false;
5973 }
5974
5975 return true;
5976}
GLintptr offset
Definition: glext.h:5920
enum hlsl_regset hlsl_deref_get_regset(struct hlsl_ctx *ctx, const struct hlsl_deref *deref)
Definition: hlsl.c:327
hlsl_regset
Definition: hlsl.h:146
D3DXREGISTER_SET regset
Definition: shader.c:5881
@ VKD3D_SHADER_ERROR_HLSL_OFFSET_OUT_OF_BOUNDS

Referenced by hlsl_offset_from_deref_safe().

◆ hlsl_offset_from_deref_safe()

unsigned int hlsl_offset_from_deref_safe ( struct hlsl_ctx *  ctx,
const struct hlsl_deref *  deref 
)

Definition at line 5978 of file hlsl_codegen.c.

5979{
5980 unsigned int offset;
5981
5982 if (hlsl_offset_from_deref(ctx, deref, &offset))
5983 return offset;
5984
5985 if (deref->rel_offset.node)
5986 hlsl_fixme(ctx, &deref->rel_offset.node->loc, "Dereference with non-constant offset of type %s.",
5987 hlsl_node_type_to_string(deref->rel_offset.node->type));
5988
5989 return 0;
5990}
void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, const char *fmt,...)
Definition: hlsl.c:58
const char * hlsl_node_type_to_string(enum hlsl_ir_node_type type)
Definition: hlsl.c:2949
bool hlsl_offset_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref, unsigned int *offset)

Referenced by hlsl_reg_from_deref(), sm1_generate_vsir_init_src_param_from_deref(), sm4_numeric_register_from_deref(), and sm4_register_from_deref().

◆ hlsl_pop_scope()

void hlsl_pop_scope ( struct hlsl_ctx *  ctx)

Definition at line 2653 of file hlsl.c.

2654{
2655 struct hlsl_scope *prev_scope = ctx->cur_scope->upper;
2656
2657 VKD3D_ASSERT(prev_scope);
2658 TRACE("Popping current scope.\n");
2659 ctx->cur_scope = prev_scope;
2660}

Referenced by hlsl_compile_internal_function().

◆ hlsl_push_scope()

void void void void void hlsl_push_scope ( struct hlsl_ctx *  ctx)

Definition at line 2642 of file hlsl.c.

2643{
2644 struct hlsl_scope *new_scope;
2645
2646 if (!(new_scope = hlsl_new_scope(ctx, ctx->cur_scope)))
2647 return;
2648
2649 TRACE("Pushing a new scope.\n");
2650 ctx->cur_scope = new_scope;
2651}
static struct hlsl_scope * hlsl_new_scope(struct hlsl_ctx *ctx, struct hlsl_scope *upper)
Definition: hlsl.c:2629

Referenced by hlsl_compile_internal_function(), and hlsl_ctx_init().

◆ hlsl_realloc()

static void * hlsl_realloc ( struct hlsl_ctx *  ctx,
void *  ptr,
size_t  size 
)
inlinestatic

Definition at line 1318 of file hlsl.h.

1319{
1320 void *ret = vkd3d_realloc(ptr, size);
1321
1322 if (!ret)
1324 return ret;
1325}
static void * vkd3d_realloc(void *ptr, size_t size)
Definition: vkd3d_memory.h:36

◆ hlsl_reg_from_deref()

struct hlsl_reg hlsl_reg_from_deref ( struct hlsl_ctx *  ctx,
const struct hlsl_deref *  deref 
)

Definition at line 5992 of file hlsl_codegen.c.

5993{
5994 const struct hlsl_ir_var *var = deref->var;
5995 struct hlsl_reg ret = var->regs[HLSL_REGSET_NUMERIC];
5996 unsigned int offset = hlsl_offset_from_deref_safe(ctx, deref);
5997
5998 VKD3D_ASSERT(deref->data_type);
6000
6001 ret.index += offset / 4;
6002 ret.id += offset / 4;
6003
6004 ret.writemask = 0xf & (0xf << (offset % 4));
6005 if (var->regs[HLSL_REGSET_NUMERIC].writemask)
6006 ret.writemask = hlsl_combine_writemasks(var->regs[HLSL_REGSET_NUMERIC].writemask, ret.writemask);
6007
6008 return ret;
6009}
unsigned int hlsl_combine_writemasks(unsigned int first, unsigned int second)
Definition: hlsl.c:4026
unsigned int hlsl_offset_from_deref_safe(struct hlsl_ctx *ctx, const struct hlsl_deref *deref)
Definition: hlsl.h:282

Referenced by sm1_generate_vsir_init_dst_param_from_deref(), sm1_generate_vsir_init_src_param_from_deref(), and sm4_register_from_deref().

◆ hlsl_regset_index_from_deref()

bool hlsl_regset_index_from_deref ( struct hlsl_ctx *  ctx,
const struct hlsl_deref *  deref,
enum hlsl_regset  regset,
unsigned int *  index 
)

Definition at line 5876 of file hlsl_codegen.c.

5878{
5879 struct hlsl_type *type = deref->var->data_type;
5880 bool index_is_constant = true;
5881 unsigned int i;
5882
5883 *index = 0;
5884
5885 for (i = 0; i < deref->path_len; ++i)
5886 {
5887 struct hlsl_ir_node *path_node = deref->path[i].node;
5888 unsigned int idx = 0;
5889
5890 VKD3D_ASSERT(path_node);
5891 if (path_node->type == HLSL_IR_CONSTANT)
5892 {
5893 /* We should always have generated a cast to UINT. */
5894 VKD3D_ASSERT(path_node->data_type->class == HLSL_CLASS_SCALAR
5895 && path_node->data_type->e.numeric.type == HLSL_TYPE_UINT);
5896
5897 idx = hlsl_ir_constant(path_node)->value.u[0].u;
5898
5899 switch (type->class)
5900 {
5901 case HLSL_CLASS_ARRAY:
5902 if (idx >= type->e.array.elements_count)
5903 return false;
5904
5905 *index += idx * type->e.array.type->reg_size[regset];
5906 break;
5907
5908 case HLSL_CLASS_STRUCT:
5909 *index += type->e.record.fields[idx].reg_offset[regset];
5910 break;
5911
5912 case HLSL_CLASS_MATRIX:
5913 *index += 4 * idx;
5914 break;
5915
5916 default:
5918 }
5919 }
5920 else
5921 {
5922 index_is_constant = false;
5923
5924 switch (type->class)
5925 {
5926 case HLSL_CLASS_ARRAY:
5927 idx = type->e.array.elements_count - 1;
5928 *index += idx * type->e.array.type->reg_size[regset];
5929 break;
5930
5931 case HLSL_CLASS_MATRIX:
5933 *index += idx * 4;
5934 break;
5935
5936 default:
5938 }
5939 }
5940
5942 }
5943
5944 VKD3D_ASSERT(!(regset <= HLSL_REGSET_LAST_OBJECT) || (type->reg_size[regset] == 1));
5945 VKD3D_ASSERT(!(regset == HLSL_REGSET_NUMERIC) || type->reg_size[regset] <= 4);
5946 return index_is_constant;
5947}

Referenced by register_deref_usage(), and track_object_components_sampler_dim().

◆ hlsl_release_string_buffer()

◆ hlsl_replace_node()

void hlsl_replace_node ( struct hlsl_ir_node *  old,
struct hlsl_ir_node *  new 
)

Definition at line 3626 of file hlsl.c.

3627{
3628 struct hlsl_src *src, *next;
3629
3630 VKD3D_ASSERT(old->data_type == new->data_type || old->data_type->dimx == new->data_type->dimx);
3631 VKD3D_ASSERT(old->data_type == new->data_type || old->data_type->dimy == new->data_type->dimy);
3632
3634 {
3636 hlsl_src_from_node(src, new);
3637 }
3638 list_remove(&old->entry);
3639 hlsl_free_instr(old);
3640}
struct list uses
Definition: hlsl.h:353
Definition: hlsl.h:382
#define new(TYPE, numElems)
Definition: treelist.c:54

Referenced by call_lower_func(), copy_propagation_replace_with_constant_vector(), copy_propagation_replace_with_single_instr(), fold_redundant_casts(), fold_swizzle_chains(), hlsl_fold_constant_exprs(), hlsl_fold_constant_identities(), hlsl_fold_constant_swizzles(), lower_null_constant(), remove_trivial_swizzles(), replace_instr_with_last_vsir_instr(), and replace_state_block_constant().

◆ hlsl_run_const_passes()

void hlsl_run_const_passes ( struct hlsl_ctx *  ctx,
struct hlsl_block *  body 
)

Definition at line 6397 of file hlsl_codegen.c.

6398{
6399 bool progress;
6400
6402
6405 do
6406 {
6409 }
6410 while (progress);
6412
6421
6422 do
6423 {
6431 } while (progress);
6432}
bool hlsl_fold_constant_swizzles(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
bool hlsl_fold_constant_identities(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
static bool remove_trivial_swizzles(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
static bool lower_narrowing_casts(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
static bool lower_int_division(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
static bool fold_swizzle_chains(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
static bool lower_casts_to_bool(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
bool hlsl_copy_propagation_execute(struct hlsl_ctx *ctx, struct hlsl_block *block)
bool hlsl_transform_ir(struct hlsl_ctx *ctx, bool(*func)(struct hlsl_ctx *ctx, struct hlsl_ir_node *, void *), struct hlsl_block *block, void *context)
Definition: hlsl_codegen.c:642
static bool split_struct_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
static bool split_matrix_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
static bool lower_int_abs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
static bool lower_broadcasts(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
static bool lower_float_modulus(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
static bool lower_matrix_swizzles(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
static bool lower_int_modulus(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
static bool split_array_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
static bool remove_trivial_conditional_branches(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
static bool lower_int_dot(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
static bool fold_redundant_casts(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)

Referenced by loop_unrolling_unroll_loop(), process_entry_function(), and resolve_fx_4_state_block_values().

◆ hlsl_sampler_dim_count()

static unsigned int hlsl_sampler_dim_count ( enum hlsl_sampler_dim  dim)
inlinestatic

Definition at line 1393 of file hlsl.h.

1394{
1395 switch (dim)
1396 {
1401 return 1;
1405 return 2;
1410 return 3;
1412 return 4;
1413 default:
1415 }
1416}

Referenced by lower_index_loads(), and write_sm4_ld().

◆ hlsl_scope_add_type()

bool hlsl_scope_add_type ( struct hlsl_scope *  scope,
struct hlsl_type *  type 
)

Definition at line 1285 of file hlsl.c.

1286{
1287 if (hlsl_get_type(scope, type->name, false, false))
1288 return false;
1289
1290 rb_put(&scope->types, type->name, &type->scope_entry);
1291 return true;
1292}

Referenced by declare_predefined_types().

◆ hlsl_sm1_base_type()

D3DXPARAMETER_TYPE hlsl_sm1_base_type ( const struct hlsl_type *  type)

Definition at line 1575 of file d3dbc.c.

1576{
1577 switch (type->class)
1578 {
1579 case HLSL_CLASS_SCALAR:
1580 case HLSL_CLASS_VECTOR:
1581 case HLSL_CLASS_MATRIX:
1582 switch (type->e.numeric.type)
1583 {
1584 case HLSL_TYPE_BOOL:
1585 return D3DXPT_BOOL;
1586 /* Actually double behaves differently depending on DLL version:
1587 * For <= 36, it maps to D3DXPT_FLOAT.
1588 * For 37-40, it maps to zero (D3DXPT_VOID).
1589 * For >= 41, it maps to 39, which is D3D_SVT_DOUBLE (note D3D_SVT_*
1590 * values are mostly compatible with D3DXPT_*).
1591 * However, the latter two cases look like bugs, and a reasonable
1592 * application certainly wouldn't know what to do with them.
1593 * For fx_2_0 it's always D3DXPT_FLOAT regardless of DLL version. */
1594 case HLSL_TYPE_DOUBLE:
1595 case HLSL_TYPE_FLOAT:
1596 case HLSL_TYPE_HALF:
1597 return D3DXPT_FLOAT;
1598 case HLSL_TYPE_INT:
1599 case HLSL_TYPE_UINT:
1600 return D3DXPT_INT;
1601 default:
1603 }
1604
1605 case HLSL_CLASS_SAMPLER:
1606 switch (type->sampler_dim)
1607 {
1609 return D3DXPT_SAMPLER1D;
1611 return D3DXPT_SAMPLER2D;
1613 return D3DXPT_SAMPLER3D;
1615 return D3DXPT_SAMPLERCUBE;
1617 return D3DXPT_SAMPLER;
1618 default:
1619 ERR("Invalid dimension %#x.\n", type->sampler_dim);
1621 }
1622 break;
1623
1624 case HLSL_CLASS_TEXTURE:
1625 switch (type->sampler_dim)
1626 {
1628 return D3DXPT_TEXTURE1D;
1630 return D3DXPT_TEXTURE2D;
1632 return D3DXPT_TEXTURE3D;
1634 return D3DXPT_TEXTURECUBE;
1636 return D3DXPT_TEXTURE;
1637 default:
1638 ERR("Invalid dimension %#x.\n", type->sampler_dim);
1640 }
1641 break;
1642
1643 case HLSL_CLASS_ARRAY:
1644 return hlsl_sm1_base_type(type->e.array.type);
1645
1646 case HLSL_CLASS_STRUCT:
1647 return D3DXPT_VOID;
1648
1649 case HLSL_CLASS_STRING:
1650 return D3DXPT_STRING;
1651
1653 return D3DXPT_PIXELSHADER;
1654
1656 return D3DXPT_VERTEXSHADER;
1657
1661 case HLSL_CLASS_ERROR:
1662 case HLSL_CLASS_PASS:
1666 case HLSL_CLASS_UAV:
1667 case HLSL_CLASS_VOID:
1674 case HLSL_CLASS_NULL:
1675 break;
1676 }
1677
1679}
D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type)
Definition: d3dbc.c:1575
@ D3DXPT_STRING
Definition: d3dx9shader.h:77
@ D3DXPT_TEXTURE
Definition: d3dx9shader.h:78
@ D3DXPT_SAMPLER3D
Definition: d3dx9shader.h:86
@ D3DXPT_VERTEXSHADER
Definition: d3dx9shader.h:89
@ D3DXPT_TEXTURE1D
Definition: d3dx9shader.h:79
@ D3DXPT_SAMPLERCUBE
Definition: d3dx9shader.h:87
@ D3DXPT_FLOAT
Definition: d3dx9shader.h:76
@ D3DXPT_TEXTURECUBE
Definition: d3dx9shader.h:82
@ D3DXPT_PIXELSHADER
Definition: d3dx9shader.h:88
@ D3DXPT_BOOL
Definition: d3dx9shader.h:74
@ D3DXPT_INT
Definition: d3dx9shader.h:75
@ D3DXPT_VOID
Definition: d3dx9shader.h:73
@ D3DXPT_SAMPLER
Definition: d3dx9shader.h:83
@ D3DXPT_SAMPLER1D
Definition: d3dx9shader.h:84
@ D3DXPT_SAMPLER2D
Definition: d3dx9shader.h:85
@ D3DXPT_TEXTURE3D
Definition: d3dx9shader.h:81
@ D3DXPT_TEXTURE2D
Definition: d3dx9shader.h:80

Referenced by hlsl_sm1_base_type(), write_fx_2_parameter(), and write_sm1_type().

◆ hlsl_sm1_class()

D3DXPARAMETER_CLASS hlsl_sm1_class ( const struct hlsl_type *  type)

Definition at line 1528 of file d3dbc.c.

1529{
1530 switch (type->class)
1531 {
1532 case HLSL_CLASS_ARRAY:
1533 return hlsl_sm1_class(type->e.array.type);
1534 case HLSL_CLASS_MATRIX:
1536 if (type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR)
1537 return D3DXPC_MATRIX_COLUMNS;
1538 else
1539 return D3DXPC_MATRIX_ROWS;
1540 case HLSL_CLASS_SCALAR:
1541 return D3DXPC_SCALAR;
1542 case HLSL_CLASS_STRUCT:
1543 return D3DXPC_STRUCT;
1544 case HLSL_CLASS_VECTOR:
1545 return D3DXPC_VECTOR;
1547 case HLSL_CLASS_SAMPLER:
1548 case HLSL_CLASS_STRING:
1549 case HLSL_CLASS_TEXTURE:
1551 return D3DXPC_OBJECT;
1555 case HLSL_CLASS_ERROR:
1556 case HLSL_CLASS_PASS:
1560 case HLSL_CLASS_UAV:
1561 case HLSL_CLASS_VOID:
1568 case HLSL_CLASS_NULL:
1569 break;
1570 }
1571
1573}
D3DXPARAMETER_CLASS hlsl_sm1_class(const struct hlsl_type *type)
Definition: d3dbc.c:1528
@ D3DXPC_SCALAR
Definition: d3dx9shader.h:62
@ D3DXPC_MATRIX_COLUMNS
Definition: d3dx9shader.h:65
@ D3DXPC_STRUCT
Definition: d3dx9shader.h:67
@ D3DXPC_MATRIX_ROWS
Definition: d3dx9shader.h:64
@ D3DXPC_VECTOR
Definition: d3dx9shader.h:63
@ D3DXPC_OBJECT
Definition: d3dx9shader.h:66
#define HLSL_MODIFIERS_MAJORITY_MASK
Definition: hlsl.h:427

Referenced by get_fx_2_type_class(), hlsl_sm1_class(), and write_sm1_type().

◆ hlsl_sprintf_alloc()

char * hlsl_sprintf_alloc ( struct hlsl_ctx *  ctx,
const char *  fmt,
  ... 
)

◆ hlsl_src_from_node()

◆ hlsl_src_remove()

◆ hlsl_state_block_add_entry()

bool hlsl_state_block_add_entry ( struct hlsl_state_block *  state_block,
struct hlsl_state_block_entry *  entry 
)

Definition at line 1925 of file hlsl.c.

1927{
1928 if (!vkd3d_array_reserve((void **)&state_block->entries,
1929 &state_block->capacity, state_block->count + 1,
1930 sizeof(*state_block->entries)))
1931 return false;
1932
1933 state_block->entries[state_block->count++] = entry;
1934 return true;
1935}
size_t capacity
Definition: hlsl.h:576

Referenced by hlsl_new_sampler_state().

◆ hlsl_strdup()

static char * hlsl_strdup ( struct hlsl_ctx *  ctx,
const char *  string 
)
inlinestatic

◆ hlsl_swizzle_from_writemask()

uint32_t hlsl_swizzle_from_writemask ( unsigned int  writemask)

Definition at line 4001 of file hlsl.c.

4002{
4003 static const unsigned int swizzles[16] =
4004 {
4005 0,
4006 HLSL_SWIZZLE(X, X, X, X),
4007 HLSL_SWIZZLE(Y, Y, Y, Y),
4008 HLSL_SWIZZLE(X, Y, X, X),
4009 HLSL_SWIZZLE(Z, Z, Z, Z),
4010 HLSL_SWIZZLE(X, Z, X, X),
4011 HLSL_SWIZZLE(Y, Z, X, X),
4012 HLSL_SWIZZLE(X, Y, Z, X),
4013 HLSL_SWIZZLE(W, W, W, W),
4014 HLSL_SWIZZLE(X, W, X, X),
4015 HLSL_SWIZZLE(Y, W, X, X),
4016 HLSL_SWIZZLE(X, Y, W, X),
4017 HLSL_SWIZZLE(Z, W, X, X),
4018 HLSL_SWIZZLE(X, Z, W, X),
4019 HLSL_SWIZZLE(Y, Z, W, X),
4020 HLSL_SWIZZLE(X, Y, Z, W),
4021 };
4022
4023 return swizzles[writemask & 0xf];
4024}

Referenced by generate_vsir_get_src_swizzle(), generate_vsir_instr_swizzle(), lower_int_dot(), lower_trig(), sm4_numeric_register_from_deref(), sm4_src_from_deref(), sm4_src_from_node(), and write_sm4_swizzle().

◆ hlsl_swizzle_get_component()

◆ hlsl_transform_ir()

bool hlsl_transform_ir ( struct hlsl_ctx *  ctx,
bool(*)(struct hlsl_ctx *ctx, struct hlsl_ir_node *, void *)  func,
struct hlsl_block *  block,
void *  context 
)

Definition at line 642 of file hlsl_codegen.c.

644{
645 struct hlsl_ir_node *instr, *next;
646 bool progress = false;
647
648 LIST_FOR_EACH_ENTRY_SAFE(instr, next, &block->instrs, struct hlsl_ir_node, entry)
649 {
650 if (instr->type == HLSL_IR_IF)
651 {
652 struct hlsl_ir_if *iff = hlsl_ir_if(instr);
653
656 }
657 else if (instr->type == HLSL_IR_LOOP)
658 {
660 }
661 else if (instr->type == HLSL_IR_SWITCH)
662 {
663 struct hlsl_ir_switch *s = hlsl_ir_switch(instr);
664 struct hlsl_ir_switch_case *c;
665
667 {
669 }
670 }
671
672 progress |= func(ctx, instr, context);
673 }
674
675 return progress;
676}
Definition: http.c:7252

Referenced by find_recursive_calls(), hlsl_run_const_passes(), hlsl_transform_ir(), lower_ir(), process_entry_function(), resolve_fx_4_state_block_values(), and transform_derefs().

◆ hlsl_type_clone()

struct hlsl_type * hlsl_type_clone ( struct hlsl_ctx *  ctx,
struct hlsl_type *  old,
unsigned int  default_majority,
uint32_t  modifiers 
)

Definition at line 1183 of file hlsl.c.

1185{
1186 struct hlsl_type *type;
1187
1188 if (!(type = hlsl_alloc(ctx, sizeof(*type))))
1189 return NULL;
1190
1191 if (old->name)
1192 {
1193 type->name = hlsl_strdup(ctx, old->name);
1194 if (!type->name)
1195 {
1197 return NULL;
1198 }
1199 }
1200 type->class = old->class;
1201 type->dimx = old->dimx;
1202 type->dimy = old->dimy;
1203 type->modifiers = old->modifiers | modifiers;
1204 if (!(type->modifiers & HLSL_MODIFIERS_MAJORITY_MASK))
1205 type->modifiers |= default_majority;
1206 type->sampler_dim = old->sampler_dim;
1207 type->is_minimum_precision = old->is_minimum_precision;
1208 type->sample_count = old->sample_count;
1209
1210 switch (old->class)
1211 {
1212 case HLSL_CLASS_SCALAR:
1213 case HLSL_CLASS_VECTOR:
1214 case HLSL_CLASS_MATRIX:
1215 type->e.numeric.type = old->e.numeric.type;
1216 break;
1217
1218 case HLSL_CLASS_ARRAY:
1219 if (!(type->e.array.type = hlsl_type_clone(ctx, old->e.array.type, default_majority, modifiers)))
1220 {
1221 vkd3d_free((void *)type->name);
1223 return NULL;
1224 }
1225 type->e.array.elements_count = old->e.array.elements_count;
1226 break;
1227
1228 case HLSL_CLASS_STRUCT:
1229 {
1230 size_t field_count = old->e.record.field_count, i;
1231
1232 type->e.record.field_count = field_count;
1233
1234 if (!(type->e.record.fields = hlsl_calloc(ctx, field_count, sizeof(*type->e.record.fields))))
1235 {
1236 vkd3d_free((void *)type->name);
1238 return NULL;
1239 }
1240
1241 for (i = 0; i < field_count; ++i)
1242 {
1243 const struct hlsl_struct_field *src_field = &old->e.record.fields[i];
1244 struct hlsl_struct_field *dst_field = &type->e.record.fields[i];
1245
1246 dst_field->loc = src_field->loc;
1247 if (!(dst_field->type = hlsl_type_clone(ctx, src_field->type, default_majority, modifiers)))
1248 {
1249 vkd3d_free(type->e.record.fields);
1250 vkd3d_free((void *)type->name);
1252 return NULL;
1253 }
1254 dst_field->name = hlsl_strdup(ctx, src_field->name);
1255 if (src_field->semantic.name)
1256 {
1257 dst_field->semantic.name = hlsl_strdup(ctx, src_field->semantic.name);
1258 dst_field->semantic.index = src_field->semantic.index;
1259 }
1260 }
1261 break;
1262 }
1263
1264 case HLSL_CLASS_UAV:
1265 type->e.resource.rasteriser_ordered = old->e.resource.rasteriser_ordered;
1266 /* fall through */
1267 case HLSL_CLASS_TEXTURE:
1268 type->e.resource.format = old->e.resource.format;
1269 break;
1270
1272 type->e.version = old->e.version;
1273 break;
1274
1275 default:
1276 break;
1277 }
1278
1280
1281 list_add_tail(&ctx->types, &type->entry);
1282 return type;
1283}
struct hlsl_type * hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old, unsigned int default_majority, uint32_t modifiers)
Definition: hlsl.c:1183
char * name
Definition: wpp.c:52
const char * name
Definition: hlsl.h:262
struct hlsl_type * type
Definition: hlsl.h:261
struct hlsl_semantic semantic
Definition: hlsl.h:263
struct vkd3d_shader_location loc
Definition: hlsl.h:260
uint32_t is_minimum_precision
Definition: hlsl.h:234
unsigned int version
Definition: hlsl.h:222
struct hlsl_type::@5997::@6000 array
struct hlsl_type::@5997::@6001 resource
struct hlsl_type::@5997::@5999 record

Referenced by hlsl_type_clone().

◆ hlsl_type_component_count()

unsigned int hlsl_type_component_count ( const struct hlsl_type *  type)

Definition at line 1042 of file hlsl.c.

1043{
1044 switch (type->class)
1045 {
1046 case HLSL_CLASS_SCALAR:
1047 case HLSL_CLASS_VECTOR:
1048 case HLSL_CLASS_MATRIX:
1049 return type->dimx * type->dimy;
1050
1051 case HLSL_CLASS_STRUCT:
1052 {
1053 unsigned int count = 0, i;
1054
1055 for (i = 0; i < type->e.record.field_count; ++i)
1056 count += hlsl_type_component_count(type->e.record.fields[i].type);
1057 return count;
1058 }
1059
1060 case HLSL_CLASS_ARRAY:
1061 return hlsl_type_component_count(type->e.array.type) * type->e.array.elements_count;
1062
1064 return hlsl_type_component_count(type->e.resource.format);
1065
1068 case HLSL_CLASS_ERROR:
1072 case HLSL_CLASS_SAMPLER:
1073 case HLSL_CLASS_STRING:
1074 case HLSL_CLASS_TEXTURE:
1075 case HLSL_CLASS_UAV:
1082 case HLSL_CLASS_NULL:
1083 return 1;
1084
1086 case HLSL_CLASS_PASS:
1088 case HLSL_CLASS_VOID:
1089 break;
1090 }
1091
1093}

Referenced by copy_propagation_create_var_def(), copy_propagation_get_value(), copy_propagation_invalidate_variable_from_deref_recurse(), copy_propagation_replace_with_constant_vector(), copy_propagation_replace_with_single_instr(), copy_propagation_var_def_destroy(), get_component_index_from_default_initializer_index(), hlsl_component_index_range_from_deref(), hlsl_dump_var_default_values(), hlsl_free_var(), hlsl_type_component_count(), lower_discard_neg(), lower_f16tof32(), lower_f32tof16(), lower_round(), prepend_uniform_copy(), sm4_get_extern_resources(), traverse_path_from_component_index(), write_fx_2_default_value(), write_fx_4_default_value(), write_fx_4_state_numeric_value(), write_fx_4_type(), write_sm1_uniforms(), write_sm4_rdef(), and write_sm4_type().

◆ hlsl_type_element_count()

unsigned int hlsl_type_element_count ( const struct hlsl_type *  type)

Definition at line 209 of file hlsl.c.

210{
211 switch (type->class)
212 {
214 return type->dimx;
217 case HLSL_CLASS_ARRAY:
218 return type->e.array.elements_count;
220 return type->e.record.field_count;
221 default:
222 return 0;
223 }
224}

Referenced by append_output_copy_recurse(), copy_propagation_invalidate_variable_from_deref_recurse(), lower_nonconstant_array_loads(), and prepend_input_copy_recurse().

◆ hlsl_type_get_array_element_reg_size()

unsigned int hlsl_type_get_array_element_reg_size ( const struct hlsl_type *  type,
enum hlsl_regset  regset 
)

Definition at line 444 of file hlsl.c.

445{
447 return align(type->reg_size[regset], 4);
448 return type->reg_size[regset];
449}
static size_t align(size_t addr, size_t alignment)

Referenced by append_output_copy_recurse(), new_offset_from_path_index(), and prepend_input_copy_recurse().

◆ hlsl_type_get_component_offset()

unsigned int hlsl_type_get_component_offset ( struct hlsl_ctx *  ctx,
struct hlsl_type *  type,
unsigned int  index,
enum hlsl_regset *  regset 
)

Definition at line 620 of file hlsl.c.

622{
623 unsigned int offset[HLSL_REGSET_LAST + 1] = {0};
624 struct hlsl_type *next_type;
625 unsigned int idx, r;
626
628 {
629 next_type = type;
631
632 switch (type->class)
633 {
636 break;
637
640 break;
641
643 for (r = 0; r <= HLSL_REGSET_LAST; ++r)
644 offset[r] += type->e.record.fields[idx].reg_offset[r];
645 break;
646
647 case HLSL_CLASS_ARRAY:
648 for (r = 0; r <= HLSL_REGSET_LAST; ++r)
649 {
650 if (r == HLSL_REGSET_NUMERIC)
651 offset[r] += idx * align(type->e.array.type->reg_size[r], 4);
652 else
653 offset[r] += idx * type->e.array.type->reg_size[r];
654 }
655 break;
656
665 case HLSL_CLASS_UAV:
672 VKD3D_ASSERT(idx == 0);
673 break;
674
676 case HLSL_CLASS_ERROR:
677 case HLSL_CLASS_PASS:
679 case HLSL_CLASS_VOID:
682 case HLSL_CLASS_NULL:
684 }
685 type = next_type;
686 }
687
689 return offset[*regset];
690}
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
for(i=0;i< sizeof(testsuite)/sizeof(testsuite[0]);++i) ok(call_test(testsuite[i].func)

Referenced by sm4_get_extern_resources(), write_sm1_uniforms(), and write_sm4_rdef().

◆ hlsl_type_get_component_type()

struct hlsl_type * hlsl_type_get_component_type ( struct hlsl_ctx *  ctx,
struct hlsl_type *  type,
unsigned int  index 
)

◆ hlsl_type_get_sm4_offset()

unsigned int hlsl_type_get_sm4_offset ( const struct hlsl_type *  type,
unsigned int  offset 
)

Definition at line 332 of file hlsl.c.

333{
334 /* Align to the next vec4 boundary if:
335 * (a) the type is a struct or array type, or
336 * (b) the type would cross a vec4 boundary; i.e. a vec3 and a
337 * vec1 can be packed together, but not a vec3 and a vec2.
338 */
339 if (type->class == HLSL_CLASS_STRUCT || type->class == HLSL_CLASS_ARRAY
340 || (offset & 3) + type->reg_size[HLSL_REGSET_NUMERIC] > 4)
341 return align(offset, 4);
342 return offset;
343}

Referenced by hlsl_calculate_buffer_offset(), and hlsl_type_calculate_reg_size().

◆ hlsl_type_is_resource()

bool hlsl_type_is_resource ( const struct hlsl_type *  type)

◆ hlsl_type_is_row_major()

bool hlsl_type_is_row_major ( const struct hlsl_type *  type)

Definition at line 186 of file hlsl.c.

187{
188 /* Default to column-major if the majority isn't explicitly set, which can
189 * happen for anonymous nodes. */
190 return !!(type->modifiers & HLSL_MODIFIER_ROW_MAJOR);
191}

Referenced by hlsl_component_index_range_from_deref(), hlsl_get_element_type_from_path_index(), hlsl_index_is_noncontiguous(), hlsl_type_calculate_reg_size(), hlsl_type_major_size(), hlsl_type_minor_size(), lower_index_loads(), lower_nonconstant_array_loads(), and traverse_path_from_component_index().

◆ hlsl_type_is_shader()

bool hlsl_type_is_shader ( const struct hlsl_type *  type)

Definition at line 257 of file hlsl.c.

258{
259 switch (type->class)
260 {
261 case HLSL_CLASS_ARRAY:
262 return hlsl_type_is_shader(type->e.array.type);
263
270 return true;
271
279 case HLSL_CLASS_ERROR:
280 case HLSL_CLASS_PASS:
287 case HLSL_CLASS_UAV:
290 case HLSL_CLASS_VOID:
291 case HLSL_CLASS_NULL:
292 return false;
293 }
294 return false;
295}
bool hlsl_type_is_shader(const struct hlsl_type *type)
Definition: hlsl.c:257

Referenced by hlsl_type_is_shader().

◆ hlsl_type_major_size()

◆ hlsl_type_minor_size()

unsigned int hlsl_type_minor_size ( const struct hlsl_type *  type)

Definition at line 193 of file hlsl.c.

194{
196 return type->dimx;
197 else
198 return type->dimy;
199}

Referenced by append_output_copy(), prepend_input_copy(), and split_matrix_copies().

◆ hlsl_type_to_string()

struct vkd3d_string_buffer * hlsl_type_to_string ( struct hlsl_ctx *  ctx,
const struct hlsl_type *  type 
)

Definition at line 2696 of file hlsl.c.

2697{
2698 struct vkd3d_string_buffer *string, *inner_string;
2699
2700 static const char *const base_types[] =
2701 {
2702 [HLSL_TYPE_FLOAT] = "float",
2703 [HLSL_TYPE_HALF] = "half",
2704 [HLSL_TYPE_DOUBLE] = "double",
2705 [HLSL_TYPE_INT] = "int",
2706 [HLSL_TYPE_UINT] = "uint",
2707 [HLSL_TYPE_BOOL] = "bool",
2708 };
2709
2710 static const char *const dimensions[] =
2711 {
2712 [HLSL_SAMPLER_DIM_1D] = "1D",
2713 [HLSL_SAMPLER_DIM_2D] = "2D",
2714 [HLSL_SAMPLER_DIM_3D] = "3D",
2715 [HLSL_SAMPLER_DIM_CUBE] = "Cube",
2716 [HLSL_SAMPLER_DIM_1DARRAY] = "1DArray",
2717 [HLSL_SAMPLER_DIM_2DARRAY] = "2DArray",
2718 [HLSL_SAMPLER_DIM_2DMS] = "2DMS",
2719 [HLSL_SAMPLER_DIM_2DMSARRAY] = "2DMSArray",
2720 [HLSL_SAMPLER_DIM_CUBEARRAY] = "CubeArray",
2721 };
2722
2723 if (!(string = hlsl_get_string_buffer(ctx)))
2724 return NULL;
2725
2726 if (type->name)
2727 {
2728 vkd3d_string_buffer_printf(string, "%s", type->name);
2729 return string;
2730 }
2731
2732 switch (type->class)
2733 {
2734 case HLSL_CLASS_SCALAR:
2735 VKD3D_ASSERT(type->e.numeric.type < ARRAY_SIZE(base_types));
2736 vkd3d_string_buffer_printf(string, "%s", base_types[type->e.numeric.type]);
2737 return string;
2738
2739 case HLSL_CLASS_VECTOR:
2740 VKD3D_ASSERT(type->e.numeric.type < ARRAY_SIZE(base_types));
2741 vkd3d_string_buffer_printf(string, "%s%u", base_types[type->e.numeric.type], type->dimx);
2742 return string;
2743
2744 case HLSL_CLASS_MATRIX:
2745 VKD3D_ASSERT(type->e.numeric.type < ARRAY_SIZE(base_types));
2746 vkd3d_string_buffer_printf(string, "%s%ux%u", base_types[type->e.numeric.type], type->dimy, type->dimx);
2747 return string;
2748
2749 case HLSL_CLASS_ARRAY:
2750 {
2751 const struct hlsl_type *t;
2752
2753 for (t = type; t->class == HLSL_CLASS_ARRAY; t = t->e.array.type)
2754 ;
2755
2756 if ((inner_string = hlsl_type_to_string(ctx, t)))
2757 {
2758 vkd3d_string_buffer_printf(string, "%s", inner_string->buffer);
2759 hlsl_release_string_buffer(ctx, inner_string);
2760 }
2761
2762 for (t = type; t->class == HLSL_CLASS_ARRAY; t = t->e.array.type)
2763 {
2764 if (t->e.array.elements_count == HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT)
2765 vkd3d_string_buffer_printf(string, "[]");
2766 else
2767 vkd3d_string_buffer_printf(string, "[%u]", t->e.array.elements_count);
2768 }
2769 return string;
2770 }
2771
2772 case HLSL_CLASS_STRUCT:
2773 vkd3d_string_buffer_printf(string, "<anonymous struct>");
2774 return string;
2775
2776 case HLSL_CLASS_TEXTURE:
2777 if (type->sampler_dim == HLSL_SAMPLER_DIM_RAW_BUFFER)
2778 {
2779 vkd3d_string_buffer_printf(string, "ByteAddressBuffer");
2780 return string;
2781 }
2782
2783 if (type->sampler_dim == HLSL_SAMPLER_DIM_GENERIC)
2784 {
2785 vkd3d_string_buffer_printf(string, "Texture");
2786 return string;
2787 }
2788
2789 VKD3D_ASSERT(hlsl_is_numeric_type(type->e.resource.format));
2790 VKD3D_ASSERT(type->e.resource.format->e.numeric.type < ARRAY_SIZE(base_types));
2791 if (type->sampler_dim == HLSL_SAMPLER_DIM_BUFFER)
2792 {
2793 vkd3d_string_buffer_printf(string, "Buffer");
2794 }
2795 else
2796 {
2797 VKD3D_ASSERT(type->sampler_dim < ARRAY_SIZE(dimensions));
2798 vkd3d_string_buffer_printf(string, "Texture%s", dimensions[type->sampler_dim]);
2799 }
2800 if ((inner_string = hlsl_type_to_string(ctx, type->e.resource.format)))
2801 {
2802 vkd3d_string_buffer_printf(string, "<%s>", inner_string->buffer);
2803 hlsl_release_string_buffer(ctx, inner_string);
2804 }
2805 return string;
2806
2807 case HLSL_CLASS_UAV:
2808 if (type->sampler_dim == HLSL_SAMPLER_DIM_RAW_BUFFER)
2809 {
2810 vkd3d_string_buffer_printf(string, "RWByteAddressBuffer");
2811 return string;
2812 }
2813 if (type->sampler_dim == HLSL_SAMPLER_DIM_BUFFER)
2814 vkd3d_string_buffer_printf(string, "RWBuffer");
2815 else if (type->sampler_dim == HLSL_SAMPLER_DIM_STRUCTURED_BUFFER)
2816 vkd3d_string_buffer_printf(string, "RWStructuredBuffer");
2817 else
2818 vkd3d_string_buffer_printf(string, "RWTexture%s", dimensions[type->sampler_dim]);
2819 if ((inner_string = hlsl_type_to_string(ctx, type->e.resource.format)))
2820 {
2821 vkd3d_string_buffer_printf(string, "<%s>", inner_string->buffer);
2822 hlsl_release_string_buffer(ctx, inner_string);
2823 }
2824 return string;
2825
2827 vkd3d_string_buffer_printf(string, "ConstantBuffer");
2828 if ((inner_string = hlsl_type_to_string(ctx, type->e.resource.format)))
2829 {
2830 vkd3d_string_buffer_printf(string, "<%s>", inner_string->buffer);
2831 hlsl_release_string_buffer(ctx, inner_string);
2832 }
2833 return string;
2834
2835 case HLSL_CLASS_ERROR:
2836 vkd3d_string_buffer_printf(string, "<error type>");
2837 return string;
2838
2842 case HLSL_CLASS_PASS:
2846 case HLSL_CLASS_SAMPLER:
2847 case HLSL_CLASS_STRING:
2850 case HLSL_CLASS_VOID:
2856 case HLSL_CLASS_NULL:
2857 break;
2858 }
2859
2860 vkd3d_string_buffer_printf(string, "<unexpected type>");
2861 return string;
2862}
GLdouble GLdouble t
Definition: gl.h:2047
#define HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT
Definition: hlsl.h:429

Referenced by allocate_register_reservations(), append_output_copy(), debug_hlsl_type(), dump_ir_call(), generate_vsir_signature_entry(), get_string_argument_value(), hlsl_type_to_string(), parse_numthreads_attribute(), parse_outputcontrolpoints_attribute(), prepend_input_copy(), and sm4_generate_vsir_block().

◆ hlsl_types_are_equal()

bool hlsl_types_are_equal ( const struct hlsl_type *  t1,
const struct hlsl_type *  t2 
)

Definition at line 1095 of file hlsl.c.

1096{
1097 if (t1 == t2)
1098 return true;
1099
1100 if (t1->class != t2->class)
1101 return false;
1102
1103 switch (t1->class)
1104 {
1105 case HLSL_CLASS_SCALAR:
1106 case HLSL_CLASS_VECTOR:
1107 case HLSL_CLASS_MATRIX:
1108 if (t1->e.numeric.type != t2->e.numeric.type)
1109 return false;
1112 return false;
1113 if (t1->dimx != t2->dimx)
1114 return false;
1115 if (t1->dimy != t2->dimy)
1116 return false;
1117 return true;
1118
1119 case HLSL_CLASS_UAV:
1120 if (t1->e.resource.rasteriser_ordered != t2->e.resource.rasteriser_ordered)
1121 return false;
1122 /* fall through */
1123 case HLSL_CLASS_TEXTURE:
1125 && !hlsl_types_are_equal(t1->e.resource.format, t2->e.resource.format))
1126 return false;
1127 /* fall through */
1128 case HLSL_CLASS_SAMPLER:
1129 if (t1->sampler_dim != t2->sampler_dim)
1130 return false;
1131 return true;
1132
1133 case HLSL_CLASS_STRUCT:
1134 if (t1->e.record.field_count != t2->e.record.field_count)
1135 return false;
1136
1137 for (size_t i = 0; i < t1->e.record.field_count; ++i)
1138 {
1139 const struct hlsl_struct_field *field1 = &t1->e.record.fields[i];
1140 const struct hlsl_struct_field *field2 = &t2->e.record.fields[i];
1141
1142 if (!hlsl_types_are_equal(field1->type, field2->type))
1143 return false;
1144
1145 if (strcmp(field1->name, field2->name))
1146 return false;
1147 }
1148 return true;
1149
1150 case HLSL_CLASS_ARRAY:
1151 return t1->e.array.elements_count == t2->e.array.elements_count
1152 && hlsl_types_are_equal(t1->e.array.type, t2->e.array.type);
1153
1155 return t1->e.version == t2->e.version;
1156
1158 return hlsl_types_are_equal(t1->e.resource.format, t2->e.resource.format);
1159
1163 case HLSL_CLASS_ERROR:
1164 case HLSL_CLASS_PASS:
1168 case HLSL_CLASS_STRING:
1170 case HLSL_CLASS_VOID:
1176 case HLSL_CLASS_NULL:
1177 return true;
1178 }
1179
1181}

Referenced by fold_redundant_casts(), func_decl_matches(), hlsl_add_conditional(), hlsl_new_func_decl(), hlsl_new_ternary_expr(), hlsl_types_are_equal(), and write_fx_4_state_assignment().

◆ hlsl_validate_state_block_entry()

bool hlsl_validate_state_block_entry ( struct hlsl_ctx *  ctx,
struct hlsl_state_block_entry *  entry,
const struct vkd3d_shader_location *  loc 
)

Definition at line 145 of file fx.c.

147{
148 if (entry->is_function_call)
149 {
151
152 if (!info)
153 {
155 "Invalid state block function '%s'.", entry->name);
156 return false;
157 }
158 if (entry->args_count < info->min_args || entry->args_count > info->max_args)
159 {
160 if (info->min_args == info->max_args)
161 {
163 "Invalid argument count for state block function '%s' (expected %u).",
164 entry->name, info->min_args);
165 }
166 else
167 {
169 "Invalid argument count for state block function '%s' (expected from %u to %u).",
170 entry->name, info->min_args, info->max_args);
171 }
172 return false;
173 }
174 }
175
176 return true;
177}
static const struct state_block_function_info * get_state_block_function_info(const char *name)
Definition: fx.c:99
@ VKD3D_SHADER_ERROR_HLSL_INVALID_STATE_BLOCK_ENTRY

◆ hlsl_var_has_buffer_offset_register_reservation()

static bool hlsl_var_has_buffer_offset_register_reservation ( struct hlsl_ctx *  ctx,
const struct hlsl_ir_var *  var 
)
inlinestatic

Definition at line 1418 of file hlsl.h.

1419{
1420 return var->reg_reservation.reg_type == 'c' && var->buffer == ctx->globals_buffer;
1421}

Referenced by hlsl_calculate_buffer_offsets().

◆ hlsl_version_ge()

static bool hlsl_version_ge ( const struct hlsl_ctx *  ctx,
unsigned int  major,
unsigned int  minor 
)
inlinestatic

◆ hlsl_version_lt()

static bool hlsl_version_lt ( const struct hlsl_ctx *  ctx,
unsigned int  major,
unsigned int  minor 
)
inlinestatic

Definition at line 1146 of file hlsl.h.

1147{
1148 return !hlsl_version_ge(ctx, major, minor);
1149}
static bool hlsl_version_ge(const struct hlsl_ctx *ctx, unsigned int major, unsigned int minor)
Definition: hlsl.h:1141

Referenced by decompose_fx_4_state_block_expand_array(), process_entry_function(), sm1_generate_vsir_instr_if(), sm4_get_extern_resources(), and vsir_data_type_from_hlsl_type().

◆ hlsl_warning()

void void void hlsl_warning ( struct hlsl_ctx *  ctx,
const struct vkd3d_shader_location *  loc,
enum vkd3d_shader_error  error,
const char *  fmt,
  ... 
)

◆ sm4_get_interpolation_mode()

enum vkd3d_shader_interpolation_mode sm4_get_interpolation_mode ( struct hlsl_type *  type,
unsigned int  storage_modifiers 
)

Definition at line 5273 of file hlsl_codegen.c.

5274{
5275 unsigned int i;
5276
5277 static const struct
5278 {
5279 unsigned int modifiers;
5281 }
5282 modes[] =
5283 {
5288 };
5289
5290 if ((storage_modifiers & HLSL_STORAGE_NOINTERPOLATION)
5292 return VKD3DSIM_CONSTANT;
5293
5294 for (i = 0; i < ARRAY_SIZE(modes); ++i)
5295 {
5296 if ((storage_modifiers & modes[i].modifiers) == modes[i].modifiers)
5297 return modes[i].mode;
5298 }
5299
5300 return VKD3DSIM_LINEAR;
5301}
GLenum mode
Definition: glext.h:6217
static enum hlsl_base_type base_type_get_semantic_equivalent(enum hlsl_base_type base)
Definition: hlsl_codegen.c:255
vkd3d_shader_interpolation_mode
@ VKD3DSIM_CONSTANT
@ VKD3DSIM_LINEAR_NOPERSPECTIVE_CENTROID
@ VKD3DSIM_LINEAR_CENTROID
@ VKD3DSIM_LINEAR
@ VKD3DSIM_LINEAR_NOPERSPECTIVE

Referenced by allocate_semantic_register(), and sm4_generate_vsir_instr_dcl_semantic().

◆ tpf_compile()

int tpf_compile ( struct vsir_program *  program,
uint64_t  config_flags,
struct vkd3d_shader_code *  out,
struct vkd3d_shader_message_context *  message_context,
struct hlsl_ctx *  ctx,
struct hlsl_ir_function_decl *  entry_func 
)

Definition at line 6046 of file tpf.c.

6049{
6050 enum vkd3d_shader_type shader_type = program->shader_version.type;
6051 struct tpf_compiler tpf = {0};
6052 struct sm4_stat stat = {0};
6053 size_t i;
6054 int ret;
6055
6056 tpf.ctx = ctx;
6057 tpf.program = program;
6058 tpf.buffer = NULL;
6059 tpf.stat = &stat;
6061 dxbc_writer_init(&tpf.dxbc);
6062
6063 tpf_write_signature(&tpf, &program->input_signature, TAG_ISGN);
6064 tpf_write_signature(&tpf, &program->output_signature, TAG_OSGN);
6066 tpf_write_signature(&tpf, &program->patch_constant_signature, TAG_PCSG);
6067 write_sm4_rdef(ctx, &tpf.dxbc);
6068 tpf_write_shdr(&tpf, entry_func);
6069 tpf_write_sfi0(&tpf);
6070 tpf_write_stat(&tpf);
6071
6072 ret = VKD3D_OK;
6073 if (ctx->result)
6074 ret = ctx->result;
6075 if (tpf.result)
6076 ret = tpf.result;
6077
6078 if (!ret)
6079 ret = dxbc_writer_write(&tpf.dxbc, out);
6080 for (i = 0; i < tpf.dxbc.section_count; ++i)
6081 vkd3d_shader_free_shader_code(&tpf.dxbc.sections[i].data);
6082 return ret;
6083}
#define stat
Definition: acwin.h:100
#define TAG_ISGN
#define TAG_OSGN
#define TAG_PCSG
int dxbc_writer_write(struct dxbc_writer *dxbc, struct vkd3d_shader_code *out)
Definition: dxbc.c:100
void dxbc_writer_init(struct dxbc_writer *dxbc)
Definition: dxbc.c:36
Definition: tpf.c:1404
Definition: stat.h:66
int result
Definition: tpf.c:1416
struct hlsl_ctx * ctx
Definition: tpf.c:1411
struct vkd3d_bytecode_buffer * buffer
Definition: tpf.c:1418
struct vsir_program * program
Definition: tpf.c:1412
struct vkd3d_sm4_lookup_tables lookup
Definition: tpf.c:1413
struct sm4_stat * stat
Definition: tpf.c:1414
struct dxbc_writer dxbc
Definition: tpf.c:1419
static void tpf_write_stat(struct tpf_compiler *tpf)
Definition: tpf.c:5992
static void tpf_write_signature(struct tpf_compiler *tpf, const struct shader_signature *signature, uint32_t tag)
Definition: tpf.c:3245
static void init_sm4_lookup_tables(struct vkd3d_sm4_lookup_tables *lookup)
Definition: tpf.c:1422
static void tpf_write_shdr(struct tpf_compiler *tpf, struct hlsl_ir_function_decl *entry_func)
Definition: tpf.c:5861
static void write_sm4_rdef(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc)
Definition: tpf.c:3773
static void tpf_write_sfi0(struct tpf_compiler *tpf)
Definition: tpf.c:5966
vkd3d_shader_type

Referenced by hlsl_emit_bytecode().

◆ vsir_swizzle_from_hlsl()

static uint32_t vsir_swizzle_from_hlsl ( uint32_t  swizzle)
inlinestatic

Definition at line 73 of file hlsl.h.

74{
79}
static uint32_t vkd3d_shader_create_swizzle(enum vkd3d_shader_swizzle_component x, enum vkd3d_shader_swizzle_component y, enum vkd3d_shader_swizzle_component z, enum vkd3d_shader_swizzle_component w)

Referenced by generate_vsir_get_src_swizzle(), and generate_vsir_instr_swizzle().

◆ write_sm1_uniforms()

void write_sm1_uniforms ( struct hlsl_ctx *  ctx,
struct vkd3d_bytecode_buffer *  buffer 
)

Definition at line 1752 of file d3dbc.c.

1753{
1754 size_t ctab_offset, ctab_start, ctab_end, vars_offset, vars_start, size_offset, creator_offset, offset;
1755 unsigned int uniform_count = 0;
1756 struct hlsl_ir_var *var;
1757
1758 LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
1759 {
1760 unsigned int r;
1761
1762 for (r = 0; r <= HLSL_REGSET_LAST; ++r)
1763 {
1764 if (var->semantic.name || !var->regs[r].allocated || !var->last_read)
1765 continue;
1766
1767 ++uniform_count;
1768
1769 if (var->is_param && var->is_uniform)
1770 {
1771 char *new_name;
1772
1773 if (!(new_name = hlsl_sprintf_alloc(ctx, "$%s", var->name)))
1774 return;
1775 vkd3d_free((char *)var->name);
1776 var->name = new_name;
1777 }
1778 }
1779 }
1780
1782
1783 size_offset = put_u32(buffer, 0);
1784 ctab_offset = put_u32(buffer, VKD3D_MAKE_TAG('C','T','A','B'));
1785
1786 ctab_start = put_u32(buffer, 7 * sizeof(uint32_t)); /* CTAB header size. */
1787 creator_offset = put_u32(buffer, 0);
1788 put_u32(buffer, sm1_version(ctx->profile->type, ctx->profile->major_version, ctx->profile->minor_version));
1789 put_u32(buffer, uniform_count);
1790 vars_offset = put_u32(buffer, 0);
1791 put_u32(buffer, 0); /* FIXME: flags */
1792 put_u32(buffer, 0); /* FIXME: target string */
1793
1794 vars_start = bytecode_align(buffer);
1795 set_u32(buffer, vars_offset, vars_start - ctab_start);
1796
1797 LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
1798 {
1799 unsigned int r;
1800
1801 for (r = 0; r <= HLSL_REGSET_LAST; ++r)
1802 {
1803 if (var->semantic.name || !var->regs[r].allocated || !var->last_read)
1804 continue;
1805
1806 put_u32(buffer, 0); /* name */
1807 if (r == HLSL_REGSET_NUMERIC)
1808 {
1810 put_u32(buffer, var->bind_count[r]);
1811 }
1812 else
1813 {
1815 put_u32(buffer, var->bind_count[r]);
1816 }
1817 put_u32(buffer, 0); /* type */
1818 put_u32(buffer, 0); /* default value */
1819 }
1820 }
1821
1822 uniform_count = 0;
1823
1824 LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
1825 {
1826 unsigned int r;
1827
1828 for (r = 0; r <= HLSL_REGSET_LAST; ++r)
1829 {
1830 size_t var_offset, name_offset;
1831
1832 if (var->semantic.name || !var->regs[r].allocated || !var->last_read)
1833 continue;
1834
1835 var_offset = vars_start + (uniform_count * 5 * sizeof(uint32_t));
1836
1837 name_offset = put_string(buffer, var->name);
1838 set_u32(buffer, var_offset, name_offset - ctab_start);
1839
1840 write_sm1_type(buffer, var->data_type, ctab_start);
1841 set_u32(buffer, var_offset + 3 * sizeof(uint32_t), var->data_type->bytecode_offset - ctab_start);
1842
1843 if (var->default_values)
1844 {
1845 unsigned int reg_size = var->data_type->reg_size[HLSL_REGSET_NUMERIC];
1846 unsigned int comp_count = hlsl_type_component_count(var->data_type);
1847 unsigned int default_value_offset;
1848 unsigned int k;
1849
1850 default_value_offset = bytecode_reserve_bytes(buffer, reg_size * sizeof(uint32_t));
1851 set_u32(buffer, var_offset + 4 * sizeof(uint32_t), default_value_offset - ctab_start);
1852
1853 for (k = 0; k < comp_count; ++k)
1854 {
1855 struct hlsl_type *comp_type = hlsl_type_get_component_type(ctx, var->data_type, k);
1856 unsigned int comp_offset;
1857 enum hlsl_regset regset;
1858
1859 comp_offset = hlsl_type_get_component_offset(ctx, var->data_type, k, &regset);
1861 {
1862 union
1863 {
1864 uint32_t u;
1865 float f;
1866 } uni;
1867
1868 switch (comp_type->e.numeric.type)
1869 {
1870 case HLSL_TYPE_DOUBLE:
1871 if (ctx->double_as_float_alias)
1872 uni.u = var->default_values[k].number.u;
1873 else
1874 uni.u = 0;
1875 break;
1876
1877 case HLSL_TYPE_INT:
1878 uni.f = var->default_values[k].number.i;
1879 break;
1880
1881 case HLSL_TYPE_UINT:
1882 case HLSL_TYPE_BOOL:
1883 uni.f = var->default_values[k].number.u;
1884 break;
1885
1886 case HLSL_TYPE_HALF:
1887 case HLSL_TYPE_FLOAT:
1888 uni.u = var->default_values[k].number.u;
1889 break;
1890
1891 default:
1893 }
1894
1895 set_u32(buffer, default_value_offset + comp_offset * sizeof(uint32_t), uni.u);
1896 }
1897 }
1898 }
1899
1900 ++uniform_count;
1901 }
1902 }
1903
1905 set_u32(buffer, creator_offset, offset - ctab_start);
1906
1907 ctab_end = bytecode_align(buffer);
1908 set_u32(buffer, size_offset, vkd3d_make_u32(VKD3D_SM1_OP_COMMENT, (ctab_end - ctab_offset) / sizeof(uint32_t)));
1909}
static const unsigned char reg_size[]
Definition: amd64_sup.c:21
@ VKD3D_SM1_OP_COMMENT
Definition: d3dbc.c:200
static void write_sm1_type(struct vkd3d_bytecode_buffer *buffer, struct hlsl_type *type, unsigned int ctab_start)
Definition: d3dbc.c:1681
static void sm1_sort_externs(struct hlsl_ctx *ctx)
Definition: d3dbc.c:1739
@ D3DXRS_FLOAT4
Definition: d3dx9shader.h:55
@ D3DXRS_SAMPLER
Definition: d3dx9shader.h:56
unsigned int hlsl_type_get_component_offset(struct hlsl_ctx *ctx, struct hlsl_type *type, unsigned int index, enum hlsl_regset *regset)
Definition: hlsl.c:620
char * hlsl_sprintf_alloc(struct hlsl_ctx *ctx, const char *fmt,...)
Definition: hlsl.c:75
#define uint32_t
Definition: nsiface.idl:61
static uint32_t vkd3d_make_u32(uint16_t low, uint16_t high)
Definition: vkd3d_common.h:381
#define VKD3D_MAKE_TAG(ch0, ch1, ch2, ch3)
Definition: vkd3d_common.h:57
VKD3D_SHADER_API const char * vkd3d_shader_get_version(unsigned int *major, unsigned int *minor)
size_t bytecode_reserve_bytes(struct vkd3d_bytecode_buffer *buffer, size_t size)
size_t bytecode_align(struct vkd3d_bytecode_buffer *buffer)
void set_u32(struct vkd3d_bytecode_buffer *buffer, size_t offset, uint32_t value)
static size_t put_string(struct vkd3d_bytecode_buffer *buffer, const char *string)

Referenced by sm1_generate_vsir().