ReactOS 0.4.17-dev-1133-gc25e4fd
hlsl.c File Reference
#include "hlsl.h"
#include <stdio.h>
Include dependency graph for hlsl.c:

Go to the source code of this file.

Classes

struct  clone_instr_map
 

Functions

void hlsl_note (struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_log_level level, const char *fmt,...)
 
void hlsl_error (struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_error error, const char *fmt,...)
 
void hlsl_warning (struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, enum vkd3d_shader_error error, const char *fmt,...)
 
void hlsl_fixme (struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, const char *fmt,...)
 
char * hlsl_sprintf_alloc (struct hlsl_ctx *ctx, const char *fmt,...)
 
bool hlsl_add_var (struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local_var)
 
struct hlsl_ir_var * hlsl_get_var (struct hlsl_scope *scope, const char *name)
 
void hlsl_free_state_block_entry (struct hlsl_state_block_entry *entry)
 
void hlsl_free_state_block (struct hlsl_state_block *state_block)
 
void hlsl_free_var (struct hlsl_ir_var *decl)
 
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)
 
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)
 
bool hlsl_type_is_resource (const struct hlsl_type *type)
 
bool hlsl_type_is_shader (const struct hlsl_type *type)
 
static enum hlsl_regset type_get_regset (const struct hlsl_type *type)
 
enum hlsl_regset hlsl_deref_get_regset (struct hlsl_ctx *ctx, const struct hlsl_deref *deref)
 
unsigned int hlsl_type_get_sm4_offset (const struct hlsl_type *type, unsigned int offset)
 
static void hlsl_type_calculate_reg_size (struct hlsl_ctx *ctx, struct hlsl_type *type)
 
unsigned int hlsl_type_get_array_element_reg_size (const struct hlsl_type *type, enum hlsl_regset regset)
 
static struct hlsl_type * hlsl_new_simple_type (struct hlsl_ctx *ctx, const char *name, enum hlsl_type_class class)
 
static struct hlsl_type * hlsl_new_type (struct hlsl_ctx *ctx, const char *name, enum hlsl_type_class type_class, enum hlsl_base_type base_type, unsigned dimx, unsigned dimy)
 
static bool type_is_single_component (const struct hlsl_type *type)
 
static unsigned int traverse_path_from_component_index (struct hlsl_ctx *ctx, struct hlsl_type **type_ptr, unsigned int *index_ptr)
 
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)
 
static bool init_deref (struct hlsl_ctx *ctx, struct hlsl_deref *deref, struct hlsl_ir_var *var, unsigned int path_len)
 
bool hlsl_init_deref_from_index_chain (struct hlsl_ctx *ctx, struct hlsl_deref *deref, struct hlsl_ir_node *chain)
 
struct hlsl_type * hlsl_deref_get_type (struct hlsl_ctx *ctx, const struct hlsl_deref *deref)
 
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)
 
struct hlsl_type * hlsl_get_element_type_from_path_index (struct hlsl_ctx *ctx, const struct hlsl_type *type, struct hlsl_ir_node *idx)
 
struct hlsl_type * hlsl_new_array_type (struct hlsl_ctx *ctx, struct hlsl_type *basic_type, unsigned int array_size)
 
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_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)
 
static const char * get_case_insensitive_typename (const char *name)
 
struct hlsl_type * hlsl_get_type (struct hlsl_scope *scope, const char *name, bool recursive, bool case_insensitive)
 
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)
 
unsigned int hlsl_type_component_count (const struct hlsl_type *type)
 
bool hlsl_types_are_equal (const struct hlsl_type *t1, const struct hlsl_type *t2)
 
struct hlsl_type * hlsl_type_clone (struct hlsl_ctx *ctx, struct hlsl_type *old, unsigned int default_majority, uint32_t modifiers)
 
bool hlsl_scope_add_type (struct hlsl_scope *scope, struct hlsl_type *type)
 
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_copy (struct hlsl_ctx *ctx, struct hlsl_ir_node *node)
 
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_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)
 
static bool type_is_single_reg (const struct hlsl_type *type)
 
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_init_simple_deref_from_var (struct hlsl_deref *deref, struct hlsl_ir_var *var)
 
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)
 
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)
 
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_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_bool_constant (struct hlsl_ctx *ctx, bool b, 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_node * hlsl_new_int_constant (struct hlsl_ctx *ctx, int32_t n, const struct vkd3d_shader_location *loc)
 
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_string_constant (struct hlsl_ctx *ctx, const char *str, 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_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_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_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_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)
 
static struct hlsl_ir_node * hlsl_new_error_expr (struct hlsl_ctx *ctx)
 
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_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)
 
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_load * hlsl_new_var_load (struct hlsl_ctx *ctx, struct hlsl_ir_var *var, 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_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_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_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)
 
bool hlsl_state_block_add_entry (struct hlsl_state_block *state_block, struct hlsl_state_block_entry *entry)
 
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)
 
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_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_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_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)
 
static struct hlsl_ir_node * clone_instr (struct hlsl_ctx *ctx, struct clone_instr_map *map, const struct hlsl_ir_node *instr)
 
static bool clone_block (struct hlsl_ctx *ctx, struct hlsl_block *dst_block, const struct hlsl_block *src_block, struct clone_instr_map *map)
 
static struct hlsl_ir_node * map_instr (const struct clone_instr_map *map, struct hlsl_ir_node *src)
 
static bool clone_deref (struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_deref *dst, const struct hlsl_deref *src)
 
static void clone_src (struct clone_instr_map *map, struct hlsl_src *dst, const struct hlsl_src *src)
 
static struct hlsl_ir_node * clone_call (struct hlsl_ctx *ctx, struct hlsl_ir_call *src)
 
static struct hlsl_ir_node * clone_constant (struct hlsl_ctx *ctx, struct hlsl_ir_constant *src)
 
static struct hlsl_ir_node * clone_expr (struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_expr *src)
 
static struct hlsl_ir_node * clone_if (struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_if *src)
 
static struct hlsl_ir_node * clone_jump (struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_jump *src)
 
static struct hlsl_ir_node * clone_load (struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_load *src)
 
static struct hlsl_ir_node * clone_loop (struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_loop *src)
 
static struct hlsl_ir_node * clone_resource_load (struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_resource_load *src)
 
static struct hlsl_ir_node * clone_resource_store (struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_resource_store *src)
 
static struct hlsl_ir_node * clone_string_constant (struct hlsl_ctx *ctx, struct hlsl_ir_string_constant *src)
 
static struct hlsl_ir_node * clone_store (struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_store *src)
 
static struct hlsl_ir_node * clone_swizzle (struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_swizzle *src)
 
static struct hlsl_ir_node * clone_index (struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_index *src)
 
static struct hlsl_ir_node * clone_compile (struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_compile *compile)
 
static struct hlsl_ir_node * clone_sampler_state (struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_sampler_state *sampler_state)
 
static struct hlsl_ir_node * clone_stateblock_constant (struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_stateblock_constant *constant)
 
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_free_ir_switch_case (struct hlsl_ir_switch_case *c)
 
void hlsl_cleanup_ir_switch_cases (struct list *cases)
 
static struct hlsl_ir_node * clone_switch (struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_switch *s)
 
bool hlsl_clone_block (struct hlsl_ctx *ctx, struct hlsl_block *dst_block, const struct hlsl_block *src_block)
 
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_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)
 
static int compare_hlsl_types_rb (const void *key, const struct rb_entry *entry)
 
static struct hlsl_scope * hlsl_new_scope (struct hlsl_ctx *ctx, struct hlsl_scope *upper)
 
void hlsl_push_scope (struct hlsl_ctx *ctx)
 
void hlsl_pop_scope (struct hlsl_ctx *ctx)
 
static bool func_decl_matches (const struct hlsl_ir_function_decl *decl, const struct hlsl_func_parameters *parameters)
 
struct hlsl_ir_function_decl * hlsl_get_func_decl (struct hlsl_ctx *ctx, const char *name, const struct hlsl_func_parameters *parameters)
 
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)
 
const char * debug_hlsl_type (struct hlsl_ctx *ctx, const struct hlsl_type *type)
 
struct vkd3d_string_buffer * hlsl_modifiers_to_string (struct hlsl_ctx *ctx, uint32_t modifiers)
 
const char * hlsl_node_type_to_string (enum hlsl_ir_node_type type)
 
const char * hlsl_jump_type_to_string (enum hlsl_ir_jump_type type)
 
static void dump_instr (struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_ir_node *instr)
 
static void dump_block (struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_block *block)
 
static void dump_src (struct vkd3d_string_buffer *buffer, const struct hlsl_src *src)
 
static void dump_ir_var (struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_ir_var *var)
 
static void dump_deref (struct vkd3d_string_buffer *buffer, const struct hlsl_deref *deref)
 
const char * debug_hlsl_writemask (unsigned int writemask)
 
const char * debug_hlsl_swizzle (uint32_t swizzle, unsigned int size)
 
static void dump_ir_call (struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_ir_call *call)
 
static void dump_ir_constant (struct vkd3d_string_buffer *buffer, const struct hlsl_ir_constant *constant)
 
const char * debug_hlsl_expr_op (enum hlsl_ir_expr_op op)
 
static void dump_ir_expr (struct vkd3d_string_buffer *buffer, const struct hlsl_ir_expr *expr)
 
static void dump_ir_if (struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_ir_if *if_node)
 
static void dump_ir_jump (struct vkd3d_string_buffer *buffer, const struct hlsl_ir_jump *jump)
 
static void dump_ir_loop (struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_ir_loop *loop)
 
static void dump_ir_resource_load (struct vkd3d_string_buffer *buffer, const struct hlsl_ir_resource_load *load)
 
static void dump_ir_resource_store (struct vkd3d_string_buffer *buffer, const struct hlsl_ir_resource_store *store)
 
static void dump_ir_string (struct vkd3d_string_buffer *buffer, const struct hlsl_ir_string_constant *string)
 
static void dump_ir_store (struct vkd3d_string_buffer *buffer, const struct hlsl_ir_store *store)
 
static void dump_ir_swizzle (struct vkd3d_string_buffer *buffer, const struct hlsl_ir_swizzle *swizzle)
 
static void dump_ir_index (struct vkd3d_string_buffer *buffer, const struct hlsl_ir_index *index)
 
static void dump_ir_compile (struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_ir_compile *compile)
 
static void dump_ir_sampler_state (struct vkd3d_string_buffer *buffer, const struct hlsl_ir_sampler_state *sampler_state)
 
static void dump_ir_stateblock_constant (struct vkd3d_string_buffer *buffer, const struct hlsl_ir_stateblock_constant *constant)
 
static void dump_ir_switch (struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_ir_switch *s)
 
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)
 
void hlsl_replace_node (struct hlsl_ir_node *old, struct hlsl_ir_node *new)
 
void hlsl_free_type (struct hlsl_type *type)
 
void hlsl_free_instr_list (struct list *list)
 
void hlsl_block_cleanup (struct hlsl_block *block)
 
static void free_ir_call (struct hlsl_ir_call *call)
 
static void free_ir_constant (struct hlsl_ir_constant *constant)
 
static void free_ir_expr (struct hlsl_ir_expr *expr)
 
static void free_ir_if (struct hlsl_ir_if *if_node)
 
static void free_ir_jump (struct hlsl_ir_jump *jump)
 
static void free_ir_load (struct hlsl_ir_load *load)
 
static void free_ir_loop (struct hlsl_ir_loop *loop)
 
static void free_ir_resource_load (struct hlsl_ir_resource_load *load)
 
static void free_ir_string_constant (struct hlsl_ir_string_constant *string)
 
static void free_ir_resource_store (struct hlsl_ir_resource_store *store)
 
static void free_ir_store (struct hlsl_ir_store *store)
 
static void free_ir_swizzle (struct hlsl_ir_swizzle *swizzle)
 
static void free_ir_switch (struct hlsl_ir_switch *s)
 
static void free_ir_index (struct hlsl_ir_index *index)
 
static void free_ir_compile (struct hlsl_ir_compile *compile)
 
static void free_ir_sampler_state (struct hlsl_ir_sampler_state *sampler_state)
 
static void free_ir_stateblock_constant (struct hlsl_ir_stateblock_constant *constant)
 
void hlsl_free_instr (struct hlsl_ir_node *node)
 
void hlsl_free_attribute (struct hlsl_attribute *attr)
 
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)
 
static void free_function_decl (struct hlsl_ir_function_decl *decl)
 
static void free_function (struct hlsl_ir_function *func)
 
static void free_function_rb (struct rb_entry *entry, void *context)
 
void hlsl_add_function (struct hlsl_ctx *ctx, char *name, struct hlsl_ir_function_decl *decl)
 
uint32_t hlsl_map_swizzle (uint32_t swizzle, unsigned int writemask)
 
uint32_t hlsl_swizzle_from_writemask (unsigned int writemask)
 
unsigned int hlsl_combine_writemasks (unsigned int first, unsigned int second)
 
uint32_t hlsl_combine_swizzles (uint32_t first, uint32_t second, unsigned int dim)
 
const struct hlsl_profile_info * hlsl_get_target_info (const char *target)
 
static int compare_function_rb (const void *key, const struct rb_entry *entry)
 
static void declare_predefined_types (struct hlsl_ctx *ctx)
 
static bool hlsl_ctx_init (struct hlsl_ctx *ctx, const struct vkd3d_shader_compile_info *compile_info, const struct hlsl_profile_info *profile, struct vkd3d_shader_message_context *message_context)
 
static void hlsl_ctx_cleanup (struct hlsl_ctx *ctx)
 
int hlsl_compile_shader (const struct vkd3d_shader_code *hlsl, const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
 
struct hlsl_ir_function_decl * hlsl_compile_internal_function (struct hlsl_ctx *ctx, const char *name, const char *hlsl)
 

Function Documentation

◆ clone_block()

static bool clone_block ( struct hlsl_ctx *  ctx,
struct hlsl_block *  dst_block,
const struct hlsl_block *  src_block,
struct clone_instr_map *  map 
)
static

Definition at line 2087 of file hlsl.c.

2089{
2090 const struct hlsl_ir_node *src;
2091 struct hlsl_ir_node *dst;
2092
2093 hlsl_block_init(dst_block);
2094
2095 LIST_FOR_EACH_ENTRY(src, &src_block->instrs, struct hlsl_ir_node, entry)
2096 {
2097 if (!(dst = clone_instr(ctx, map, src)))
2098 {
2099 hlsl_block_cleanup(dst_block);
2100 return false;
2101 }
2102 hlsl_block_add_instr(dst_block, dst);
2103
2104 if (!list_empty(&src->uses))
2105 {
2106 if (!hlsl_array_reserve(ctx, (void **)&map->instrs, &map->capacity, map->count + 1, sizeof(*map->instrs)))
2107 {
2108 hlsl_block_cleanup(dst_block);
2109 return false;
2110 }
2111
2112 map->instrs[map->count].dst = dst;
2113 map->instrs[map->count].src = src;
2114 ++map->count;
2115 }
2116 }
2117 return true;
2118}
static int list_empty(struct list_entry *head)
Definition: list.h:58
Definition: _map.h:48
_STLP_TEMPLATE_FOR_CONT_EXT size_type count(const _KT &__x) const
Definition: _map.h:214
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
void hlsl_block_cleanup(struct hlsl_block *block)
Definition: hlsl.c:3675
static struct hlsl_ir_node * clone_instr(struct hlsl_ctx *ctx, struct clone_instr_map *map, const struct hlsl_ir_node *instr)
Definition: hlsl.c:2481
static bool hlsl_array_reserve(struct hlsl_ctx *ctx, void **elements, size_t *capacity, size_t element_count, size_t element_size)
Definition: hlsl.h:1336
static void hlsl_block_init(struct hlsl_block *block)
Definition: hlsl.h:1268
static void hlsl_block_add_instr(struct hlsl_block *block, struct hlsl_ir_node *instr)
Definition: hlsl.h:1274
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:236
struct list instrs
Definition: hlsl.h:369

Referenced by clone_compile(), clone_if(), clone_loop(), clone_stateblock_entry(), clone_switch(), and hlsl_clone_block().

◆ clone_call()

static struct hlsl_ir_node * clone_call ( struct hlsl_ctx *  ctx,
struct hlsl_ir_call *  src 
)
static

Definition at line 2157 of file hlsl.c.

2158{
2159 return hlsl_new_call(ctx, src->decl, &src->node.loc);
2160}
struct hlsl_ir_node * hlsl_new_call(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *decl, const struct vkd3d_shader_location *loc)
Definition: hlsl.c:1508

Referenced by clone_instr().

◆ clone_compile()

static struct hlsl_ir_node * clone_compile ( struct hlsl_ctx *  ctx,
struct clone_instr_map *  map,
struct hlsl_ir_compile *  compile 
)
static

Definition at line 2328 of file hlsl.c.

2330{
2331 const char *profile_name = NULL;
2332 struct hlsl_ir_node **args;
2333 struct hlsl_ir_node *node;
2334 struct hlsl_block block;
2335 unsigned int i;
2336
2337 if (!(clone_block(ctx, &block, &compile->instrs, map)))
2338 return NULL;
2339
2340 if (!(args = hlsl_alloc(ctx, sizeof(*args) * compile->args_count)))
2341 {
2343 return NULL;
2344 }
2345 for (i = 0; i < compile->args_count; ++i)
2346 {
2347 args[i] = map_instr(map, compile->args[i].node);
2349 }
2350
2351 if (compile->profile)
2352 profile_name = compile->profile->name;
2353
2354 if (!(node = hlsl_new_compile(ctx, compile->compile_type, profile_name,
2355 args, compile->args_count, &block, &compile->node.loc)))
2356 {
2359 return NULL;
2360 }
2361
2363 return node;
2364}
#define NULL
Definition: types.h:112
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
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: hlsl.c:1866
static struct hlsl_ir_node * map_instr(const struct clone_instr_map *map, struct hlsl_ir_node *src)
Definition: hlsl.c:2120
static void * hlsl_alloc(struct hlsl_ctx *ctx, size_t size)
Definition: hlsl.h:1300
#define args
Definition: format.c:66
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
Definition: dlist.c:348
#define VKD3D_ASSERT(cond)
Definition: vkd3d_common.h:49
static void vkd3d_free(void *ptr)
Definition: vkd3d_memory.h:52
static unsigned int block
Definition: xmlmemory.c:101

Referenced by clone_instr().

◆ clone_constant()

static struct hlsl_ir_node * clone_constant ( struct hlsl_ctx *  ctx,
struct hlsl_ir_constant *  src 
)
static

Definition at line 2162 of file hlsl.c.

2163{
2164 return hlsl_new_constant(ctx, src->node.data_type, &src->value, &src->node.loc);
2165}
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

Referenced by clone_instr().

◆ clone_deref()

static bool clone_deref ( struct hlsl_ctx *  ctx,
struct clone_instr_map *  map,
struct hlsl_deref *  dst,
const struct hlsl_deref *  src 
)
static

Definition at line 2136 of file hlsl.c.

2138{
2139 unsigned int i;
2140
2142
2143 if (!init_deref(ctx, dst, src->var, src->path_len))
2144 return false;
2145
2146 for (i = 0; i < src->path_len; ++i)
2147 hlsl_src_from_node(&dst->path[i], map_instr(map, src->path[i].node));
2148
2149 return true;
2150}
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

Referenced by clone_load(), clone_resource_load(), clone_resource_store(), and clone_store().

◆ clone_expr()

static struct hlsl_ir_node * clone_expr ( struct hlsl_ctx *  ctx,
struct clone_instr_map *  map,
struct hlsl_ir_expr *  src 
)
static

Definition at line 2167 of file hlsl.c.

2168{
2169 struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS];
2170 unsigned int i;
2171
2172 for (i = 0; i < ARRAY_SIZE(operands); ++i)
2173 operands[i] = map_instr(map, src->operands[i].node);
2174
2175 return hlsl_new_expr(ctx, src->op, operands, src->node.data_type, &src->node.loc);
2176}
#define ARRAY_SIZE(A)
Definition: main.h:20
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
#define HLSL_MAX_OPERANDS
Definition: hlsl.h:750

Referenced by clone_instr().

◆ clone_if()

static struct hlsl_ir_node * clone_if ( struct hlsl_ctx *  ctx,
struct clone_instr_map *  map,
struct hlsl_ir_if *  src 
)
static

Definition at line 2178 of file hlsl.c.

2179{
2180 struct hlsl_block then_block, else_block;
2181 struct hlsl_ir_node *dst;
2182
2183 if (!clone_block(ctx, &then_block, &src->then_block, map))
2184 return NULL;
2185 if (!clone_block(ctx, &else_block, &src->else_block, map))
2186 {
2187 hlsl_block_cleanup(&then_block);
2188 return NULL;
2189 }
2190
2191 if (!(dst = hlsl_new_if(ctx, map_instr(map, src->condition.node), &then_block, &else_block, &src->node.loc)))
2192 {
2193 hlsl_block_cleanup(&then_block);
2194 hlsl_block_cleanup(&else_block);
2195 return NULL;
2196 }
2197
2198 return dst;
2199}
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: hlsl.c:1647

Referenced by clone_instr().

◆ clone_index()

static struct hlsl_ir_node * clone_index ( struct hlsl_ctx *  ctx,
struct clone_instr_map *  map,
struct hlsl_ir_index *  src 
)
static

Definition at line 2317 of file hlsl.c.

2319{
2320 struct hlsl_ir_node *dst;
2321
2322 if (!(dst = hlsl_new_index(ctx, map_instr(map, src->val.node), map_instr(map, src->idx.node),
2323 &src->node.loc)))
2324 return NULL;
2325 return dst;
2326}
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: hlsl.c:2022

Referenced by clone_instr().

◆ clone_instr()

static struct hlsl_ir_node * clone_instr ( struct hlsl_ctx *  ctx,
struct clone_instr_map *  map,
const struct hlsl_ir_node *  instr 
)
static

Definition at line 2481 of file hlsl.c.

2483{
2484 switch (instr->type)
2485 {
2486 case HLSL_IR_CALL:
2487 return clone_call(ctx, hlsl_ir_call(instr));
2488
2489 case HLSL_IR_CONSTANT:
2490 return clone_constant(ctx, hlsl_ir_constant(instr));
2491
2492 case HLSL_IR_EXPR:
2493 return clone_expr(ctx, map, hlsl_ir_expr(instr));
2494
2495 case HLSL_IR_IF:
2496 return clone_if(ctx, map, hlsl_ir_if(instr));
2497
2498 case HLSL_IR_INDEX:
2499 return clone_index(ctx, map, hlsl_ir_index(instr));
2500
2501 case HLSL_IR_JUMP:
2502 return clone_jump(ctx, map, hlsl_ir_jump(instr));
2503
2504 case HLSL_IR_LOAD:
2505 return clone_load(ctx, map, hlsl_ir_load(instr));
2506
2507 case HLSL_IR_LOOP:
2508 return clone_loop(ctx, map, hlsl_ir_loop(instr));
2509
2512
2515
2518
2519 case HLSL_IR_STORE:
2520 return clone_store(ctx, map, hlsl_ir_store(instr));
2521
2522 case HLSL_IR_SWITCH:
2523 return clone_switch(ctx, map, hlsl_ir_switch(instr));
2524
2525 case HLSL_IR_SWIZZLE:
2526 return clone_swizzle(ctx, map, hlsl_ir_swizzle(instr));
2527
2528 case HLSL_IR_COMPILE:
2529 return clone_compile(ctx, map, hlsl_ir_compile(instr));
2530
2533
2536
2539 }
2540
2542}
static struct hlsl_ir_node * clone_if(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_if *src)
Definition: hlsl.c:2178
static struct hlsl_ir_node * clone_resource_store(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_resource_store *src)
Definition: hlsl.c:2269
static struct hlsl_ir_node * clone_call(struct hlsl_ctx *ctx, struct hlsl_ir_call *src)
Definition: hlsl.c:2157
static struct hlsl_ir_node * clone_string_constant(struct hlsl_ctx *ctx, struct hlsl_ir_string_constant *src)
Definition: hlsl.c:2287
static struct hlsl_ir_node * clone_swizzle(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_swizzle *src)
Definition: hlsl.c:2310
static struct hlsl_ir_node * clone_stateblock_constant(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_stateblock_constant *constant)
Definition: hlsl.c:2373
static struct hlsl_ir_node * clone_store(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_store *src)
Definition: hlsl.c:2292
static struct hlsl_ir_node * clone_jump(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_jump *src)
Definition: hlsl.c:2201
static struct hlsl_ir_node * clone_expr(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_expr *src)
Definition: hlsl.c:2167
static struct hlsl_ir_node * clone_constant(struct hlsl_ctx *ctx, struct hlsl_ir_constant *src)
Definition: hlsl.c:2162
static struct hlsl_ir_node * clone_index(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_index *src)
Definition: hlsl.c:2317
static struct hlsl_ir_node * clone_compile(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_compile *compile)
Definition: hlsl.c:2328
static struct hlsl_ir_node * clone_sampler_state(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_sampler_state *sampler_state)
Definition: hlsl.c:2366
static struct hlsl_ir_node * clone_loop(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_loop *src)
Definition: hlsl.c:2222
static struct hlsl_ir_node * clone_resource_load(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_resource_load *src)
Definition: hlsl.c:2238
static struct hlsl_ir_node * clone_switch(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_switch *s)
Definition: hlsl.c:2446
static struct hlsl_ir_node * clone_load(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_load *src)
Definition: hlsl.c:2206
@ 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
enum hlsl_ir_node_type type
Definition: hlsl.h:345
#define vkd3d_unreachable()
Definition: vkd3d_common.h:119

Referenced by clone_block().

◆ clone_jump()

static struct hlsl_ir_node * clone_jump ( struct hlsl_ctx *  ctx,
struct clone_instr_map *  map,
struct hlsl_ir_jump *  src 
)
static

Definition at line 2201 of file hlsl.c.

2202{
2203 return hlsl_new_jump(ctx, src->type, map_instr(map, src->condition.node), &src->node.loc);
2204}
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: hlsl.c:2044

Referenced by clone_instr().

◆ clone_load()

static struct hlsl_ir_node * clone_load ( struct hlsl_ctx *  ctx,
struct clone_instr_map *  map,
struct hlsl_ir_load *  src 
)
static

Definition at line 2206 of file hlsl.c.

2207{
2208 struct hlsl_ir_load *dst;
2209
2210 if (!(dst = hlsl_alloc(ctx, sizeof(*dst))))
2211 return NULL;
2212 init_node(&dst->node, HLSL_IR_LOAD, src->node.data_type, &src->node.loc);
2213
2214 if (!clone_deref(ctx, map, &dst->src, &src->src))
2215 {
2216 vkd3d_free(dst);
2217 return NULL;
2218 }
2219 return &dst->node;
2220}
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
static bool clone_deref(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_deref *dst, const struct hlsl_deref *src)
Definition: hlsl.c:2136

Referenced by clone_instr().

◆ clone_loop()

static struct hlsl_ir_node * clone_loop ( struct hlsl_ctx *  ctx,
struct clone_instr_map *  map,
struct hlsl_ir_loop *  src 
)
static

Definition at line 2222 of file hlsl.c.

2223{
2224 struct hlsl_ir_node *dst;
2225 struct hlsl_block body;
2226
2227 if (!clone_block(ctx, &body, &src->body, map))
2228 return NULL;
2229
2230 if (!(dst = hlsl_new_loop(ctx, &body, src->unroll_type, src->unroll_limit, &src->node.loc)))
2231 {
2233 return NULL;
2234 }
2235 return dst;
2236}
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: hlsl.c:2057
static const void * body(MD5_CTX *ctx, const void *data, unsigned long size)
Definition: md5.c:100

Referenced by clone_instr().

◆ clone_resource_load()

static struct hlsl_ir_node * clone_resource_load ( struct hlsl_ctx *  ctx,
struct clone_instr_map *  map,
struct hlsl_ir_resource_load *  src 
)
static

Definition at line 2238 of file hlsl.c.

2240{
2241 struct hlsl_ir_resource_load *dst;
2242
2243 if (!(dst = hlsl_alloc(ctx, sizeof(*dst))))
2244 return NULL;
2245 init_node(&dst->node, HLSL_IR_RESOURCE_LOAD, src->node.data_type, &src->node.loc);
2246 dst->load_type = src->load_type;
2247 if (!clone_deref(ctx, map, &dst->resource, &src->resource))
2248 {
2249 vkd3d_free(dst);
2250 return NULL;
2251 }
2252 if (!clone_deref(ctx, map, &dst->sampler, &src->sampler))
2253 {
2254 hlsl_cleanup_deref(&dst->resource);
2255 vkd3d_free(dst);
2256 return NULL;
2257 }
2258 clone_src(map, &dst->coords, &src->coords);
2259 clone_src(map, &dst->lod, &src->lod);
2260 clone_src(map, &dst->ddx, &src->ddx);
2261 clone_src(map, &dst->ddy, &src->ddy);
2262 clone_src(map, &dst->sample_index, &src->sample_index);
2263 clone_src(map, &dst->cmp, &src->cmp);
2264 clone_src(map, &dst->texel_offset, &src->texel_offset);
2265 dst->sampling_dim = src->sampling_dim;
2266 return &dst->node;
2267}
void hlsl_cleanup_deref(struct hlsl_deref *deref)
Definition: hlsl.c:1408
static void clone_src(struct clone_instr_map *map, struct hlsl_src *dst, const struct hlsl_src *src)
Definition: hlsl.c:2152

Referenced by clone_instr().

◆ clone_resource_store()

static struct hlsl_ir_node * clone_resource_store ( struct hlsl_ctx *  ctx,
struct clone_instr_map *  map,
struct hlsl_ir_resource_store *  src 
)
static

Definition at line 2269 of file hlsl.c.

2271{
2273
2274 if (!(dst = hlsl_alloc(ctx, sizeof(*dst))))
2275 return NULL;
2276 init_node(&dst->node, HLSL_IR_RESOURCE_STORE, NULL, &src->node.loc);
2277 if (!clone_deref(ctx, map, &dst->resource, &src->resource))
2278 {
2279 vkd3d_free(dst);
2280 return NULL;
2281 }
2282 clone_src(map, &dst->coords, &src->coords);
2283 clone_src(map, &dst->value, &src->value);
2284 return &dst->node;
2285}

Referenced by clone_instr().

◆ clone_sampler_state()

static struct hlsl_ir_node * clone_sampler_state ( struct hlsl_ctx *  ctx,
struct clone_instr_map *  map,
struct hlsl_ir_sampler_state *  sampler_state 
)
static

Definition at line 2366 of file hlsl.c.

2368{
2369 return hlsl_new_sampler_state(ctx, sampler_state->state_block,
2370 &sampler_state->node.loc);
2371}
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: hlsl.c:1937
struct hlsl_ir_node node
Definition: hlsl.h:924
struct hlsl_state_block * state_block
Definition: hlsl.h:926

Referenced by clone_instr().

◆ clone_src()

static void clone_src ( struct clone_instr_map *  map,
struct hlsl_src *  dst,
const struct hlsl_src *  src 
)
static

Definition at line 2152 of file hlsl.c.

2153{
2155}

Referenced by clone_resource_load(), clone_resource_store(), clone_stateblock_entry(), and clone_store().

◆ clone_stateblock_constant()

static struct hlsl_ir_node * clone_stateblock_constant ( struct hlsl_ctx *  ctx,
struct clone_instr_map *  map,
struct hlsl_ir_stateblock_constant *  constant 
)
static

Definition at line 2373 of file hlsl.c.

2375{
2376 return hlsl_new_stateblock_constant(ctx, constant->name, &constant->node.loc);
2377}
struct hlsl_ir_node * hlsl_new_stateblock_constant(struct hlsl_ctx *ctx, const char *name, struct vkd3d_shader_location *loc)
Definition: hlsl.c:1978

Referenced by clone_instr().

◆ 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}
void hlsl_free_state_block_entry(struct hlsl_state_block_entry *entry)
Definition: hlsl.c:137
static char * hlsl_strdup(struct hlsl_ctx *ctx, const char *string)
Definition: hlsl.h:1327
Definition: hlsl.h:549
Definition: name.c:39

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

◆ clone_store()

static struct hlsl_ir_node * clone_store ( struct hlsl_ctx *  ctx,
struct clone_instr_map *  map,
struct hlsl_ir_store *  src 
)
static

Definition at line 2292 of file hlsl.c.

2293{
2294 struct hlsl_ir_store *dst;
2295
2296 if (!(dst = hlsl_alloc(ctx, sizeof(*dst))))
2297 return NULL;
2298 init_node(&dst->node, HLSL_IR_STORE, NULL, &src->node.loc);
2299
2300 if (!clone_deref(ctx, map, &dst->lhs, &src->lhs))
2301 {
2302 vkd3d_free(dst);
2303 return NULL;
2304 }
2305 clone_src(map, &dst->rhs, &src->rhs);
2306 dst->writemask = src->writemask;
2307 return &dst->node;
2308}

Referenced by clone_instr().

◆ clone_string_constant()

static struct hlsl_ir_node * clone_string_constant ( struct hlsl_ctx *  ctx,
struct hlsl_ir_string_constant *  src 
)
static

Definition at line 2287 of file hlsl.c.

2288{
2289 return hlsl_new_string_constant(ctx, src->string, &src->node.loc);
2290}
struct hlsl_ir_node * hlsl_new_string_constant(struct hlsl_ctx *ctx, const char *str, const struct vkd3d_shader_location *loc)
Definition: hlsl.c:1571

Referenced by clone_instr().

◆ clone_switch()

static struct hlsl_ir_node * clone_switch ( struct hlsl_ctx *  ctx,
struct clone_instr_map *  map,
struct hlsl_ir_switch *  s 
)
static

Definition at line 2446 of file hlsl.c.

2448{
2449 struct hlsl_ir_switch_case *c, *d;
2450 struct hlsl_ir_node *ret;
2451 struct hlsl_block body;
2452 struct list cases;
2453
2454 list_init(&cases);
2455
2457 {
2458 if (!(clone_block(ctx, &body, &c->body, map)))
2459 {
2461 return NULL;
2462 }
2463
2464 d = hlsl_new_switch_case(ctx, c->value, c->is_default, &body, &c->loc);
2466 if (!d)
2467 {
2469 return NULL;
2470 }
2471
2472 list_add_tail(&cases, &d->entry);
2473 }
2474
2475 ret = hlsl_new_switch(ctx, map_instr(map, s->selector.node), &cases, &s->node.loc);
2477
2478 return ret;
2479}
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
Definition: list.h:39
return ret
Definition: mutex.c:147
GLdouble s
Definition: gl.h:2039
const GLubyte * c
Definition: glext.h:8905
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: hlsl.c:1682
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: hlsl.c:1664
void hlsl_cleanup_ir_switch_cases(struct list *cases)
Definition: hlsl.c:2436
#define d
Definition: ke_i.h:81
#define c
Definition: ke_i.h:80
struct list entry
Definition: wpp.c:51

Referenced by clone_instr().

◆ clone_swizzle()

static struct hlsl_ir_node * clone_swizzle ( struct hlsl_ctx *  ctx,
struct clone_instr_map *  map,
struct hlsl_ir_swizzle *  src 
)
static

Definition at line 2310 of file hlsl.c.

2312{
2313 return hlsl_new_swizzle(ctx, src->swizzle, src->node.data_type->dimx,
2314 map_instr(map, src->val.node), &src->node.loc);
2315}
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: hlsl.c:1847

Referenced by clone_instr().

◆ compare_function_rb()

static int compare_function_rb ( const void *  key,
const struct rb_entry *  entry 
)
static

Definition at line 4137 of file hlsl.c.

4138{
4139 const char *name = key;
4140 const struct hlsl_ir_function *func = RB_ENTRY_VALUE(entry, const struct hlsl_ir_function,entry);
4141
4142 return strcmp(name, func->name);
4143}
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
GLenum func
Definition: glext.h:6028
#define RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:26
Definition: copy.c:22
WCHAR * name
Definition: name.c:42

Referenced by hlsl_ctx_init().

◆ compare_hlsl_types_rb()

static int compare_hlsl_types_rb ( const void *  key,
const struct rb_entry *  entry 
)
static

Definition at line 2613 of file hlsl.c.

2614{
2615 const struct hlsl_type *type = RB_ENTRY_VALUE(entry, const struct hlsl_type, scope_entry);
2616 const char *name = key;
2617
2618 if (name == type->name)
2619 return 0;
2620
2621 if (!name || !type->name)
2622 {
2623 ERR("hlsl_type without a name in a scope?\n");
2624 return -1;
2625 }
2626 return strcmp(name, type->name);
2627}
#define ERR(fmt,...)
Definition: precomp.h:57
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
struct rb_entry scope_entry
Definition: hlsl.h:161

Referenced by hlsl_new_scope().

◆ debug_hlsl_expr_op()

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
@ 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

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 ( uint32_t  swizzle,
unsigned int  size 
)

Definition at line 3093 of file hlsl.c.

3094{
3095 static const char components[] = {'x', 'y', 'z', 'w'};
3096 char string[5];
3097 unsigned int i;
3098
3100 for (i = 0; i < size; ++i)
3102 string[size] = 0;
3103 return vkd3d_dbg_sprintf(".%s", string);
3104}
GLuint GLenum swizzle
Definition: glext.h:9511
GLsizeiptr size
Definition: glext.h:5919
GLenum GLenum GLuint components
Definition: glext.h:9620
static unsigned int hlsl_swizzle_get_component(uint32_t swizzle, unsigned int idx)
Definition: hlsl.h:68
const char * vkd3d_dbg_sprintf(const char *fmt,...) VKD3D_PRINTF_FUNC(1

Referenced by copy_propagation_replace_with_constant_vector(), copy_propagation_replace_with_single_instr(), and dump_ir_swizzle().

◆ 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}
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

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}
#define VKD3DSP_WRITEMASK_ALL

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

◆ declare_predefined_types()

static void declare_predefined_types ( struct hlsl_ctx *  ctx)
static

Definition at line 4145 of file hlsl.c.

4146{
4147 struct vkd3d_string_buffer *name;
4148 unsigned int x, y, bt, i, v;
4149 struct hlsl_type *type;
4150
4151 static const char * const names[] =
4152 {
4153 [HLSL_TYPE_FLOAT] = "float",
4154 [HLSL_TYPE_HALF] = "half",
4155 [HLSL_TYPE_DOUBLE] = "double",
4156 [HLSL_TYPE_INT] = "int",
4157 [HLSL_TYPE_UINT] = "uint",
4158 [HLSL_TYPE_BOOL] = "bool",
4159 };
4160
4161 static const char *const variants_float[] = {"min10float", "min16float"};
4162 static const char *const variants_int[] = {"min12int", "min16int"};
4163 static const char *const variants_uint[] = {"min16uint"};
4164
4165 static const char *const sampler_names[] =
4166 {
4167 [HLSL_SAMPLER_DIM_GENERIC] = "sampler",
4168 [HLSL_SAMPLER_DIM_COMPARISON] = "SamplerComparisonState",
4169 [HLSL_SAMPLER_DIM_1D] = "sampler1D",
4170 [HLSL_SAMPLER_DIM_2D] = "sampler2D",
4171 [HLSL_SAMPLER_DIM_3D] = "sampler3D",
4172 [HLSL_SAMPLER_DIM_CUBE] = "samplerCUBE",
4173 };
4174
4175 static const struct
4176 {
4177 char name[20];
4178 enum hlsl_type_class class;
4179 enum hlsl_base_type base_type;
4180 unsigned int dimx, dimy;
4181 }
4182 effect_types[] =
4183 {
4184 {"dword", HLSL_CLASS_SCALAR, HLSL_TYPE_UINT, 1, 1},
4185 {"vector", HLSL_CLASS_VECTOR, HLSL_TYPE_FLOAT, 4, 1},
4186 {"matrix", HLSL_CLASS_MATRIX, HLSL_TYPE_FLOAT, 4, 4},
4187 };
4188
4189 static const struct
4190 {
4191 const char *name;
4192 unsigned int version;
4193 }
4194 technique_types[] =
4195 {
4196 {"technique", 9},
4197 {"technique10", 10},
4198 {"technique11", 11},
4199 };
4200
4202 return;
4203
4204 for (bt = 0; bt <= HLSL_TYPE_LAST_SCALAR; ++bt)
4205 {
4206 for (y = 1; y <= 4; ++y)
4207 {
4208 for (x = 1; x <= 4; ++x)
4209 {
4211 vkd3d_string_buffer_printf(name, "%s%ux%u", names[bt], y, x);
4212 type = hlsl_new_type(ctx, name->buffer, HLSL_CLASS_MATRIX, bt, x, y);
4213 hlsl_scope_add_type(ctx->globals, type);
4214 ctx->builtin_types.matrix[bt][x - 1][y - 1] = type;
4215
4216 if (y == 1)
4217 {
4219 vkd3d_string_buffer_printf(name, "%s%u", names[bt], x);
4220 type = hlsl_new_type(ctx, name->buffer, HLSL_CLASS_VECTOR, bt, x, y);
4221 hlsl_scope_add_type(ctx->globals, type);
4222 ctx->builtin_types.vector[bt][x - 1] = type;
4223
4224 if (x == 1)
4225 {
4228 type = hlsl_new_type(ctx, name->buffer, HLSL_CLASS_SCALAR, bt, x, y);
4229 hlsl_scope_add_type(ctx->globals, type);
4230 ctx->builtin_types.scalar[bt] = type;
4231 }
4232 }
4233 }
4234 }
4235 }
4236
4237 for (bt = 0; bt <= HLSL_TYPE_LAST_SCALAR; ++bt)
4238 {
4239 const char *const *variants;
4240 unsigned int n_variants;
4241
4242 switch (bt)
4243 {
4244 case HLSL_TYPE_FLOAT:
4245 variants = variants_float;
4246 n_variants = ARRAY_SIZE(variants_float);
4247 break;
4248
4249 case HLSL_TYPE_INT:
4250 variants = variants_int;
4251 n_variants = ARRAY_SIZE(variants_int);
4252 break;
4253
4254 case HLSL_TYPE_UINT:
4255 variants = variants_uint;
4256 n_variants = ARRAY_SIZE(variants_uint);
4257 break;
4258
4259 default:
4260 n_variants = 0;
4261 variants = NULL;
4262 break;
4263 }
4264
4265 for (v = 0; v < n_variants; ++v)
4266 {
4267 for (y = 1; y <= 4; ++y)
4268 {
4269 for (x = 1; x <= 4; ++x)
4270 {
4272 vkd3d_string_buffer_printf(name, "%s%ux%u", variants[v], y, x);
4273 type = hlsl_new_type(ctx, name->buffer, HLSL_CLASS_MATRIX, bt, x, y);
4274 type->is_minimum_precision = 1;
4275 hlsl_scope_add_type(ctx->globals, type);
4276
4277 if (y == 1)
4278 {
4280 vkd3d_string_buffer_printf(name, "%s%u", variants[v], x);
4281 type = hlsl_new_type(ctx, name->buffer, HLSL_CLASS_VECTOR, bt, x, y);
4282 type->is_minimum_precision = 1;
4283 hlsl_scope_add_type(ctx->globals, type);
4284
4285 if (x == 1)
4286 {
4288 vkd3d_string_buffer_printf(name, "%s", variants[v]);
4289 type = hlsl_new_type(ctx, name->buffer, HLSL_CLASS_SCALAR, bt, x, y);
4290 type->is_minimum_precision = 1;
4291 hlsl_scope_add_type(ctx->globals, type);
4292 }
4293 }
4294 }
4295 }
4296 }
4297 }
4298
4299 for (bt = 0; bt <= HLSL_SAMPLER_DIM_LAST_SAMPLER; ++bt)
4300 {
4301 type = hlsl_new_simple_type(ctx, sampler_names[bt], HLSL_CLASS_SAMPLER);
4302 type->sampler_dim = bt;
4303 ctx->builtin_types.sampler[bt] = type;
4304 }
4305
4306 ctx->builtin_types.Void = hlsl_new_simple_type(ctx, "void", HLSL_CLASS_VOID);
4307 ctx->builtin_types.null = hlsl_new_type(ctx, "NULL", HLSL_CLASS_NULL, HLSL_TYPE_UINT, 1, 1);
4308 ctx->builtin_types.string = hlsl_new_simple_type(ctx, "string", HLSL_CLASS_STRING);
4309 ctx->builtin_types.error = hlsl_new_simple_type(ctx, "<error type>", HLSL_CLASS_ERROR);
4310 hlsl_scope_add_type(ctx->globals, ctx->builtin_types.string);
4325
4326 for (i = 0; i < ARRAY_SIZE(effect_types); ++i)
4327 {
4328 type = hlsl_new_type(ctx, effect_types[i].name, effect_types[i].class,
4329 effect_types[i].base_type, effect_types[i].dimx, effect_types[i].dimy);
4330 hlsl_scope_add_type(ctx->globals, type);
4331 }
4332
4333 for (i = 0; i < ARRAY_SIZE(technique_types); ++i)
4334 {
4336 type->e.version = technique_types[i].version;
4337 hlsl_scope_add_type(ctx->globals, type);
4338 }
4339
4341}
static const WCHAR version[]
Definition: asmname.c:66
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
const GLdouble * v
Definition: gl.h:2040
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLuint * names
Definition: glext.h:11545
bool hlsl_scope_add_type(struct hlsl_scope *scope, struct hlsl_type *type)
Definition: hlsl.c:1285
static struct hlsl_type * hlsl_new_simple_type(struct hlsl_ctx *ctx, const char *name, enum hlsl_type_class class)
Definition: hlsl.c:451
static struct hlsl_type * hlsl_new_type(struct hlsl_ctx *ctx, const char *name, enum hlsl_type_class type_class, enum hlsl_base_type base_type, unsigned dimx, unsigned dimy)
Definition: hlsl.c:470
hlsl_type_class
Definition: hlsl.h:82
@ 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_VECTOR
Definition: hlsl.h:84
@ HLSL_CLASS_TEXTURE
Definition: hlsl.h:99
@ HLSL_CLASS_DEPTH_STENCIL_VIEW
Definition: hlsl.h:90
@ 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_DEPTH_STENCIL_STATE
Definition: hlsl.h:89
@ HLSL_CLASS_PASS
Definition: hlsl.h:92
@ HLSL_CLASS_ERROR
Definition: hlsl.h:110
hlsl_base_type
Definition: hlsl.h:114
@ 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
static struct vkd3d_string_buffer * hlsl_get_string_buffer(struct hlsl_ctx *ctx)
Definition: hlsl.h:1346
@ HLSL_SAMPLER_DIM_GENERIC
Definition: hlsl.h:126
@ HLSL_SAMPLER_DIM_LAST_SAMPLER
Definition: hlsl.h:132
@ 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_COMPARISON
Definition: hlsl.h:127
@ HLSL_SAMPLER_DIM_1D
Definition: hlsl.h:128
unsigned int dimx
Definition: hlsl.h:187
const char * name
Definition: hlsl.h:174
unsigned int dimy
Definition: hlsl.h:188
void vkd3d_string_buffer_clear(struct vkd3d_string_buffer *buffer)
int vkd3d_string_buffer_printf(struct vkd3d_string_buffer *buffer, const char *format,...)

Referenced by hlsl_ctx_init().

◆ dump_block()

static void dump_block ( struct hlsl_ctx *  ctx,
struct vkd3d_string_buffer *  buffer,
const struct hlsl_block *  block 
)
static

Definition at line 2996 of file hlsl.c.

2997{
2998 struct hlsl_ir_node *instr;
2999
3000 LIST_FOR_EACH_ENTRY(instr, &block->instrs, struct hlsl_ir_node, entry)
3001 {
3002 dump_instr(ctx, buffer, instr);
3004 }
3005}
GLuint buffer
Definition: glext.h:5915
static void dump_instr(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_ir_node *instr)
Definition: hlsl.c:3487

Referenced by dump_ir_compile(), dump_ir_if(), dump_ir_loop(), dump_ir_switch(), and hlsl_dump_function().

◆ dump_deref()

static void dump_deref ( struct vkd3d_string_buffer *  buffer,
const struct hlsl_deref *  deref 
)
static

Definition at line 3030 of file hlsl.c.

3031{
3032 unsigned int i;
3033
3034 if (deref->var)
3035 {
3036 vkd3d_string_buffer_printf(buffer, "%s", deref->var->name);
3037 if (!hlsl_deref_is_lowered(deref))
3038 {
3039 if (deref->path_len)
3040 {
3042 for (i = 0; i < deref->path_len; ++i)
3043 {
3045 dump_src(buffer, &deref->path[i]);
3047 }
3049 }
3050 }
3051 else
3052 {
3053 bool show_rel, show_const;
3054
3055 show_rel = deref->rel_offset.node;
3056 show_const = deref->const_offset != 0 || !show_rel;
3057
3059 if (show_rel)
3060 dump_src(buffer, &deref->rel_offset);
3061 if (show_rel && show_const)
3063 if (show_const)
3066 }
3067 }
3068 else
3069 {
3071 }
3072}
static void dump_src(struct vkd3d_string_buffer *buffer, const struct hlsl_src *src)
Definition: hlsl.c:3007
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
struct hlsl_ir_var * var
Definition: hlsl.h:796

Referenced by dump_instr(), dump_ir_resource_load(), dump_ir_resource_store(), and dump_ir_store().

◆ dump_instr()

static void dump_instr ( struct hlsl_ctx *  ctx,
struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_node *  instr 
)
static

Definition at line 3487 of file hlsl.c.

3488{
3489 if (instr->index)
3490 vkd3d_string_buffer_printf(buffer, "%4u: ", instr->index);
3491 else
3492 vkd3d_string_buffer_printf(buffer, "%p: ", instr);
3493
3494 vkd3d_string_buffer_printf(buffer, "%10s | ", instr->data_type ? debug_hlsl_type(ctx, instr->data_type) : "");
3495
3496 switch (instr->type)
3497 {
3498 case HLSL_IR_CALL:
3500 break;
3501
3502 case HLSL_IR_CONSTANT:
3504 break;
3505
3506 case HLSL_IR_EXPR:
3508 break;
3509
3510 case HLSL_IR_IF:
3511 dump_ir_if(ctx, buffer, hlsl_ir_if(instr));
3512 break;
3513
3514 case HLSL_IR_INDEX:
3516 break;
3517
3518 case HLSL_IR_JUMP:
3520 break;
3521
3522 case HLSL_IR_LOAD:
3523 dump_deref(buffer, &hlsl_ir_load(instr)->src);
3524 break;
3525
3526 case HLSL_IR_LOOP:
3528 break;
3529
3532 break;
3533
3536 break;
3537
3540 break;
3541
3542 case HLSL_IR_STORE:
3544 break;
3545
3546 case HLSL_IR_SWITCH:
3548 break;
3549
3550 case HLSL_IR_SWIZZLE:
3552 break;
3553
3554 case HLSL_IR_COMPILE:
3556 break;
3557
3560 break;
3561
3564 break;
3565
3567 vkd3d_string_buffer_printf(buffer, "vsir_program instruction %u",
3568 hlsl_ir_vsir_instruction_ref(instr)->vsir_instr_idx);
3569 break;
3570 }
3571}
static void dump_deref(struct vkd3d_string_buffer *buffer, const struct hlsl_deref *deref)
Definition: hlsl.c:3030
static void dump_ir_stateblock_constant(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_stateblock_constant *constant)
Definition: hlsl.c:3455
static void dump_ir_store(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_store *store)
Definition: hlsl.c:3385
static void dump_ir_constant(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_constant *constant)
Definition: hlsl.c:3134
static void dump_ir_resource_load(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_resource_load *load)
Definition: hlsl.c:3307
static void dump_ir_loop(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_ir_loop *loop)
Definition: hlsl.c:3300
const char * debug_hlsl_type(struct hlsl_ctx *ctx, const struct hlsl_type *type)
Definition: hlsl.c:2889
static void dump_ir_if(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_ir_if *if_node)
Definition: hlsl.c:3259
static void dump_ir_expr(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_expr *expr)
Definition: hlsl.c:3246
static void dump_ir_call(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_ir_call *call)
Definition: hlsl.c:3106
static void dump_ir_jump(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_jump *jump)
Definition: hlsl.c:3270
static void dump_ir_resource_store(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_resource_store *store)
Definition: hlsl.c:3369
static void dump_ir_swizzle(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_swizzle *swizzle)
Definition: hlsl.c:3396
static void dump_ir_compile(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_ir_compile *compile)
Definition: hlsl.c:3421
static void dump_ir_switch(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_ir_switch *s)
Definition: hlsl.c:3461
static void dump_ir_index(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_index *index)
Definition: hlsl.c:3413
static void dump_ir_string(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_string_constant *string)
Definition: hlsl.c:3380
static void dump_ir_sampler_state(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_sampler_state *sampler_state)
Definition: hlsl.c:3449
unsigned int index
Definition: hlsl.h:361
struct hlsl_type * data_type
Definition: hlsl.h:349

Referenced by dump_block().

◆ dump_ir_call()

static void dump_ir_call ( struct hlsl_ctx *  ctx,
struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_call *  call 
)
static

Definition at line 3106 of file hlsl.c.

3107{
3108 const struct hlsl_ir_function_decl *decl = call->decl;
3110 size_t i;
3111
3112 if (!(string = hlsl_type_to_string(ctx, decl->return_type)))
3113 return;
3114
3115 vkd3d_string_buffer_printf(buffer, "call %s %s(", string->buffer, decl->func->name);
3117
3118 for (i = 0; i < decl->parameters.count; ++i)
3119 {
3120 const struct hlsl_ir_var *param = decl->parameters.vars[i];
3121
3122 if (!(string = hlsl_type_to_string(ctx, param->data_type)))
3123 return;
3124
3125 if (i)
3128
3130 }
3132}
GLfloat param
Definition: glext.h:5796
struct hlsl_ir_function_decl * decl
Definition: hlsl.h:636
struct hlsl_func_parameters parameters
Definition: hlsl.h:610
struct hlsl_ir_function * func
Definition: hlsl.h:608
struct hlsl_type * return_type
Definition: hlsl.h:599

Referenced by dump_instr().

◆ dump_ir_compile()

static void dump_ir_compile ( struct hlsl_ctx *  ctx,
struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_compile *  compile 
)
static

Definition at line 3421 of file hlsl.c.

3423{
3424 unsigned int i;
3425
3426 switch (compile->compile_type)
3427 {
3428 case HLSL_COMPILE_TYPE_COMPILE:
3429 vkd3d_string_buffer_printf(buffer, "compile %s {\n", compile->profile->name);
3430 break;
3431
3432 case HLSL_COMPILE_TYPE_CONSTRUCTGSWITHSO:
3433 vkd3d_string_buffer_printf(buffer, "ConstructGSWithSO {\n");
3434 break;
3435 }
3436
3437 dump_block(ctx, buffer, &compile->instrs);
3438
3439 vkd3d_string_buffer_printf(buffer, " %10s } (", "");
3440 for (i = 0; i < compile->args_count; ++i)
3441 {
3442 dump_src(buffer, &compile->args[i]);
3443 if (i + 1 < compile->args_count)
3445 }
3447}
static void dump_block(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_block *block)
Definition: hlsl.c:2996

Referenced by dump_instr().

◆ dump_ir_constant()

static void dump_ir_constant ( struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_constant *  constant 
)
static

Definition at line 3134 of file hlsl.c.

3135{
3136 struct hlsl_type *type = constant->node.data_type;
3137 unsigned int x;
3138
3139 if (type->dimx != 1)
3141 for (x = 0; x < type->dimx; ++x)
3142 {
3144
3145 switch (type->e.numeric.type)
3146 {
3147 case HLSL_TYPE_BOOL:
3148 vkd3d_string_buffer_printf(buffer, "%s ", value->u ? "true" : "false");
3149 break;
3150
3151 case HLSL_TYPE_DOUBLE:
3153 break;
3154
3155 case HLSL_TYPE_FLOAT:
3156 case HLSL_TYPE_HALF:
3158 break;
3159
3160 case HLSL_TYPE_INT:
3162 break;
3163
3164 case HLSL_TYPE_UINT:
3166 break;
3167
3168 default:
3170 }
3171 }
3172 if (type->dimx != 1)
3174}
union constant::@272 value[4]
Definition: pdh_main.c:64

Referenced by dump_instr().

◆ dump_ir_expr()

static void dump_ir_expr ( struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_expr *  expr 
)
static

Definition at line 3246 of file hlsl.c.

3247{
3248 unsigned int i;
3249
3251 for (i = 0; i < HLSL_MAX_OPERANDS && expr->operands[i].node; ++i)
3252 {
3253 dump_src(buffer, &expr->operands[i]);
3255 }
3257}
const char * debug_hlsl_expr_op(enum hlsl_ir_expr_op op)
Definition: hlsl.c:3176
Definition: query.h:86

Referenced by dump_instr().

◆ dump_ir_if()

static void dump_ir_if ( struct hlsl_ctx *  ctx,
struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_if *  if_node 
)
static

Definition at line 3259 of file hlsl.c.

3260{
3262 dump_src(buffer, &if_node->condition);
3264 dump_block(ctx, buffer, &if_node->then_block);
3265 vkd3d_string_buffer_printf(buffer, " %10s } else {\n", "");
3266 dump_block(ctx, buffer, &if_node->else_block);
3267 vkd3d_string_buffer_printf(buffer, " %10s }", "");
3268}
struct hlsl_block then_block
Definition: hlsl.h:643
struct hlsl_src condition
Definition: hlsl.h:642
struct hlsl_block else_block
Definition: hlsl.h:644

Referenced by dump_instr().

◆ dump_ir_index()

static void dump_ir_index ( struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_index *  index 
)
static

Definition at line 3413 of file hlsl.c.

3414{
3415 dump_src(buffer, &index->val);
3417 dump_src(buffer, &index->idx);
3419}
GLuint index
Definition: glext.h:6031

Referenced by dump_instr().

◆ dump_ir_jump()

static void dump_ir_jump ( struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_jump *  jump 
)
static

Definition at line 3270 of file hlsl.c.

3271{
3272 switch (jump->type)
3273 {
3274 case HLSL_IR_JUMP_BREAK:
3276 break;
3277
3280 break;
3281
3283 vkd3d_string_buffer_printf(buffer, "discard_neg");
3284 break;
3285
3287 vkd3d_string_buffer_printf(buffer, "discard_nz");
3288 break;
3289
3292 break;
3293
3295 vkd3d_string_buffer_printf(buffer, "unresolved_continue");
3296 break;
3297 }
3298}
@ 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
enum hlsl_ir_jump_type type
Definition: hlsl.h:775

Referenced by dump_instr().

◆ dump_ir_loop()

static void dump_ir_loop ( struct hlsl_ctx *  ctx,
struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_loop *  loop 
)
static

Definition at line 3300 of file hlsl.c.

3301{
3302 vkd3d_string_buffer_printf(buffer, "for (;;) {\n");
3303 dump_block(ctx, buffer, &loop->body);
3304 vkd3d_string_buffer_printf(buffer, " %10s }", "");
3305}
struct hlsl_block body
Definition: hlsl.h:658

Referenced by dump_instr().

◆ dump_ir_resource_load()

static void dump_ir_resource_load ( struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_resource_load *  load 
)
static

Definition at line 3307 of file hlsl.c.

3308{
3309 static const char *const type_names[] =
3310 {
3311 [HLSL_RESOURCE_LOAD] = "load_resource",
3312 [HLSL_RESOURCE_SAMPLE] = "sample",
3313 [HLSL_RESOURCE_SAMPLE_CMP] = "sample_cmp",
3314 [HLSL_RESOURCE_SAMPLE_CMP_LZ] = "sample_cmp_lz",
3315 [HLSL_RESOURCE_SAMPLE_LOD] = "sample_lod",
3316 [HLSL_RESOURCE_SAMPLE_LOD_BIAS] = "sample_biased",
3317 [HLSL_RESOURCE_SAMPLE_GRAD] = "sample_grad",
3318 [HLSL_RESOURCE_GATHER_RED] = "gather_red",
3319 [HLSL_RESOURCE_GATHER_GREEN] = "gather_green",
3320 [HLSL_RESOURCE_GATHER_BLUE] = "gather_blue",
3321 [HLSL_RESOURCE_GATHER_ALPHA] = "gather_alpha",
3322 [HLSL_RESOURCE_SAMPLE_INFO] = "sample_info",
3323 [HLSL_RESOURCE_RESINFO] = "resinfo",
3324 };
3325
3326 VKD3D_ASSERT(load->load_type < ARRAY_SIZE(type_names));
3327 vkd3d_string_buffer_printf(buffer, "%s(resource = ", type_names[load->load_type]);
3328 dump_deref(buffer, &load->resource);
3329 vkd3d_string_buffer_printf(buffer, ", sampler = ");
3330 dump_deref(buffer, &load->sampler);
3331 if (load->coords.node)
3332 {
3333 vkd3d_string_buffer_printf(buffer, ", coords = ");
3334 dump_src(buffer, &load->coords);
3335 }
3336 if (load->sample_index.node)
3337 {
3338 vkd3d_string_buffer_printf(buffer, ", sample index = ");
3339 dump_src(buffer, &load->sample_index);
3340 }
3341 if (load->texel_offset.node)
3342 {
3343 vkd3d_string_buffer_printf(buffer, ", offset = ");
3344 dump_src(buffer, &load->texel_offset);
3345 }
3346 if (load->lod.node)
3347 {
3349 dump_src(buffer, &load->lod);
3350 }
3351 if (load->ddx.node)
3352 {
3354 dump_src(buffer, &load->ddx);
3355 }
3356 if (load->ddy.node)
3357 {
3359 dump_src(buffer, &load->ddy);
3360 }
3361 if (load->cmp.node)
3362 {
3364 dump_src(buffer, &load->cmp);
3365 }
3367}
@ 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_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
int load
Definition: msacm.c:1365

Referenced by dump_instr().

◆ dump_ir_resource_store()

static void dump_ir_resource_store ( struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_resource_store *  store 
)
static

Definition at line 3369 of file hlsl.c.

3370{
3371 vkd3d_string_buffer_printf(buffer, "store_resource(resource = ");
3372 dump_deref(buffer, &store->resource);
3373 vkd3d_string_buffer_printf(buffer, ", coords = ");
3374 dump_src(buffer, &store->coords);
3375 vkd3d_string_buffer_printf(buffer, ", value = ");
3376 dump_src(buffer, &store->value);
3378}
struct hlsl_src coords value
Definition: hlsl.h:864
struct hlsl_deref resource
Definition: hlsl.h:863

Referenced by dump_instr().

◆ dump_ir_sampler_state()

static void dump_ir_sampler_state ( struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_sampler_state *  sampler_state 
)
static

Definition at line 3449 of file hlsl.c.

3451{
3452 vkd3d_string_buffer_printf(buffer, "sampler_state {...}");
3453}

Referenced by dump_instr().

◆ dump_ir_stateblock_constant()

static void dump_ir_stateblock_constant ( struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_stateblock_constant *  constant 
)
static

Definition at line 3455 of file hlsl.c.

3457{
3459}

Referenced by dump_instr().

◆ dump_ir_store()

static void dump_ir_store ( struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_store *  store 
)
static

Definition at line 3385 of file hlsl.c.

3386{
3388 dump_deref(buffer, &store->lhs);
3389 if (store->writemask != VKD3DSP_WRITEMASK_ALL)
3392 dump_src(buffer, &store->rhs);
3394}
const char * debug_hlsl_writemask(unsigned int writemask)
Definition: hlsl.c:3074
struct hlsl_src rhs
Definition: hlsl.h:871
struct hlsl_deref lhs
Definition: hlsl.h:870
unsigned char writemask
Definition: hlsl.h:872

Referenced by dump_instr().

◆ dump_ir_string()

static void dump_ir_string ( struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_string_constant *  string 
)
static

Definition at line 3380 of file hlsl.c.

3381{
3383}
#define debugstr_a
Definition: kernel32.h:31

Referenced by dump_instr().

◆ dump_ir_switch()

static void dump_ir_switch ( struct hlsl_ctx *  ctx,
struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_switch *  s 
)
static

Definition at line 3461 of file hlsl.c.

3462{
3463 struct hlsl_ir_switch_case *c;
3464
3466 dump_src(buffer, &s->selector);
3468
3470 {
3471 if (c->is_default)
3472 {
3473 vkd3d_string_buffer_printf(buffer, " %10s default: {\n", "");
3474 }
3475 else
3476 {
3477 vkd3d_string_buffer_printf(buffer, " %10s case %u : {\n", "", c->value);
3478 }
3479
3480 dump_block(ctx, buffer, &c->body);
3481 vkd3d_string_buffer_printf(buffer, " %10s }\n", "");
3482 }
3483
3484 vkd3d_string_buffer_printf(buffer, " %10s }", "");
3485}

Referenced by dump_instr().

◆ dump_ir_swizzle()

static void dump_ir_swizzle ( struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_swizzle *  swizzle 
)
static

Definition at line 3396 of file hlsl.c.

3397{
3398 unsigned int i;
3399
3400 dump_src(buffer, &swizzle->val);
3401 if (swizzle->val.node->data_type->dimy > 1)
3402 {
3404 for (i = 0; i < swizzle->node.data_type->dimx; ++i)
3405 vkd3d_string_buffer_printf(buffer, "_m%u%u", (swizzle->swizzle >> i * 8) & 0xf, (swizzle->swizzle >> (i * 8 + 4)) & 0xf);
3406 }
3407 else
3408 {
3409 vkd3d_string_buffer_printf(buffer, "%s", debug_hlsl_swizzle(swizzle->swizzle, swizzle->node.data_type->dimx));
3410 }
3411}
const char * debug_hlsl_swizzle(uint32_t swizzle, unsigned int size)
Definition: hlsl.c:3093

Referenced by dump_instr().

◆ dump_ir_var()

static void dump_ir_var ( struct hlsl_ctx *  ctx,
struct vkd3d_string_buffer *  buffer,
const struct hlsl_ir_var *  var 
)
static

Definition at line 3015 of file hlsl.c.

3016{
3017 if (var->storage_modifiers)
3018 {
3020
3021 if ((string = hlsl_modifiers_to_string(ctx, var->storage_modifiers)))
3022 vkd3d_string_buffer_printf(buffer, "%s ", string->buffer);
3024 }
3025 vkd3d_string_buffer_printf(buffer, "%s %s", debug_hlsl_type(ctx, var->data_type), var->name);
3026 if (var->semantic.name)
3027 vkd3d_string_buffer_printf(buffer, " : %s%u", var->semantic.name, var->semantic.index);
3028}
struct vkd3d_string_buffer * hlsl_modifiers_to_string(struct hlsl_ctx *ctx, uint32_t modifiers)
Definition: hlsl.c:2901
const char * var
Definition: shader.c:5879

Referenced by hlsl_dump_function().

◆ dump_src()

static void dump_src ( struct vkd3d_string_buffer *  buffer,
const struct hlsl_src *  src 
)
static

Definition at line 3007 of file hlsl.c.

3008{
3009 if (src->node->index)
3010 vkd3d_string_buffer_printf(buffer, "@%u", src->node->index);
3011 else
3013}

Referenced by dump_deref(), dump_ir_compile(), dump_ir_expr(), dump_ir_if(), dump_ir_index(), dump_ir_resource_load(), dump_ir_resource_store(), dump_ir_store(), dump_ir_switch(), and dump_ir_swizzle().

◆ free_function()

static void free_function ( struct hlsl_ir_function *  func)
static

Definition at line 3931 of file hlsl.c.

3932{
3933 struct hlsl_ir_function_decl *decl, *next;
3934
3935 LIST_FOR_EACH_ENTRY_SAFE(decl, next, &func->overloads, struct hlsl_ir_function_decl, entry)
3936 free_function_decl(decl);
3937 vkd3d_free((void *)func->name);
3939}
static void free_function_decl(struct hlsl_ir_function_decl *decl)
Definition: hlsl.c:3918
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:242
PSYMCRYPT_PARALLEL_HASH_OPERATION next

Referenced by free_function_rb().

◆ free_function_decl()

static void free_function_decl ( struct hlsl_ir_function_decl *  decl)
static

Definition at line 3918 of file hlsl.c.

3919{
3920 unsigned int i;
3921
3922 for (i = 0; i < decl->attr_count; ++i)
3923 hlsl_free_attribute((void *)decl->attrs[i]);
3924 vkd3d_free((void *)decl->attrs);
3925
3926 vkd3d_free(decl->parameters.vars);
3927 hlsl_block_cleanup(&decl->body);
3928 vkd3d_free(decl);
3929}
void hlsl_free_attribute(struct hlsl_attribute *attr)
Definition: hlsl.c:3885
const struct hlsl_attribute *const * attrs
Definition: hlsl.h:617
unsigned int attr_count
Definition: hlsl.h:616
struct hlsl_block body
Definition: hlsl.h:612

Referenced by free_function().

◆ free_function_rb()

static void free_function_rb ( struct rb_entry *  entry,
void *  context 
)
static

Definition at line 3941 of file hlsl.c.

3942{
3944}
static void free_function(struct hlsl_ir_function *func)
Definition: hlsl.c:3931

Referenced by hlsl_ctx_cleanup().

◆ free_ir_call()

static void free_ir_call ( struct hlsl_ir_call *  call)
static

Definition at line 3680 of file hlsl.c.

3681{
3682 vkd3d_free(call);
3683}

Referenced by hlsl_free_instr().

◆ free_ir_compile()

static void free_ir_compile ( struct hlsl_ir_compile *  compile)
static

Definition at line 3781 of file hlsl.c.

3782{
3783 unsigned int i;
3784
3785 for (i = 0; i < compile->args_count; ++i)
3786 hlsl_src_remove(&compile->args[i]);
3787
3788 hlsl_block_cleanup(&compile->instrs);
3789 vkd3d_free(compile);
3790}
static void hlsl_src_remove(struct hlsl_src *src)
Definition: hlsl.h:1293

Referenced by hlsl_free_instr().

◆ free_ir_constant()

static void free_ir_constant ( struct hlsl_ir_constant *  constant)
static

Definition at line 3685 of file hlsl.c.

3686{
3688}

Referenced by hlsl_free_instr().

◆ free_ir_expr()

static void free_ir_expr ( struct hlsl_ir_expr *  expr)
static

Definition at line 3690 of file hlsl.c.

3691{
3692 unsigned int i;
3693
3694 for (i = 0; i < ARRAY_SIZE(expr->operands); ++i)
3695 hlsl_src_remove(&expr->operands[i]);
3697}

Referenced by hlsl_free_instr().

◆ free_ir_if()

static void free_ir_if ( struct hlsl_ir_if *  if_node)
static

Definition at line 3699 of file hlsl.c.

3700{
3701 hlsl_block_cleanup(&if_node->then_block);
3702 hlsl_block_cleanup(&if_node->else_block);
3703 hlsl_src_remove(&if_node->condition);
3704 vkd3d_free(if_node);
3705}

Referenced by hlsl_free_instr().

◆ free_ir_index()

static void free_ir_index ( struct hlsl_ir_index *  index)
static

Definition at line 3774 of file hlsl.c.

3775{
3776 hlsl_src_remove(&index->val);
3777 hlsl_src_remove(&index->idx);
3779}

Referenced by hlsl_free_instr().

◆ free_ir_jump()

static void free_ir_jump ( struct hlsl_ir_jump *  jump)
static

Definition at line 3707 of file hlsl.c.

3708{
3709 hlsl_src_remove(&jump->condition);
3710 vkd3d_free(jump);
3711}
struct hlsl_src condition
Definition: hlsl.h:777

Referenced by hlsl_free_instr().

◆ free_ir_load()

static void free_ir_load ( struct hlsl_ir_load *  load)
static

Definition at line 3713 of file hlsl.c.

3714{
3715 hlsl_cleanup_deref(&load->src);
3717}

Referenced by hlsl_free_instr().

◆ free_ir_loop()

static void free_ir_loop ( struct hlsl_ir_loop *  loop)
static

Definition at line 3719 of file hlsl.c.

3720{
3721 hlsl_block_cleanup(&loop->body);
3722 vkd3d_free(loop);
3723}

Referenced by hlsl_free_instr().

◆ free_ir_resource_load()

static void free_ir_resource_load ( struct hlsl_ir_resource_load *  load)
static

Definition at line 3725 of file hlsl.c.

3726{
3727 hlsl_cleanup_deref(&load->sampler);
3728 hlsl_cleanup_deref(&load->resource);
3729 hlsl_src_remove(&load->coords);
3730 hlsl_src_remove(&load->lod);
3731 hlsl_src_remove(&load->ddx);
3732 hlsl_src_remove(&load->ddy);
3733 hlsl_src_remove(&load->cmp);
3734 hlsl_src_remove(&load->texel_offset);
3735 hlsl_src_remove(&load->sample_index);
3737}

Referenced by hlsl_free_instr().

◆ free_ir_resource_store()

static void free_ir_resource_store ( struct hlsl_ir_resource_store *  store)
static

Definition at line 3745 of file hlsl.c.

3746{
3748 hlsl_src_remove(&store->coords);
3749 hlsl_src_remove(&store->value);
3750 vkd3d_free(store);
3751}

Referenced by hlsl_free_instr().

◆ free_ir_sampler_state()

static void free_ir_sampler_state ( struct hlsl_ir_sampler_state *  sampler_state)
static

Definition at line 3792 of file hlsl.c.

3793{
3794 if (sampler_state->state_block)
3795 hlsl_free_state_block(sampler_state->state_block);
3796 vkd3d_free(sampler_state);
3797}
void hlsl_free_state_block(struct hlsl_state_block *state_block)
Definition: hlsl.c:150

Referenced by hlsl_free_instr().

◆ free_ir_stateblock_constant()

static void free_ir_stateblock_constant ( struct hlsl_ir_stateblock_constant *  constant)
static

Definition at line 3799 of file hlsl.c.

3800{
3801 vkd3d_free(constant->name);
3803}

Referenced by hlsl_free_instr().

◆ free_ir_store()

static void free_ir_store ( struct hlsl_ir_store *  store)
static

Definition at line 3753 of file hlsl.c.

3754{
3755 hlsl_src_remove(&store->rhs);
3756 hlsl_cleanup_deref(&store->lhs);
3757 vkd3d_free(store);
3758}

Referenced by hlsl_free_instr().

◆ free_ir_string_constant()

static void free_ir_string_constant ( struct hlsl_ir_string_constant *  string)
static

Definition at line 3739 of file hlsl.c.

3740{
3741 vkd3d_free(string->string);
3742 vkd3d_free(string);
3743}

Referenced by hlsl_free_instr().

◆ free_ir_switch()

static void free_ir_switch ( struct hlsl_ir_switch *  s)
static

Definition at line 3766 of file hlsl.c.

3767{
3768 hlsl_src_remove(&s->selector);
3770
3771 vkd3d_free(s);
3772}

Referenced by hlsl_free_instr().

◆ free_ir_swizzle()

static void free_ir_swizzle ( struct hlsl_ir_swizzle *  swizzle)
static

Definition at line 3760 of file hlsl.c.

3761{
3762 hlsl_src_remove(&swizzle->val);
3764}

Referenced by hlsl_free_instr().

◆ func_decl_matches()

static bool func_decl_matches ( const struct hlsl_ir_function_decl *  decl,
const struct hlsl_func_parameters *  parameters 
)
static

Definition at line 2662 of file hlsl.c.

2664{
2665 size_t i;
2666
2667 if (parameters->count != decl->parameters.count)
2668 return false;
2669
2670 for (i = 0; i < parameters->count; ++i)
2671 {
2672 if (!hlsl_types_are_equal(parameters->vars[i]->data_type, decl->parameters.vars[i]->data_type))
2673 return false;
2674 }
2675 return true;
2676}
bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2)
Definition: hlsl.c:1095
static BYTE parameters[]
Definition: asn.c:558

Referenced by hlsl_get_func_decl().

◆ get_case_insensitive_typename()

static const char * get_case_insensitive_typename ( const char *  name)
static

Definition at line 970 of file hlsl.c.

971{
972 static const char *const names[] =
973 {
974 "dword",
975 "float",
976 "geometryshader",
977 "matrix",
978 "pixelshader",
979 "texture",
980 "vector",
981 "vertexshader",
982 "string",
983 };
984 unsigned int i;
985
986 for (i = 0; i < ARRAY_SIZE(names); ++i)
987 {
989 return names[i];
990 }
991
992 return NULL;
993}
static int ascii_strcasecmp(const char *a, const char *b)
Definition: vkd3d_common.h:437

Referenced by hlsl_get_type().

◆ 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 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
Definition: rbtree.h:30

◆ 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}
const char * name
Definition: hlsl.h:456
struct hlsl_scope * scope
Definition: hlsl.h:470
struct list scope_entry
Definition: hlsl.h:466

◆ hlsl_block_cleanup()

◆ 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}

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}
void hlsl_free_ir_switch_case(struct hlsl_ir_switch_case *c)
Definition: hlsl.c:2429

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}
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
const GLint * first
Definition: glext.h:5794
#define HLSL_SWIZZLE_SHIFT(idx)
Definition: hlsl.h:66

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}
_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
int hlsl_lexer_compile(struct hlsl_ctx *ctx, const struct vkd3d_shader_code *hlsl)
#define TRACE(s)
Definition: solgame.cpp:4
Definition: inflate.c:139

Referenced by lower_f16tof32(), and lower_f32tof16().

◆ hlsl_compile_shader()

int hlsl_compile_shader ( const struct vkd3d_shader_code *  hlsl,
const struct vkd3d_shader_compile_info *  compile_info,
struct vkd3d_shader_code *  out,
struct vkd3d_shader_message_context *  message_context 
)

Definition at line 4496 of file hlsl.c.

4498{
4500 const struct vkd3d_shader_hlsl_source_info *hlsl_source_info;
4501 struct hlsl_ir_function_decl *decl, *entry_func = NULL;
4502 const struct hlsl_profile_info *profile;
4503 struct hlsl_ir_function *func;
4504 const char *entry_point;
4505 struct hlsl_ctx ctx;
4506 int ret;
4507
4508 if (!(hlsl_source_info = vkd3d_find_struct(compile_info->next, HLSL_SOURCE_INFO)))
4509 {
4510 ERR("No HLSL source info given.\n");
4512 }
4513 entry_point = hlsl_source_info->entry_point ? hlsl_source_info->entry_point : "main";
4514
4515 if (!(profile = hlsl_get_target_info(hlsl_source_info->profile)))
4516 {
4517 FIXME("Unknown compilation target %s.\n", debugstr_a(hlsl_source_info->profile));
4519 }
4520
4522 {
4524 "The '%s' target profile is only compatible with the 'fx' target type.", profile->name);
4526 }
4527 else if (target_type == VKD3D_SHADER_TARGET_D3D_BYTECODE && profile->major_version > 3)
4528 {
4530 "The '%s' target profile is incompatible with the 'd3dbc' target type.", profile->name);
4532 }
4533 else if (target_type == VKD3D_SHADER_TARGET_DXBC_TPF && profile->major_version < 4)
4534 {
4536 "The '%s' target profile is incompatible with the 'dxbc-tpf' target type.", profile->name);
4538 }
4540 {
4542 "The '%s' target profile is incompatible with the 'fx' target type.", profile->name);
4544 }
4545
4546 if (!hlsl_ctx_init(&ctx, compile_info, profile, message_context))
4548
4549 if ((ret = hlsl_lexer_compile(&ctx, hlsl)) == 2)
4550 {
4553 }
4554
4555 if (ctx.result)
4556 {
4558 return ctx.result;
4559 }
4560
4561 /* If parsing failed without an error condition being recorded, we
4562 * plausibly hit some unimplemented feature. */
4563 if (ret)
4564 {
4567 }
4568
4569 if (ctx.profile->type == VKD3D_SHADER_TYPE_EFFECT)
4570 {
4572
4574 return ret;
4575 }
4576
4577 if ((func = hlsl_get_function(&ctx, entry_point)))
4578 {
4579 LIST_FOR_EACH_ENTRY(decl, &func->overloads, struct hlsl_ir_function_decl, entry)
4580 {
4581 if (!decl->has_body)
4582 continue;
4583 if (entry_func)
4584 {
4585 /* Depending on d3dcompiler version, either the first or last is
4586 * selected. */
4587 hlsl_fixme(&ctx, &decl->loc, "Multiple valid entry point definitions.");
4588 }
4589 entry_func = decl;
4590 }
4591 }
4592
4593 if (!entry_func)
4594 {
4595 const struct vkd3d_shader_location loc = {.source_name = compile_info->source_name};
4596
4598 "Entry point \"%s\" is not defined.", entry_point);
4601 }
4602
4606 {
4608 struct vkd3d_shader_compile_info info = *compile_info;
4609 struct vsir_program program;
4610
4611 if (profile->major_version < 4)
4612 {
4613 if ((ret = hlsl_emit_bytecode(&ctx, entry_func, VKD3D_SHADER_TARGET_D3D_BYTECODE, &info.source)) < 0)
4614 goto done;
4616 ret = d3dbc_parse(&info, config_flags, message_context, &program);
4617 }
4618 else
4619 {
4620 if ((ret = hlsl_emit_bytecode(&ctx, entry_func, VKD3D_SHADER_TARGET_DXBC_TPF, &info.source)) < 0)
4621 goto done;
4622 info.source_type = VKD3D_SHADER_SOURCE_DXBC_TPF;
4623 ret = tpf_parse(&info, config_flags, message_context, &program);
4624 }
4625 if (ret >= 0)
4626 {
4627 ret = vsir_program_compile(&program, config_flags, &info, out, message_context);
4629 }
4631 }
4632 else
4633 {
4634 ret = hlsl_emit_bytecode(&ctx, entry_func, target_type, out);
4635 }
4636
4637done:
4639 return ret;
4640}
#define FIXME(fmt,...)
Definition: precomp.h:53
int d3dbc_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t config_flags, struct vkd3d_shader_message_context *message_context, struct vsir_program *program)
Definition: d3dbc.c:1349
UINT64 uint64_t
Definition: types.h:77
int hlsl_emit_effect_binary(struct hlsl_ctx *ctx, struct vkd3d_shader_code *out)
Definition: fx.c:2865
GLuint program
Definition: glext.h:6723
void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, const char *fmt,...)
Definition: hlsl.c:58
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
static void hlsl_ctx_cleanup(struct hlsl_ctx *ctx)
Definition: hlsl.c:4444
static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const struct vkd3d_shader_compile_info *compile_info, const struct hlsl_profile_info *profile, struct vkd3d_shader_message_context *message_context)
Definition: hlsl.c:4343
const struct hlsl_profile_info * hlsl_get_target_info(const char *target)
Definition: hlsl.c:4054
struct hlsl_ir_function * hlsl_get_function(struct hlsl_ctx *ctx, const char *name)
Definition: hlsl.c:1019
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)
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
char * name
Definition: wpp.c:52
struct vkd3d_shader_message_context * message_context
Definition: hlsl.h:1026
struct vkd3d_shader_location loc
Definition: hlsl.h:603
enum vkd3d_shader_target_type target_type
int tpf_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t config_flags, struct vkd3d_shader_message_context *message_context, struct vsir_program *program)
Definition: tpf.c:2900
VKD3D_SHADER_API void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code)
@ VKD3D_SHADER_SOURCE_D3D_BYTECODE
@ VKD3D_SHADER_SOURCE_DXBC_TPF
vkd3d_shader_target_type
@ VKD3D_SHADER_TARGET_SPIRV_BINARY
@ VKD3D_SHADER_TARGET_D3D_ASM
@ VKD3D_SHADER_TARGET_SPIRV_TEXT
@ VKD3D_SHADER_TARGET_DXBC_TPF
@ VKD3D_SHADER_TARGET_D3D_BYTECODE
@ VKD3D_SHADER_TARGET_FX
uint64_t vkd3d_shader_init_config_flags(void)
int vsir_program_compile(struct vsir_program *program, uint64_t config_flags, const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
#define vkd3d_find_struct(c, t)
@ VKD3D_SHADER_TYPE_EFFECT
vkd3d_shader_error
@ VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED
@ VKD3D_SHADER_ERROR_HLSL_INCOMPATIBLE_PROFILE
@ VKD3D_ERROR_INVALID_ARGUMENT
Definition: vkd3d_types.h:51
@ VKD3D_ERROR_NOT_IMPLEMENTED
Definition: vkd3d_types.h:55
@ VKD3D_ERROR_INVALID_SHADER
Definition: vkd3d_types.h:53
@ VKD3D_ERROR_OUT_OF_MEMORY
Definition: vkd3d_types.h:49
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

Referenced by compile_hlsl().

◆ 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}
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
@ HLSL_CLASS_STRUCT
Definition: hlsl.h:87

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}
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_ctx_cleanup()

static void hlsl_ctx_cleanup ( struct hlsl_ctx *  ctx)
static

Definition at line 4444 of file hlsl.c.

4445{
4446 struct hlsl_buffer *buffer, *next_buffer;
4447 struct hlsl_scope *scope, *next_scope;
4448 struct hlsl_ir_var *var, *next_var;
4449 struct hlsl_type *type, *next_type;
4450 unsigned int i;
4451
4452 for (i = 0; i < ctx->source_files_count; ++i)
4453 vkd3d_free((void *)ctx->source_files[i]);
4454 vkd3d_free(ctx->source_files);
4455 vkd3d_string_buffer_cache_cleanup(&ctx->string_buffers);
4456
4457 rb_destroy(&ctx->functions, free_function_rb, NULL);
4458
4459 /* State blocks must be free before the variables, because they contain instructions that may
4460 * refer to them. */
4461 LIST_FOR_EACH_ENTRY_SAFE(scope, next_scope, &ctx->scopes, struct hlsl_scope, entry)
4462 {
4463 LIST_FOR_EACH_ENTRY_SAFE(var, next_var, &scope->vars, struct hlsl_ir_var, scope_entry)
4464 {
4465 for (i = 0; i < var->state_block_count; ++i)
4466 hlsl_free_state_block(var->state_blocks[i]);
4467 vkd3d_free(var->state_blocks);
4468 var->state_blocks = NULL;
4469 var->state_block_count = 0;
4470 var->state_block_capacity = 0;
4471 }
4472 }
4473
4474 hlsl_block_cleanup(&ctx->static_initializers);
4475
4476 LIST_FOR_EACH_ENTRY_SAFE(scope, next_scope, &ctx->scopes, struct hlsl_scope, entry)
4477 {
4478 LIST_FOR_EACH_ENTRY_SAFE(var, next_var, &scope->vars, struct hlsl_ir_var, scope_entry)
4480 rb_destroy(&scope->types, NULL, NULL);
4481 vkd3d_free(scope);
4482 }
4483
4484 LIST_FOR_EACH_ENTRY_SAFE(type, next_type, &ctx->types, struct hlsl_type, entry)
4486
4487 LIST_FOR_EACH_ENTRY_SAFE(buffer, next_buffer, &ctx->buffers, struct hlsl_buffer, entry)
4488 {
4489 vkd3d_free((void *)buffer->name);
4491 }
4492
4493 vkd3d_free(ctx->constant_defs.regs);
4494}
void hlsl_free_var(struct hlsl_ir_var *decl)
Definition: hlsl.c:161
static void free_function_rb(struct rb_entry *entry, void *context)
Definition: hlsl.c:3941
void hlsl_free_type(struct hlsl_type *type)
Definition: hlsl.c:3643
static void rb_destroy(struct rb_tree *tree, rb_traverse_func_t *callback, void *context)
Definition: rbtree.h:185
struct rb_tree types
Definition: hlsl.h:956
struct list vars
Definition: hlsl.h:953
void vkd3d_string_buffer_cache_cleanup(struct vkd3d_string_buffer_cache *cache)

Referenced by hlsl_compile_shader().

◆ hlsl_ctx_init()

static bool hlsl_ctx_init ( struct hlsl_ctx *  ctx,
const struct vkd3d_shader_compile_info *  compile_info,
const struct hlsl_profile_info *  profile,
struct vkd3d_shader_message_context *  message_context 
)
static

Definition at line 4343 of file hlsl.c.

4345{
4346 unsigned int i;
4347
4348 memset(ctx, 0, sizeof(*ctx));
4349
4350 ctx->profile = profile;
4351
4352 ctx->message_context = message_context;
4353
4354 if (!(ctx->source_files = hlsl_alloc(ctx, sizeof(*ctx->source_files))))
4355 return false;
4356 if (!(ctx->source_files[0] = hlsl_strdup(ctx, compile_info->source_name ? compile_info->source_name : "<anonymous>")))
4357 {
4358 vkd3d_free(ctx->source_files);
4359 return false;
4360 }
4361 ctx->source_files_count = 1;
4362 ctx->location.source_name = ctx->source_files[0];
4363 ctx->location.line = ctx->location.column = 1;
4364 vkd3d_string_buffer_cache_init(&ctx->string_buffers);
4365
4366 list_init(&ctx->scopes);
4367
4368 if (!(ctx->dummy_scope = hlsl_new_scope(ctx, NULL)))
4369 {
4370 vkd3d_free((void *)ctx->source_files[0]);
4371 vkd3d_free(ctx->source_files);
4372 return false;
4373 }
4375 ctx->globals = ctx->cur_scope;
4376
4377 list_init(&ctx->types);
4379
4380 rb_init(&ctx->functions, compare_function_rb);
4381
4382 hlsl_block_init(&ctx->static_initializers);
4383 list_init(&ctx->extern_vars);
4384
4385 list_init(&ctx->buffers);
4386
4387 if (!(ctx->globals_buffer = hlsl_new_buffer(ctx, HLSL_BUFFER_CONSTANT,
4388 hlsl_strdup(ctx, "$Globals"), 0, NULL, NULL, &ctx->location)))
4389 return false;
4390 if (!(ctx->params_buffer = hlsl_new_buffer(ctx, HLSL_BUFFER_CONSTANT,
4391 hlsl_strdup(ctx, "$Params"), 0, NULL, NULL, &ctx->location)))
4392 return false;
4393 ctx->cur_buffer = ctx->globals_buffer;
4394
4395 ctx->warn_implicit_truncation = true;
4396
4397 for (i = 0; i < compile_info->option_count; ++i)
4398 {
4399 const struct vkd3d_shader_compile_option *option = &compile_info->options[i];
4400
4401 switch (option->name)
4402 {
4405 ctx->matrix_majority = HLSL_MODIFIER_ROW_MAJOR;
4407 ctx->matrix_majority = HLSL_MODIFIER_COLUMN_MAJOR;
4408 break;
4409
4411 ctx->semantic_compat_mapping = option->value & VKD3D_SHADER_COMPILE_OPTION_BACKCOMPAT_MAP_SEMANTIC_NAMES;
4412 ctx->double_as_float_alias = option->value & VKD3D_SHADER_COMPILE_OPTION_DOUBLE_AS_FLOAT_ALIAS;
4413 break;
4414
4416 ctx->child_effect = option->value;
4417 break;
4418
4420 ctx->warn_implicit_truncation = option->value;
4421 break;
4422
4424 ctx->include_empty_buffers = option->value;
4425 break;
4426
4427 default:
4428 break;
4429 }
4430 }
4431
4432 if (!(ctx->error_instr = hlsl_new_error_expr(ctx)))
4433 return false;
4434 hlsl_block_add_instr(&ctx->static_initializers, ctx->error_instr);
4435
4437 ctx->output_control_point_count = UINT_MAX;
4438 ctx->output_primitive = 0;
4439 ctx->partitioning = 0;
4440
4441 return true;
4442}
#define UINT_MAX
Definition: limits.h:27
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: hlsl.c:2594
static struct hlsl_scope * hlsl_new_scope(struct hlsl_ctx *ctx, struct hlsl_scope *upper)
Definition: hlsl.c:2629
static int compare_function_rb(const void *key, const struct rb_entry *entry)
Definition: hlsl.c:4137
static void declare_predefined_types(struct hlsl_ctx *ctx)
Definition: hlsl.c:4145
static struct hlsl_ir_node * hlsl_new_error_expr(struct hlsl_ctx *ctx)
Definition: hlsl.c:1637
@ HLSL_BUFFER_CONSTANT
Definition: hlsl.h:985
#define HLSL_MODIFIER_ROW_MAJOR
Definition: hlsl.h:406
#define HLSL_MODIFIER_COLUMN_MAJOR
Definition: hlsl.h:407
static void rb_init(struct rb_tree *tree, rb_compare_func_t compare)
Definition: rbtree.h:173
Definition: getopt.h:109
WCHAR * name
Definition: getopt.h:110
const struct vkd3d_shader_compile_option * options
@ VKD3D_SHADER_COMPILE_OPTION_WARN_IMPLICIT_TRUNCATION
Definition: vkd3d_shader.h:352
@ VKD3D_SHADER_COMPILE_OPTION_BACKWARD_COMPATIBILITY
Definition: vkd3d_shader.h:310
@ VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ORDER
Definition: vkd3d_shader.h:302
@ VKD3D_SHADER_COMPILE_OPTION_CHILD_EFFECT
Definition: vkd3d_shader.h:341
@ VKD3D_SHADER_COMPILE_OPTION_INCLUDE_EMPTY_BUFFERS_IN_EFFECTS
Definition: vkd3d_shader.h:360
@ VKD3D_SHADER_COMPILE_OPTION_BACKCOMPAT_MAP_SEMANTIC_NAMES
Definition: vkd3d_shader.h:193
@ VKD3D_SHADER_COMPILE_OPTION_DOUBLE_AS_FLOAT_ALIAS
Definition: vkd3d_shader.h:204
@ VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_COLUMN_MAJOR
Definition: vkd3d_shader.h:174
@ VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_ROW_MAJOR
Definition: vkd3d_shader.h:173
void vkd3d_string_buffer_cache_init(struct vkd3d_string_buffer_cache *cache)
@ VKD3D_TESSELLATOR_DOMAIN_INVALID

Referenced by hlsl_compile_shader().

◆ 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 * 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
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_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
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 const uint32_t k[]
Definition: sha256.c:24
unsigned int hlsl_type_component_count(const struct hlsl_type *type)
Definition: hlsl.c:1042
static BOOL is_string(parse_buffer *buf)
Definition: parsing.c:581

◆ hlsl_error()

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

Definition at line 35 of file hlsl.c.

37{
39
41 vkd3d_shader_verror(ctx->message_context, loc, error, fmt, args);
42 va_end(args);
43
44 if (!ctx->result)
46}
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
char * va_list
Definition: vadefs.h:50
#define error(str)
Definition: mkdosfs.c:1605
Definition: dsound.c:943
void vkd3d_shader_verror(struct vkd3d_shader_message_context *context, const struct vkd3d_shader_location *location, enum vkd3d_shader_error error, const char *format, va_list args)

Referenced by add_semantic_var(), allocate_buffers(), allocate_const_registers(), allocate_objects(), allocate_register_reservations(), allocate_semantic_register(), decompose_fx_4_state_function_call(), find_recursive_calls(), fold_div(), fold_log2(), fold_mod(), fold_rcp(), fold_rsq(), fold_sqrt(), generate_vsir_signature_entry(), get_string_argument_value(), hlsl_calculate_buffer_offset(), hlsl_compile_shader(), hlsl_emit_bytecode(), hlsl_fx_2_write(), hlsl_init_deref_from_index_chain(), hlsl_new_compile(), hlsl_offset_from_deref(), hlsl_validate_state_block_entry(), loop_unrolling_unroll_loop(), lower_calls(), lower_combined_samples(), normalize_switch_cases(), parse_domain_attribute(), parse_numthreads_attribute(), parse_outputcontrolpoints_attribute(), parse_outputtopology_attribute(), parse_partitioning_attribute(), parse_patchconstantfunc_attribute(), process_entry_function(), replace_state_block_constant(), resolve_fx_4_state_block_values(), sm1_generate_vsir_instr_expr_cast(), track_object_components_sampler_dim(), validate_buffer_offsets(), validate_component_index_range_from_deref(), validate_dereferences(), validate_field_semantic(), validate_hull_shader_attributes(), write_annotations(), write_fx_4_state_assignment(), write_fx_4_string_initializer(), write_sm4_dcl_textures(), write_sm4_gather(), write_sm4_ld(), write_sm4_rdef(), and write_sm4_sample().

◆ hlsl_fixme()

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

Definition at line 58 of file hlsl.c.

59{
62
65 vkd3d_string_buffer_printf(string, "Aborting due to not yet implemented feature: ");
67 vkd3d_shader_error(ctx->message_context, loc, VKD3D_SHADER_ERROR_HLSL_NOT_IMPLEMENTED, "%s", string->buffer);
69 va_end(args);
70
71 if (!ctx->result)
73}
int vkd3d_string_buffer_vprintf(struct vkd3d_string_buffer *buffer, const char *format, va_list args)
@ VKD3D_SHADER_ERROR_HLSL_NOT_IMPLEMENTED

Referenced by append_output_copy(), get_fx_4_numeric_type_description(), hlsl_compile_shader(), hlsl_offset_from_deref_safe(), is_type_supported_fx_2(), lower_combined_samples(), lower_ternary(), new_offset_from_path_index(), parse_numthreads_attribute(), parse_outputcontrolpoints_attribute(), prepend_input_copy(), prepend_input_copy_recurse(), resolve_fx_4_state_block_values(), sm1_generate_vsir_block(), sm1_generate_vsir_init_dst_param_from_deref(), sm1_generate_vsir_init_src_param_from_deref(), sm1_generate_vsir_instr_expr(), sm1_generate_vsir_instr_expr_cast(), sm1_generate_vsir_instr_if(), sm1_generate_vsir_instr_jump(), sm1_generate_vsir_instr_resource_load(), sm1_generate_vsir_sampler_dcls(), sm4_generate_vsir_block(), sm4_generate_vsir_instr_expr(), sm4_generate_vsir_instr_expr_cast(), split_array_copies(), split_matrix_copies(), split_struct_copies(), validate_nonconstant_vector_store_derefs(), write_fx_2_default_value(), write_fx_2_initial_value(), write_fx_2_object_initializer(), write_fx_2_pass(), write_fx_4_annotation(), write_fx_4_default_value(), write_fx_4_object_variable(), write_fx_4_state_assignment(), write_fx_4_state_numeric_value(), write_sm4_block(), write_sm4_jump(), write_sm4_rdef(), write_sm4_resinfo(), write_sm4_resource_load(), and write_sm4_resource_store().

◆ 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 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

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}
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 *  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}
@ HLSL_REGSET_LAST_OBJECT
Definition: hlsl.h:150
struct hlsl_ir_var::hlsl_default_value * default_values
struct hlsl_semantic semantic
Definition: hlsl.h:457
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
struct hlsl_ir_var::@6111 * objects_usage[HLSL_REGSET_LAST_OBJECT+1]

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}
unsigned int idx
Definition: utils.c:40
bool hlsl_type_is_row_major(const struct hlsl_type *type)
Definition: hlsl.c:186
@ HLSL_CLASS_ARRAY
Definition: hlsl.h:88
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

◆ 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_multiarray_element_type()

◆ hlsl_get_multiarray_size()

◆ 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_VERTEX
@ VKD3D_SHADER_TYPE_HULL
@ VKD3D_SHADER_TYPE_GEOMETRY
@ VKD3D_SHADER_TYPE_COMPUTE
@ VKD3D_SHADER_TYPE_TEXTURE
@ VKD3D_SHADER_TYPE_PIXEL
@ VKD3D_SHADER_TYPE_DOMAIN

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 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_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}
enum hlsl_type_class class
Definition: hlsl.h:163

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}
@ HLSL_CLASS_UAV
Definition: hlsl.h:100

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
static PVOID ptr
Definition: dispmode.c:27
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_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}

Referenced by sm1_generate_vsir_instr_jump(), and write_sm4_jump().

◆ 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,
uint32_t  modifiers 
)

Definition at line 2901 of file hlsl.c.

2902{
2904
2905 if (!(string = hlsl_get_string_buffer(ctx)))
2906 return NULL;
2907
2908 if (modifiers & HLSL_STORAGE_EXTERN)
2909 vkd3d_string_buffer_printf(string, "extern ");
2910 if (modifiers & HLSL_STORAGE_LINEAR)
2911 vkd3d_string_buffer_printf(string, "linear ");
2912 if (modifiers & HLSL_STORAGE_NOINTERPOLATION)
2913 vkd3d_string_buffer_printf(string, "nointerpolation ");
2914 if (modifiers & HLSL_STORAGE_CENTROID)
2915 vkd3d_string_buffer_printf(string, "centroid ");
2916 if (modifiers & HLSL_STORAGE_NOPERSPECTIVE)
2917 vkd3d_string_buffer_printf(string, "noperspective ");
2918 if (modifiers & HLSL_MODIFIER_PRECISE)
2919 vkd3d_string_buffer_printf(string, "precise ");
2920 if (modifiers & HLSL_STORAGE_SHARED)
2921 vkd3d_string_buffer_printf(string, "shared ");
2922 if (modifiers & HLSL_STORAGE_GROUPSHARED)
2923 vkd3d_string_buffer_printf(string, "groupshared ");
2924 if (modifiers & HLSL_STORAGE_STATIC)
2925 vkd3d_string_buffer_printf(string, "static ");
2926 if (modifiers & HLSL_STORAGE_UNIFORM)
2927 vkd3d_string_buffer_printf(string, "uniform ");
2928 if (modifiers & HLSL_MODIFIER_VOLATILE)
2929 vkd3d_string_buffer_printf(string, "volatile ");
2930 if (modifiers & HLSL_MODIFIER_CONST)
2931 vkd3d_string_buffer_printf(string, "const ");
2932 if (modifiers & HLSL_MODIFIER_ROW_MAJOR)
2933 vkd3d_string_buffer_printf(string, "row_major ");
2934 if (modifiers & HLSL_MODIFIER_COLUMN_MAJOR)
2935 vkd3d_string_buffer_printf(string, "column_major ");
2937 vkd3d_string_buffer_printf(string, "inout ");
2938 else if (modifiers & HLSL_STORAGE_IN)
2939 vkd3d_string_buffer_printf(string, "in ");
2940 else if (modifiers & HLSL_STORAGE_OUT)
2941 vkd3d_string_buffer_printf(string, "out ");
2942
2943 if (string->content_size)
2944 string->buffer[--string->content_size] = 0;
2945
2946 return string;
2947}
#define HLSL_STORAGE_CENTROID
Definition: hlsl.h:411
#define HLSL_STORAGE_UNIFORM
Definition: hlsl.h:403
#define HLSL_STORAGE_EXTERN
Definition: hlsl.h:397
#define HLSL_STORAGE_GROUPSHARED
Definition: hlsl.h:401
#define HLSL_STORAGE_STATIC
Definition: hlsl.h:402
#define HLSL_STORAGE_OUT
Definition: hlsl.h:409
#define HLSL_MODIFIER_PRECISE
Definition: hlsl.h:399
#define HLSL_MODIFIER_CONST
Definition: hlsl.h:405
#define HLSL_STORAGE_LINEAR
Definition: hlsl.h:413
#define HLSL_STORAGE_SHARED
Definition: hlsl.h:400
#define HLSL_STORAGE_IN
Definition: hlsl.h:408
#define HLSL_MODIFIER_VOLATILE
Definition: hlsl.h:404
#define HLSL_STORAGE_NOINTERPOLATION
Definition: hlsl.h:398
#define HLSL_STORAGE_NOPERSPECTIVE
Definition: hlsl.h:412

Referenced by dump_ir_var().

◆ 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()

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 
)

Definition at line 1619 of file hlsl.c.

1621{
1622 struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = {arg1, arg2};
1623
1624 return hlsl_new_expr(ctx, op, operands, arg1->data_type, &arg1->loc);
1625}
GLuint GLuint GLuint GLuint arg1
Definition: glext.h:9513
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
Definition: glext.h:9514

Referenced by lower_abs(), lower_casts_to_bool(), lower_ceil(), lower_cmp(), lower_comparison_operators(), lower_discard_neg(), lower_division(), lower_dot(), lower_float_modulus(), lower_floor(), lower_int_abs(), lower_int_division(), lower_int_dot(), lower_int_modulus(), lower_logic_not(), lower_round(), lower_slt(), new_offset_from_path_index(), and resolve_fx_4_state_block_values().

◆ 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}
struct hlsl_ir_node node
Definition: hlsl.h:635

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
struct vkd3d_shader_location loc
Definition: hlsl.h:355

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}
@ HLSL_CLASS_CONSTANT_BUFFER
Definition: hlsl.h:106
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}
static void hlsl_block_add_block(struct hlsl_block *block, struct hlsl_block *add)
Definition: hlsl.h:1280
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}
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

◆ hlsl_new_error_expr()

static struct hlsl_ir_node * hlsl_new_error_expr ( struct hlsl_ctx *  ctx)
static

Definition at line 1637 of file hlsl.c.

1638{
1639 static const struct vkd3d_shader_location loc = {.source_name = "<error>"};
1640 struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = {0};
1641
1642 /* Use a dummy location; we should never report any messages related to
1643 * this expression. */
1644 return hlsl_new_expr(ctx, HLSL_OP0_ERROR, operands, ctx->builtin_types.error, &loc);
1645}

Referenced by hlsl_ctx_init().

◆ 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_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

◆ 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}
GLenum condition
Definition: glext.h:9255
struct hlsl_ir_node node
Definition: hlsl.h:641

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

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

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
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

◆ 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

Referenced by clone_sampler_state().

◆ hlsl_new_scope()

static struct hlsl_scope * hlsl_new_scope ( struct hlsl_ctx *  ctx,
struct hlsl_scope *  upper 
)
static

Definition at line 2629 of file hlsl.c.

2630{
2631 struct hlsl_scope *scope;
2632
2633 if (!(scope = hlsl_alloc(ctx, sizeof(*scope))))
2634 return NULL;
2635 list_init(&scope->vars);
2637 scope->upper = upper;
2638 list_add_tail(&ctx->scopes, &scope->entry);
2639 return scope;
2640}
static int compare_hlsl_types_rb(const void *key, const struct rb_entry *entry)
Definition: hlsl.c:2613
struct list entry
Definition: hlsl.h:950

Referenced by hlsl_ctx_init(), and hlsl_push_scope().

◆ 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_simple_type()

static struct hlsl_type * hlsl_new_simple_type ( struct hlsl_ctx *  ctx,
const char *  name,
enum hlsl_type_class  class 
)
static

Definition at line 451 of file hlsl.c.

452{
453 struct hlsl_type *type;
454
455 if (!(type = hlsl_alloc(ctx, sizeof(*type))))
456 return NULL;
457 if (!(type->name = hlsl_strdup(ctx, name)))
458 {
460 return NULL;
461 }
462 type->class = class;
464
465 list_add_tail(&ctx->types, &type->entry);
466
467 return type;
468}

Referenced by declare_predefined_types().

◆ 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_ir_node node
Definition: hlsl.h:869

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

◆ 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}
GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg3
Definition: glext.h:9515

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_type()

static struct hlsl_type * hlsl_new_type ( struct hlsl_ctx *  ctx,
const char *  name,
enum hlsl_type_class  type_class,
enum hlsl_base_type  base_type,
unsigned  dimx,
unsigned  dimy 
)
static

Definition at line 470 of file hlsl.c.

472{
473 struct hlsl_type *type;
474
475 if (!(type = hlsl_alloc(ctx, sizeof(*type))))
476 return NULL;
477 if (!(type->name = hlsl_strdup(ctx, name)))
478 {
480 return NULL;
481 }
482 type->class = type_class;
483 type->e.numeric.type = base_type;
484 type->dimx = dimx;
485 type->dimy = dimy;
487
488 list_add_tail(&ctx->types, &type->entry);
489
490 return type;
491}

Referenced by declare_predefined_types().

◆ 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 hlsl_note ( struct hlsl_ctx *  ctx,
const struct vkd3d_shader_location *  loc,
enum vkd3d_shader_log_level  level,
const char *  fmt,
  ... 
)

Definition at line 25 of file hlsl.c.

27{
29
31 vkd3d_shader_vnote(ctx->message_context, loc, level, fmt, args);
32 va_end(args);
33}
GLint level
Definition: gl.h:1546
void vkd3d_shader_vnote(struct vkd3d_shader_message_context *context, const struct vkd3d_shader_location *location, enum vkd3d_shader_log_level level, const char *format, va_list args)

Referenced by add_semantic_var(), allocate_buffers(), allocate_objects(), lower_combined_samples(), note_non_static_deref_expressions(), and track_object_components_sampler_dim().

◆ 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 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}

Referenced by hlsl_compile_internal_function(), and hlsl_ctx_init().

◆ 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 entry
Definition: hlsl.h:341
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_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_sprintf_alloc()

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

Definition at line 75 of file hlsl.c.

76{
79 char *ret;
80
81 if (!(string = hlsl_get_string_buffer(ctx)))
82 return NULL;
84 if (vkd3d_string_buffer_vprintf(string, fmt, args) < 0)
85 {
86 va_end(args);
88 return NULL;
89 }
90 va_end(args);
91 ret = hlsl_strdup(ctx, string->buffer);
93 return ret;
94}

Referenced by add_semantic_var(), lower_f16tof32(), lower_f32tof16(), prepend_uniform_copy(), and write_sm1_uniforms().

◆ 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
bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t element_count, size_t element_size)
Definition: memory.c:22

Referenced by hlsl_new_sampler_state().

◆ 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_type_calculate_reg_size()

static void hlsl_type_calculate_reg_size ( struct hlsl_ctx *  ctx,
struct hlsl_type *  type 
)
static

Definition at line 345 of file hlsl.c.

346{
347 bool is_sm4 = (ctx->profile->major_version >= 4);
348 unsigned int k;
349
350 for (k = 0; k <= HLSL_REGSET_LAST; ++k)
351 type->reg_size[k] = 0;
352
353 switch (type->class)
354 {
357 type->reg_size[HLSL_REGSET_NUMERIC] = is_sm4 ? type->dimx : 4;
358 break;
359
362 type->reg_size[HLSL_REGSET_NUMERIC] = is_sm4 ? (4 * (type->dimy - 1) + type->dimx) : (4 * type->dimy);
363 else
364 type->reg_size[HLSL_REGSET_NUMERIC] = is_sm4 ? (4 * (type->dimx - 1) + type->dimy) : (4 * type->dimx);
365 break;
366
367 case HLSL_CLASS_ARRAY:
368 {
369 if (type->e.array.elements_count == HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT)
370 break;
371
372 for (k = 0; k <= HLSL_REGSET_LAST; ++k)
373 {
374 unsigned int element_size = type->e.array.type->reg_size[k];
375
376 if (is_sm4 && k == HLSL_REGSET_NUMERIC)
377 type->reg_size[k] = (type->e.array.elements_count - 1) * align(element_size, 4) + element_size;
378 else
379 type->reg_size[k] = type->e.array.elements_count * element_size;
380 }
381
382 break;
383 }
384
386 {
387 unsigned int i;
388
389 type->dimx = 0;
390 for (i = 0; i < type->e.record.field_count; ++i)
391 {
392 struct hlsl_struct_field *field = &type->e.record.fields[i];
393
394 for (k = 0; k <= HLSL_REGSET_LAST; ++k)
395 {
396 if (k == HLSL_REGSET_NUMERIC)
397 type->reg_size[k] = hlsl_type_get_sm4_offset(field->type, type->reg_size[k]);
398 field->reg_offset[k] = type->reg_size[k];
399 type->reg_size[k] += field->type->reg_size[k];
400 }
401
402 type->dimx += field->type->dimx * field->type->dimy * hlsl_get_multiarray_size(field->type);
403 }
404 break;
405 }
406
408 type->reg_size[HLSL_REGSET_SAMPLERS] = 1;
409 break;
410
412 type->reg_size[HLSL_REGSET_TEXTURES] = 1;
413 break;
414
415 case HLSL_CLASS_UAV:
416 type->reg_size[HLSL_REGSET_UAVS] = 1;
417 break;
418
422 case HLSL_CLASS_ERROR:
423 case HLSL_CLASS_PASS:
430 case HLSL_CLASS_VOID:
437 case HLSL_CLASS_NULL:
438 break;
439 }
440}
size_t const element_size
Definition: debug_heap.cpp:510
switch(r->id)
Definition: btrfs.c:3046
unsigned int hlsl_type_get_sm4_offset(const struct hlsl_type *type, unsigned int offset)
Definition: hlsl.c:332
#define HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT
Definition: hlsl.h:429
@ 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
static size_t align(size_t addr, size_t alignment)

Referenced by hlsl_new_array_type(), hlsl_new_cb_type(), hlsl_new_simple_type(), hlsl_new_struct_type(), hlsl_new_texture_type(), hlsl_new_type(), hlsl_new_uav_type(), and hlsl_type_clone().

◆ 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
#define HLSL_MODIFIERS_MAJORITY_MASK
Definition: hlsl.h:427
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
union hlsl_type::@6106 e
struct hlsl_type::@6106::@6108 record
struct hlsl_type::@6106::@6107 numeric
struct hlsl_type::@6106::@6109 array
struct hlsl_type::@6106::@6110 resource
unsigned int version
Definition: hlsl.h:222

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}
GLuint GLuint GLsizei count
Definition: gl.h:1545

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}
unsigned int hlsl_type_major_size(const struct hlsl_type *type)
Definition: hlsl.c:201

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}
D3DXREGISTER_SET regset
Definition: shader.c:5881

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
GLintptr offset
Definition: glext.h:5920
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)

Definition at line 240 of file hlsl.c.

241{
242 switch (type->class)
243 {
244 case HLSL_CLASS_ARRAY:
245 return hlsl_type_is_resource(type->e.array.type);
246
249 case HLSL_CLASS_UAV:
250 return true;
251
252 default:
253 return false;
254 }
255}
bool hlsl_type_is_resource(const struct hlsl_type *type)
Definition: hlsl.c:240

Referenced by allocate_buffers(), append_output_copy_recurse(), hlsl_calculate_buffer_offsets(), hlsl_type_is_resource(), lower_combined_samples(), prepend_input_copy_recurse(), process_entry_function(), sm1_generate_vsir_init_src_param_from_deref(), sm4_get_extern_resources(), and validate_buffer_offsets().

◆ 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
@ 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_2DARRAY
Definition: hlsl.h:134
@ HLSL_SAMPLER_DIM_RAW_BUFFER
Definition: hlsl.h:140
@ HLSL_SAMPLER_DIM_STRUCTURED_BUFFER
Definition: hlsl.h:139

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_warning()

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

Definition at line 48 of file hlsl.c.

50{
52
54 vkd3d_shader_vwarning(ctx->message_context, loc, error, fmt, args);
55 va_end(args);
56}
void vkd3d_shader_vwarning(struct vkd3d_shader_message_context *context, const struct vkd3d_shader_location *location, enum vkd3d_shader_error error, const char *format, va_list args)

Referenced by fold_div(), fold_log2(), fold_rcp(), fold_rsq(), fold_sqrt(), and parse_entry_function_attributes().

◆ init_deref()

static bool init_deref ( struct hlsl_ctx *  ctx,
struct hlsl_deref *  deref,
struct hlsl_ir_var *  var,
unsigned int  path_len 
)
static

Definition at line 692 of file hlsl.c.

694{
695 deref->var = var;
696 deref->path_len = path_len;
697 deref->rel_offset.node = NULL;
698 deref->const_offset = 0;
699 deref->data_type = NULL;
700
701 if (path_len == 0)
702 {
703 deref->path = NULL;
704 return true;
705 }
706
707 if (!(deref->path = hlsl_calloc(ctx, deref->path_len, sizeof(*deref->path))))
708 {
709 deref->var = NULL;
710 deref->path_len = 0;
711 return false;
712 }
713
714 return true;
715}
static DWORD path_len
Definition: batch.c:31

Referenced by clone_deref(), hlsl_copy_deref(), hlsl_init_deref_from_index_chain(), hlsl_new_load_index(), hlsl_new_store_index(), and init_deref_from_component_index().

◆ init_deref_from_component_index()

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 
)
static

Definition at line 801 of file hlsl.c.

804{
805 unsigned int path_len, path_index, deref_path_len, i;
806 struct hlsl_type *path_type;
807 struct hlsl_ir_node *c;
808
810
811 path_len = 0;
812 path_type = hlsl_deref_get_type(ctx, prefix);
813 path_index = index;
814 while (!type_is_single_component(path_type))
815 {
816 traverse_path_from_component_index(ctx, &path_type, &path_index);
817 ++path_len;
818 }
819
820 if (!init_deref(ctx, deref, prefix->var, prefix->path_len + path_len))
821 return false;
822
823 deref_path_len = 0;
824 for (i = 0; i < prefix->path_len; ++i)
825 hlsl_src_from_node(&deref->path[deref_path_len++], prefix->path[i].node);
826
827 path_type = hlsl_deref_get_type(ctx, prefix);
828 path_index = index;
829 while (!type_is_single_component(path_type))
830 {
831 unsigned int next_index = traverse_path_from_component_index(ctx, &path_type, &path_index);
832
833 if (!(c = hlsl_new_uint_constant(ctx, next_index, loc)))
834 {
836 return false;
837 }
839
840 hlsl_src_from_node(&deref->path[deref_path_len++], c);
841 }
842
843 VKD3D_ASSERT(deref_path_len == deref->path_len);
844
845 return true;
846}
struct hlsl_ir_node * hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n, const struct vkd3d_shader_location *loc)
Definition: hlsl.c:1562
Character const *const prefix
Definition: tempnam.cpp:195

Referenced by hlsl_new_load_component(), and hlsl_new_store_component().

◆ init_node()

◆ map_instr()

static struct hlsl_ir_node * map_instr ( const struct clone_instr_map *  map,
struct hlsl_ir_node *  src 
)
static

Definition at line 2120 of file hlsl.c.

2121{
2122 size_t i;
2123
2124 if (!src)
2125 return NULL;
2126
2127 for (i = 0; i < map->count; ++i)
2128 {
2129 if (map->instrs[i].src == src)
2130 return map->instrs[i].dst;
2131 }
2132
2133 return src;
2134}

Referenced by clone_compile(), clone_deref(), clone_expr(), clone_if(), clone_index(), clone_jump(), clone_src(), clone_switch(), and clone_swizzle().

◆ traverse_path_from_component_index()

static unsigned int traverse_path_from_component_index ( struct hlsl_ctx *  ctx,
struct hlsl_type **  type_ptr,
unsigned int *  index_ptr 
)
static

Definition at line 540 of file hlsl.c.

542{
543 struct hlsl_type *type = *type_ptr;
544 unsigned int index = *index_ptr;
545
548
549 switch (type->class)
550 {
552 VKD3D_ASSERT(index < type->dimx);
553 *type_ptr = hlsl_get_scalar_type(ctx, type->e.numeric.type);
554 *index_ptr = 0;
555 return index;
556
558 {
559 unsigned int y = index / type->dimx, x = index % type->dimx;
560 bool row_major = hlsl_type_is_row_major(type);
561
562 VKD3D_ASSERT(index < type->dimx * type->dimy);
563 *type_ptr = hlsl_get_vector_type(ctx, type->e.numeric.type, row_major ? type->dimx : type->dimy);
564 *index_ptr = row_major ? x : y;
565 return row_major ? y : x;
566 }
567
568 case HLSL_CLASS_ARRAY:
569 {
570 unsigned int elem_comp_count = hlsl_type_component_count(type->e.array.type);
571 unsigned int array_index;
572
573 *type_ptr = type->e.array.type;
574 *index_ptr = index % elem_comp_count;
575 array_index = index / elem_comp_count;
576 VKD3D_ASSERT(array_index < type->e.array.elements_count);
577 return array_index;
578 }
579
581 {
582 struct hlsl_struct_field *field;
583 unsigned int field_comp_count, i;
584
585 for (i = 0; i < type->e.record.field_count; ++i)
586 {
587 field = &type->e.record.fields[i];
588 field_comp_count = hlsl_type_component_count(field->type);
589 if (index < field_comp_count)
590 {
591 *type_ptr = field->type;
592 *index_ptr = index;
593 return i;
594 }
595 index -= field_comp_count;
596 }
598 }
599
601 {
602 *type_ptr = type->e.resource.format;
603 return traverse_path_from_component_index(ctx, type_ptr, index_ptr);
604 }
605
606 default:
608 }
609}
#define e
Definition: ke_i.h:82

Referenced by hlsl_component_to_string(), hlsl_type_get_component_offset(), hlsl_type_get_component_type(), init_deref_from_component_index(), and traverse_path_from_component_index().

◆ type_get_regset()

static enum hlsl_regset type_get_regset ( const struct hlsl_type *  type)
static

Definition at line 299 of file hlsl.c.

300{
301 switch (type->class)
302 {
306 return HLSL_REGSET_NUMERIC;
307
308 case HLSL_CLASS_ARRAY:
309 return type_get_regset(type->e.array.type);
310
313
316
317 case HLSL_CLASS_UAV:
318 return HLSL_REGSET_UAVS;
319
320 default:
321 break;
322 }
323
325}

Referenced by hlsl_deref_get_regset(), hlsl_type_get_component_offset(), and type_get_regset().

◆ type_is_single_component()

static bool type_is_single_component ( const struct hlsl_type *  type)
static

◆ type_is_single_reg()

static bool type_is_single_reg ( const struct hlsl_type *  type)
static

Definition at line 1383 of file hlsl.c.

1384{
1385 return type->class == HLSL_CLASS_SCALAR || type->class == HLSL_CLASS_VECTOR;
1386}

Referenced by hlsl_new_store_component(), and hlsl_new_store_index().