ReactOS 0.4.17-dev-934-g091855f
fx.c File Reference
#include "hlsl.h"
Include dependency graph for fx.c:

Go to the source code of this file.

Classes

struct  fx_4_binary_type
 
struct  string_entry
 
struct  type_entry
 
struct  function_component
 
struct  state_block_function_info
 
struct  fx_write_context_ops
 
struct  fx_write_context
 
struct  rhs_named_value
 
struct  replace_state_context
 
struct  fx_4_state
 
struct  fx_parser
 

Enumerations

enum  fx_4_type_constants {
  FX_4_NUMERIC_TYPE_FLOAT = 1 , FX_4_NUMERIC_TYPE_INT = 2 , FX_4_NUMERIC_TYPE_UINT = 3 , FX_4_NUMERIC_TYPE_BOOL = 4 ,
  FX_4_NUMERIC_CLASS_SCALAR = 1 , FX_4_NUMERIC_CLASS_VECTOR = 2 , FX_4_NUMERIC_CLASS_MATRIX = 3 , FX_4_NUMERIC_BASE_TYPE_SHIFT = 3 ,
  FX_4_NUMERIC_ROWS_SHIFT = 8 , FX_4_NUMERIC_COLUMNS_SHIFT = 11 , FX_4_NUMERIC_COLUMN_MAJOR_MASK = 0x4000 , FX_4_OBJECT_TYPE_STRING = 0x1 ,
  FX_4_OBJECT_TYPE_BLEND_STATE = 0x2 , FX_4_OBJECT_TYPE_DEPTH_STENCIL_STATE = 0x3 , FX_4_OBJECT_TYPE_RASTERIZER_STATE = 0x4 , FX_4_OBJECT_TYPE_PIXEL_SHADER = 0x5 ,
  FX_4_OBJECT_TYPE_VERTEX_SHADER = 0x6 , FX_4_OBJECT_TYPE_GEOMETRY_SHADER = 0x7 , FX_4_OBJECT_TYPE_GEOMETRY_SHADER_SO = 0x8 , FX_4_OBJECT_TYPE_TEXTURE = 0x9 ,
  FX_4_OBJECT_TYPE_TEXTURE_1D = 0xa , FX_4_OBJECT_TYPE_TEXTURE_1DARRAY = 0xb , FX_4_OBJECT_TYPE_TEXTURE_2D = 0xc , FX_4_OBJECT_TYPE_TEXTURE_2DARRAY = 0xd ,
  FX_4_OBJECT_TYPE_TEXTURE_2DMS = 0xe , FX_4_OBJECT_TYPE_TEXTURE_2DMSARRAY = 0xf , FX_4_OBJECT_TYPE_TEXTURE_3D = 0x10 , FX_4_OBJECT_TYPE_TEXTURE_CUBE = 0x11 ,
  FX_4_OBJECT_TYPE_RTV = 0x13 , FX_4_OBJECT_TYPE_DSV = 0x14 , FX_4_OBJECT_TYPE_SAMPLER_STATE = 0x15 , FX_4_OBJECT_TYPE_TEXTURE_CUBEARRAY = 0x17 ,
  FX_5_OBJECT_TYPE_GEOMETRY_SHADER = 0x1b , FX_5_OBJECT_TYPE_COMPUTE_SHADER = 0x1c , FX_5_OBJECT_TYPE_HULL_SHADER = 0x1d , FX_5_OBJECT_TYPE_DOMAIN_SHADER = 0x1e ,
  FX_5_OBJECT_TYPE_UAV_1D = 0x1f , FX_5_OBJECT_TYPE_UAV_1DARRAY = 0x20 , FX_5_OBJECT_TYPE_UAV_2D = 0x21 , FX_5_OBJECT_TYPE_UAV_2DARRAY = 0x22 ,
  FX_5_OBJECT_TYPE_UAV_3D = 0x23 , FX_5_OBJECT_TYPE_UAV_BUFFER = 0x24 , FX_5_OBJECT_TYPE_SRV_RAW_BUFFER = 0x25 , FX_5_OBJECT_TYPE_UAV_RAW_BUFFER = 0x26 ,
  FX_5_OBJECT_TYPE_SRV_STRUCTURED_BUFFER = 0x27 , FX_5_OBJECT_TYPE_UAV_STRUCTURED_BUFFER = 0x28 , FX_5_OBJECT_TYPE_SRV_APPEND_STRUCTURED_BUFFER = 0x2b , FX_5_OBJECT_TYPE_SRV_CONSUME_STRUCTURED_BUFFER = 0x2c ,
  FX_4_TYPE_CLASS_NUMERIC = 1 , FX_4_TYPE_CLASS_OBJECT = 2 , FX_4_TYPE_CLASS_STRUCT = 3 , FX_4_ASSIGNMENT_CONSTANT = 0x1 ,
  FX_4_ASSIGNMENT_VARIABLE = 0x2 , FX_4_ASSIGNMENT_ARRAY_CONSTANT_INDEX = 0x3 , FX_4_ASSIGNMENT_ARRAY_VARIABLE_INDEX = 0x4
}
 
enum  state_property_component_type {
  FX_BOOL , FX_FLOAT , FX_UINT , FX_UINT8 ,
  FX_DEPTHSTENCIL , FX_RASTERIZER , FX_DOMAINSHADER , FX_HULLSHADER ,
  FX_COMPUTESHADER , FX_TEXTURE , FX_DEPTHSTENCILVIEW , FX_RENDERTARGETVIEW ,
  FX_BLEND , FX_VERTEXSHADER , FX_PIXELSHADER , FX_COMPONENT_TYPE_COUNT
}
 

Functions

static size_t put_u32_unaligned (struct vkd3d_bytecode_buffer *buffer, uint32_t value)
 
static int string_storage_compare (const void *key, const struct rb_entry *entry)
 
static void string_storage_destroy (struct rb_entry *entry, void *context)
 
static const struct state_block_function_info * get_state_block_function_info (const char *name)
 
static void add_function_component (struct function_component **components, const char *name, bool lhs_has_index, unsigned int lhs_index)
 
static void get_state_block_function_components (const struct state_block_function_info *info, struct function_component *components, unsigned int comp_count)
 
bool hlsl_validate_state_block_entry (struct hlsl_ctx *ctx, struct hlsl_state_block_entry *entry, const struct vkd3d_shader_location *loc)
 
static void set_status (struct fx_write_context *fx, int status)
 
static uint32_t write_string (const char *string, struct fx_write_context *fx)
 
static void write_pass (struct hlsl_ir_var *var, struct fx_write_context *fx)
 
static uint32_t write_annotations (struct hlsl_scope *scope, struct fx_write_context *fx)
 
static void write_fx_4_annotations (struct hlsl_scope *scope, struct fx_write_context *fx)
 
static uint32_t write_fx_4_type (const struct hlsl_type *type, struct fx_write_context *fx)
 
static const char * get_fx_4_type_name (const struct hlsl_type *type)
 
static void write_fx_4_annotation (struct hlsl_ir_var *var, struct fx_write_context *fx)
 
static void write_fx_4_state_block (struct hlsl_ir_var *var, unsigned int block_index, uint32_t count_offset, struct fx_write_context *fx)
 
static uint32_t write_type (const struct hlsl_type *type, struct fx_write_context *fx)
 
static void fx_write_context_init (struct hlsl_ctx *ctx, const struct fx_write_context_ops *ops, struct fx_write_context *fx)
 
static int fx_write_context_cleanup (struct fx_write_context *fx)
 
static bool technique_matches_version (const struct hlsl_ir_var *var, const struct fx_write_context *fx)
 
static uint32_t write_fx_4_string (const char *string, struct fx_write_context *fx)
 
static void write_fx_4_pass (struct hlsl_ir_var *var, struct fx_write_context *fx)
 
static void write_fx_2_annotations (struct hlsl_ir_var *var, uint32_t count_offset, struct fx_write_context *fx)
 
static void write_fx_2_pass (struct hlsl_ir_var *var, struct fx_write_context *fx)
 
static uint32_t get_fx_4_type_size (const struct hlsl_type *type)
 
static uint32_t get_fx_4_numeric_type_description (const struct hlsl_type *type, struct fx_write_context *fx)
 
static bool is_numeric_fx_4_type (const struct hlsl_type *type)
 
static void write_fx_4_technique (struct hlsl_ir_var *var, struct fx_write_context *fx)
 
static void write_techniques (struct hlsl_scope *scope, struct fx_write_context *fx)
 
static void write_group (struct hlsl_ir_var *var, struct fx_write_context *fx)
 
static void write_groups (struct fx_write_context *fx)
 
static uint32_t write_fx_2_string (const char *string, struct fx_write_context *fx)
 
static uint32_t get_fx_2_type_class (const struct hlsl_type *type)
 
static uint32_t write_fx_2_parameter (const struct hlsl_type *type, const char *name, const struct hlsl_semantic *semantic, struct fx_write_context *fx)
 
static void write_fx_2_technique (struct hlsl_ir_var *var, struct fx_write_context *fx)
 
static uint32_t write_fx_2_default_value (struct hlsl_type *value_type, struct hlsl_default_value *value, struct fx_write_context *fx)
 
static uint32_t write_fx_2_object_initializer (const struct hlsl_ir_var *var, struct fx_write_context *fx)
 
static uint32_t write_fx_2_initial_value (const struct hlsl_ir_var *var, struct fx_write_context *fx)
 
static bool is_type_supported_fx_2 (struct hlsl_ctx *ctx, const struct hlsl_type *type, const struct vkd3d_shader_location *loc)
 
static void write_fx_2_parameters (struct fx_write_context *fx)
 
static void write_fx_2_annotation (struct hlsl_ir_var *var, struct fx_write_context *fx)
 
static int hlsl_fx_2_write (struct hlsl_ctx *ctx, struct vkd3d_shader_code *out)
 
static uint32_t write_fx_4_default_value (struct hlsl_type *value_type, struct hlsl_default_value *value, struct fx_write_context *fx)
 
static void write_fx_4_string_initializer (struct hlsl_ir_var *var, struct fx_write_context *fx)
 
static void write_fx_4_numeric_variable (struct hlsl_ir_var *var, bool shared, struct fx_write_context *fx)
 
static bool get_fx_4_state_enum_value (const struct rhs_named_value *pairs, const char *name, unsigned int *value)
 
static uint32_t write_fx_4_state_numeric_value (struct hlsl_ir_constant *value, struct fx_write_context *fx)
 
static void write_fx_4_state_assignment (const struct hlsl_ir_var *var, struct hlsl_state_block_entry *entry, struct fx_write_context *fx)
 
static bool state_block_contains_state (const struct hlsl_state_block_entry *entry, unsigned int start_index, struct hlsl_state_block *block)
 
static bool lower_null_constant (struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
 
static bool replace_state_block_constant (struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
 
static bool is_object_fx_type (enum state_property_component_type type)
 
static enum hlsl_type_class hlsl_type_class_from_fx_type (enum state_property_component_type type)
 
static enum hlsl_base_type hlsl_type_from_fx_type (enum state_property_component_type type)
 
static void resolve_fx_4_state_block_values (struct hlsl_ir_var *var, struct hlsl_state_block_entry *entry, struct fx_write_context *fx)
 
static bool decompose_fx_4_state_add_entries (struct hlsl_state_block *block, unsigned int entry_index, unsigned int count)
 
static unsigned int decompose_fx_4_state_function_call (struct hlsl_ir_var *var, struct hlsl_state_block *block, unsigned int entry_index, struct fx_write_context *fx)
 
static unsigned int decompose_fx_4_state_block_expand_array (struct hlsl_ir_var *var, struct hlsl_state_block *block, unsigned int entry_index, struct fx_write_context *fx)
 
static unsigned int decompose_fx_4_state_block (struct hlsl_ir_var *var, struct hlsl_state_block *block, unsigned int entry_index, struct fx_write_context *fx)
 
static void write_fx_4_state_object_initializer (struct hlsl_ir_var *var, struct fx_write_context *fx)
 
static void write_fx_4_shader_initializer (struct hlsl_ir_var *var, struct fx_write_context *fx)
 
static void write_fx_5_shader_initializer (struct hlsl_ir_var *var, struct fx_write_context *fx)
 
static void write_fx_4_object_variable (struct hlsl_ir_var *var, struct fx_write_context *fx)
 
static void write_fx_4_buffer (struct hlsl_buffer *b, struct fx_write_context *fx)
 
static void write_buffers (struct fx_write_context *fx, bool shared)
 
static bool is_supported_object_variable (const struct hlsl_ctx *ctx, const struct hlsl_ir_var *var)
 
static void write_objects (struct fx_write_context *fx, bool shared)
 
static int hlsl_fx_4_write (struct hlsl_ctx *ctx, struct vkd3d_shader_code *out)
 
static int hlsl_fx_5_write (struct hlsl_ctx *ctx, struct vkd3d_shader_code *out)
 
int hlsl_emit_effect_binary (struct hlsl_ctx *ctx, struct vkd3d_shader_code *out)
 
static uint32_t fx_parser_read_u32 (struct fx_parser *parser)
 
static void fx_parser_read_u32s (struct fx_parser *parser, void *dst, size_t size)
 
static void fx_parser_skip (struct fx_parser *parser, size_t size)
 
static void VKD3D_PRINTF_FUNC (3, 4)
 
static int fx_2_parse (struct fx_parser *parser)
 
static const void * fx_parser_get_unstructured_ptr (struct fx_parser *parser, uint32_t offset, size_t size)
 
static void fx_parser_read_unstructured (struct fx_parser *parser, void *dst, uint32_t offset, size_t size)
 
static const char * fx_4_get_string (struct fx_parser *parser, uint32_t offset)
 
static void parse_fx_start_indent (struct fx_parser *parser)
 
static void parse_fx_end_indent (struct fx_parser *parser)
 
static void parse_fx_print_indent (struct fx_parser *parser)
 
static void parse_fx_4_numeric_value (struct fx_parser *parser, uint32_t offset, const struct fx_4_binary_type *type)
 
static void fx_4_parse_string_initializer (struct fx_parser *parser, uint32_t offset)
 
static void fx_parse_fx_4_annotations (struct fx_parser *parser)
 
static void fx_parse_fx_4_numeric_variables (struct fx_parser *parser, uint32_t count)
 
static void fx_parse_buffers (struct fx_parser *parser)
 
static void fx_4_parse_shader_initializer (struct fx_parser *parser, unsigned int object_type)
 
static bool fx_4_object_has_initializer (const struct fx_4_binary_type *type)
 
static int fx_4_state_id_compare (const void *a, const void *b)
 
static void fx_4_parse_state_object_initializer (struct fx_parser *parser, uint32_t count, enum hlsl_type_class type_class)
 
static void fx_4_parse_object_initializer (struct fx_parser *parser, const struct fx_4_binary_type *type)
 
static void fx_4_parse_objects (struct fx_parser *parser)
 
static void fx_parse_fx_4_technique (struct fx_parser *parser)
 
static void fx_parse_groups (struct fx_parser *parser)
 
static int fx_4_parse (struct fx_parser *parser)
 
static int fx_5_parse (struct fx_parser *parser)
 
int fx_parse (const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context)
 

Variables

static const struct state_block_function_info function_info []
 
static const uint32_t fx_4_numeric_base_types []
 
static const struct fx_write_context_ops fx_2_ops
 
static const struct fx_write_context_ops fx_4_ops
 
static const struct rhs_named_value filter_values []
 
static const struct rhs_named_value address_values []
 
static const struct rhs_named_value compare_func_values []
 
static const struct rhs_named_value depth_write_mask_values []
 
static const struct rhs_named_value comparison_values []
 
static const struct rhs_named_value stencil_op_values []
 
static const struct rhs_named_value fill_values []
 
static const struct rhs_named_value cull_values []
 
static const struct rhs_named_value blend_values []
 
static const struct rhs_named_value blendop_values []
 
static const struct rhs_named_value bool_values []
 
static const struct rhs_named_value null_values []
 
static const struct fx_4_state fx_4_states []
 

Enumeration Type Documentation

◆ fx_4_type_constants

Enumerator
FX_4_NUMERIC_TYPE_FLOAT 
FX_4_NUMERIC_TYPE_INT 
FX_4_NUMERIC_TYPE_UINT 
FX_4_NUMERIC_TYPE_BOOL 
FX_4_NUMERIC_CLASS_SCALAR 
FX_4_NUMERIC_CLASS_VECTOR 
FX_4_NUMERIC_CLASS_MATRIX 
FX_4_NUMERIC_BASE_TYPE_SHIFT 
FX_4_NUMERIC_ROWS_SHIFT 
FX_4_NUMERIC_COLUMNS_SHIFT 
FX_4_NUMERIC_COLUMN_MAJOR_MASK 
FX_4_OBJECT_TYPE_STRING 
FX_4_OBJECT_TYPE_BLEND_STATE 
FX_4_OBJECT_TYPE_DEPTH_STENCIL_STATE 
FX_4_OBJECT_TYPE_RASTERIZER_STATE 
FX_4_OBJECT_TYPE_PIXEL_SHADER 
FX_4_OBJECT_TYPE_VERTEX_SHADER 
FX_4_OBJECT_TYPE_GEOMETRY_SHADER 
FX_4_OBJECT_TYPE_GEOMETRY_SHADER_SO 
FX_4_OBJECT_TYPE_TEXTURE 
FX_4_OBJECT_TYPE_TEXTURE_1D 
FX_4_OBJECT_TYPE_TEXTURE_1DARRAY 
FX_4_OBJECT_TYPE_TEXTURE_2D 
FX_4_OBJECT_TYPE_TEXTURE_2DARRAY 
FX_4_OBJECT_TYPE_TEXTURE_2DMS 
FX_4_OBJECT_TYPE_TEXTURE_2DMSARRAY 
FX_4_OBJECT_TYPE_TEXTURE_3D 
FX_4_OBJECT_TYPE_TEXTURE_CUBE 
FX_4_OBJECT_TYPE_RTV 
FX_4_OBJECT_TYPE_DSV 
FX_4_OBJECT_TYPE_SAMPLER_STATE 
FX_4_OBJECT_TYPE_TEXTURE_CUBEARRAY 
FX_5_OBJECT_TYPE_GEOMETRY_SHADER 
FX_5_OBJECT_TYPE_COMPUTE_SHADER 
FX_5_OBJECT_TYPE_HULL_SHADER 
FX_5_OBJECT_TYPE_DOMAIN_SHADER 
FX_5_OBJECT_TYPE_UAV_1D 
FX_5_OBJECT_TYPE_UAV_1DARRAY 
FX_5_OBJECT_TYPE_UAV_2D 
FX_5_OBJECT_TYPE_UAV_2DARRAY 
FX_5_OBJECT_TYPE_UAV_3D 
FX_5_OBJECT_TYPE_UAV_BUFFER 
FX_5_OBJECT_TYPE_SRV_RAW_BUFFER 
FX_5_OBJECT_TYPE_UAV_RAW_BUFFER 
FX_5_OBJECT_TYPE_SRV_STRUCTURED_BUFFER 
FX_5_OBJECT_TYPE_UAV_STRUCTURED_BUFFER 
FX_5_OBJECT_TYPE_SRV_APPEND_STRUCTURED_BUFFER 
FX_5_OBJECT_TYPE_SRV_CONSUME_STRUCTURED_BUFFER 
FX_4_TYPE_CLASS_NUMERIC 
FX_4_TYPE_CLASS_OBJECT 
FX_4_TYPE_CLASS_STRUCT 
FX_4_ASSIGNMENT_CONSTANT 
FX_4_ASSIGNMENT_VARIABLE 
FX_4_ASSIGNMENT_ARRAY_CONSTANT_INDEX 
FX_4_ASSIGNMENT_ARRAY_VARIABLE_INDEX 

Definition at line 484 of file fx.c.

485{
486 /* Numeric types encoding */
491
495
500
501 /* Object types */
510
524
529
542
543 /* Types */
547
548 /* Assignment types */
553};
@ FX_4_OBJECT_TYPE_BLEND_STATE
Definition: fx.c:503
@ FX_5_OBJECT_TYPE_UAV_1DARRAY
Definition: fx.c:531
@ FX_5_OBJECT_TYPE_UAV_STRUCTURED_BUFFER
Definition: fx.c:539
@ FX_5_OBJECT_TYPE_UAV_BUFFER
Definition: fx.c:535
@ FX_5_OBJECT_TYPE_HULL_SHADER
Definition: fx.c:527
@ FX_4_OBJECT_TYPE_DSV
Definition: fx.c:521
@ FX_4_NUMERIC_TYPE_INT
Definition: fx.c:488
@ FX_4_NUMERIC_BASE_TYPE_SHIFT
Definition: fx.c:496
@ FX_4_OBJECT_TYPE_TEXTURE_2DMSARRAY
Definition: fx.c:517
@ FX_4_NUMERIC_CLASS_VECTOR
Definition: fx.c:493
@ FX_5_OBJECT_TYPE_GEOMETRY_SHADER
Definition: fx.c:525
@ FX_4_OBJECT_TYPE_TEXTURE
Definition: fx.c:511
@ FX_4_NUMERIC_ROWS_SHIFT
Definition: fx.c:497
@ FX_4_OBJECT_TYPE_GEOMETRY_SHADER
Definition: fx.c:508
@ FX_4_OBJECT_TYPE_SAMPLER_STATE
Definition: fx.c:522
@ FX_4_NUMERIC_TYPE_BOOL
Definition: fx.c:490
@ FX_4_OBJECT_TYPE_STRING
Definition: fx.c:502
@ FX_5_OBJECT_TYPE_SRV_APPEND_STRUCTURED_BUFFER
Definition: fx.c:540
@ FX_4_NUMERIC_CLASS_SCALAR
Definition: fx.c:492
@ FX_4_OBJECT_TYPE_VERTEX_SHADER
Definition: fx.c:507
@ FX_4_ASSIGNMENT_CONSTANT
Definition: fx.c:549
@ FX_4_OBJECT_TYPE_TEXTURE_CUBEARRAY
Definition: fx.c:523
@ FX_5_OBJECT_TYPE_SRV_STRUCTURED_BUFFER
Definition: fx.c:538
@ FX_4_NUMERIC_COLUMN_MAJOR_MASK
Definition: fx.c:499
@ FX_4_OBJECT_TYPE_GEOMETRY_SHADER_SO
Definition: fx.c:509
@ FX_4_NUMERIC_TYPE_UINT
Definition: fx.c:489
@ FX_4_OBJECT_TYPE_TEXTURE_3D
Definition: fx.c:518
@ FX_4_TYPE_CLASS_OBJECT
Definition: fx.c:545
@ FX_5_OBJECT_TYPE_UAV_2DARRAY
Definition: fx.c:533
@ FX_4_OBJECT_TYPE_TEXTURE_1D
Definition: fx.c:512
@ FX_4_OBJECT_TYPE_TEXTURE_2DARRAY
Definition: fx.c:515
@ FX_4_TYPE_CLASS_STRUCT
Definition: fx.c:546
@ FX_4_ASSIGNMENT_ARRAY_VARIABLE_INDEX
Definition: fx.c:552
@ FX_4_OBJECT_TYPE_RTV
Definition: fx.c:520
@ FX_4_OBJECT_TYPE_PIXEL_SHADER
Definition: fx.c:506
@ FX_4_OBJECT_TYPE_TEXTURE_2DMS
Definition: fx.c:516
@ FX_5_OBJECT_TYPE_SRV_CONSUME_STRUCTURED_BUFFER
Definition: fx.c:541
@ FX_4_TYPE_CLASS_NUMERIC
Definition: fx.c:544
@ FX_5_OBJECT_TYPE_UAV_3D
Definition: fx.c:534
@ FX_4_ASSIGNMENT_VARIABLE
Definition: fx.c:550
@ FX_5_OBJECT_TYPE_SRV_RAW_BUFFER
Definition: fx.c:536
@ FX_4_OBJECT_TYPE_RASTERIZER_STATE
Definition: fx.c:505
@ FX_4_OBJECT_TYPE_TEXTURE_CUBE
Definition: fx.c:519
@ FX_4_NUMERIC_CLASS_MATRIX
Definition: fx.c:494
@ FX_5_OBJECT_TYPE_DOMAIN_SHADER
Definition: fx.c:528
@ FX_5_OBJECT_TYPE_UAV_2D
Definition: fx.c:532
@ FX_5_OBJECT_TYPE_UAV_1D
Definition: fx.c:530
@ FX_5_OBJECT_TYPE_COMPUTE_SHADER
Definition: fx.c:526
@ FX_4_OBJECT_TYPE_TEXTURE_2D
Definition: fx.c:514
@ FX_4_OBJECT_TYPE_TEXTURE_1DARRAY
Definition: fx.c:513
@ FX_4_NUMERIC_TYPE_FLOAT
Definition: fx.c:487
@ FX_4_NUMERIC_COLUMNS_SHIFT
Definition: fx.c:498
@ FX_4_ASSIGNMENT_ARRAY_CONSTANT_INDEX
Definition: fx.c:551
@ FX_4_OBJECT_TYPE_DEPTH_STENCIL_STATE
Definition: fx.c:504
@ FX_5_OBJECT_TYPE_UAV_RAW_BUFFER
Definition: fx.c:537

◆ state_property_component_type

Enumerator
FX_BOOL 
FX_FLOAT 
FX_UINT 
FX_UINT8 
FX_DEPTHSTENCIL 
FX_RASTERIZER 
FX_DOMAINSHADER 
FX_HULLSHADER 
FX_COMPUTESHADER 
FX_TEXTURE 
FX_DEPTHSTENCILVIEW 
FX_RENDERTARGETVIEW 
FX_BLEND 
FX_VERTEXSHADER 
FX_PIXELSHADER 
FX_COMPONENT_TYPE_COUNT 

Definition at line 1820 of file fx.c.

1821{
1822 FX_BOOL,
1823 FX_FLOAT,
1824 FX_UINT,
1825 FX_UINT8,
1831 FX_TEXTURE,
1834 FX_BLEND,
1838};
@ FX_DEPTHSTENCIL
Definition: fx.c:1826
@ FX_UINT
Definition: fx.c:1824
@ FX_FLOAT
Definition: fx.c:1823
@ FX_VERTEXSHADER
Definition: fx.c:1835
@ FX_RENDERTARGETVIEW
Definition: fx.c:1833
@ FX_UINT8
Definition: fx.c:1825
@ FX_HULLSHADER
Definition: fx.c:1829
@ FX_TEXTURE
Definition: fx.c:1831
@ FX_BLEND
Definition: fx.c:1834
@ FX_DEPTHSTENCILVIEW
Definition: fx.c:1832
@ FX_BOOL
Definition: fx.c:1822
@ FX_PIXELSHADER
Definition: fx.c:1836
@ FX_COMPUTESHADER
Definition: fx.c:1830
@ FX_COMPONENT_TYPE_COUNT
Definition: fx.c:1837
@ FX_DOMAINSHADER
Definition: fx.c:1828
@ FX_RASTERIZER
Definition: fx.c:1827

Function Documentation

◆ add_function_component()

static void add_function_component ( struct function_component **  components,
const char *  name,
bool  lhs_has_index,
unsigned int  lhs_index 
)
static

Definition at line 109 of file fx.c.

111{
112 struct function_component *comp = *components;
113
114 comp->name = name;
116 comp->lhs_index = lhs_index;
117
118 *components = *components + 1;
119}
GLenum GLenum GLuint components
Definition: glext.h:9620
bool lhs_has_index
Definition: fx.c:74
const char * name
Definition: fx.c:73
unsigned int lhs_index
Definition: fx.c:75

Referenced by get_state_block_function_components().

◆ decompose_fx_4_state_add_entries()

static bool decompose_fx_4_state_add_entries ( struct hlsl_state_block *  block,
unsigned int  entry_index,
unsigned int  count 
)
static

Definition at line 2314 of file fx.c.

2316{
2317 if (!vkd3d_array_reserve((void **)&block->entries, &block->capacity, block->count + count, sizeof(*block->entries)))
2318 return false;
2319
2320 if (entry_index != block->count - 1)
2321 {
2322 memmove(&block->entries[entry_index + count + 1], &block->entries[entry_index + 1],
2323 (block->count - entry_index - 1) * sizeof(*block->entries));
2324 }
2325 block->count += count;
2326
2327 return true;
2328}
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t element_count, size_t element_size)
Definition: memory.c:22
static unsigned int block
Definition: xmlmemory.c:101

Referenced by decompose_fx_4_state_block_expand_array(), and decompose_fx_4_state_function_call().

◆ decompose_fx_4_state_block()

static unsigned int decompose_fx_4_state_block ( struct hlsl_ir_var *  var,
struct hlsl_state_block *  block,
unsigned int  entry_index,
struct fx_write_context *  fx 
)
static

Definition at line 2422 of file fx.c.

2424{
2425 struct hlsl_state_block_entry *entry = block->entries[entry_index];
2426
2427 if (entry->is_function_call)
2428 return decompose_fx_4_state_function_call(var, block, entry_index, fx);
2429
2430 return decompose_fx_4_state_block_expand_array(var, block, entry_index, fx);
2431}
static unsigned int decompose_fx_4_state_function_call(struct hlsl_ir_var *var, struct hlsl_state_block *block, unsigned int entry_index, struct fx_write_context *fx)
Definition: fx.c:2330
static unsigned int decompose_fx_4_state_block_expand_array(struct hlsl_ir_var *var, struct hlsl_state_block *block, unsigned int entry_index, struct fx_write_context *fx)
Definition: fx.c:2379
uint32_t entry
Definition: isohybrid.c:63
const char * var
Definition: shader.c:5879
Definition: hlsl.h:549
GLfixed fx
Definition: tritemp.h:484

Referenced by write_fx_4_state_block().

◆ decompose_fx_4_state_block_expand_array()

static unsigned int decompose_fx_4_state_block_expand_array ( struct hlsl_ir_var *  var,
struct hlsl_state_block *  block,
unsigned int  entry_index,
struct fx_write_context *  fx 
)
static

Definition at line 2379 of file fx.c.

2381{
2382 static const char *states[] = { "SrcBlend", "DestBlend", "BlendOp", "SrcBlendAlpha", "DestBlendAlpha", "BlendOpAlpha" };
2383 const struct hlsl_type *type = hlsl_get_multiarray_element_type(var->data_type);
2384 struct hlsl_state_block_entry *entry = block->entries[entry_index];
2385 static const unsigned int array_size = 8;
2386 struct hlsl_ctx *ctx = fx->ctx;
2387 bool found = false;
2388 unsigned int i;
2389
2390 if (type->class != HLSL_CLASS_BLEND_STATE)
2391 return 1;
2392 if (hlsl_version_lt(ctx, 4, 1))
2393 return 1;
2394 if (entry->lhs_has_index)
2395 return 1;
2396
2397 for (i = 0; i < ARRAY_SIZE(states); ++i)
2398 {
2399 if (!ascii_strcasecmp(entry->name, states[i]))
2400 {
2401 found = true;
2402 break;
2403 }
2404 }
2405
2406 if (!found)
2407 return 1;
2408
2409 if (!decompose_fx_4_state_add_entries(block, entry_index, array_size - 1))
2410 return 1;
2411
2412 block->entries[entry_index]->lhs_has_index = true;
2413 for (i = 1; i < array_size; ++i)
2414 {
2415 block->entries[entry_index + i] = clone_stateblock_entry(ctx, entry,
2416 entry->name, true, i, true, 0);
2417 }
2418
2419 return array_size;
2420}
#define ARRAY_SIZE(A)
Definition: main.h:20
static bool decompose_fx_4_state_add_entries(struct hlsl_state_block *block, unsigned int entry_index, unsigned int count)
Definition: fx.c:2314
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
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
const struct hlsl_type * hlsl_get_multiarray_element_type(const struct hlsl_type *type)
Definition: hlsl.c:226
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
@ HLSL_CLASS_BLEND_STATE
Definition: hlsl.h:107
static bool hlsl_version_lt(const struct hlsl_ctx *ctx, unsigned int major, unsigned int minor)
Definition: hlsl.h:1146
static UINT array_size
Definition: msctf.cpp:39
static int ascii_strcasecmp(const char *a, const char *b)
Definition: vkd3d_common.h:437

Referenced by decompose_fx_4_state_block().

◆ decompose_fx_4_state_function_call()

static unsigned int decompose_fx_4_state_function_call ( struct hlsl_ir_var *  var,
struct hlsl_state_block *  block,
unsigned int  entry_index,
struct fx_write_context *  fx 
)
static

Definition at line 2330 of file fx.c.

2332{
2333 struct hlsl_state_block_entry *entry = block->entries[entry_index];
2334 const struct state_block_function_info *info;
2336 struct hlsl_ctx *ctx = fx->ctx;
2337 unsigned int i;
2338
2339 if (!entry->is_function_call)
2340 return 1;
2341
2343 return 1;
2344
2345 if (info->min_profile > ctx->profile->major_version)
2346 {
2348 "State %s is not supported for this profile.", entry->name);
2349 return 1;
2350 }
2351
2352 /* For single argument case simply replace the name. */
2353 if (info->min_args == info->max_args && info->min_args == 1)
2354 {
2355 vkd3d_free(entry->name);
2356 entry->name = hlsl_strdup(ctx, info->components[0].name);
2357 return 1;
2358 }
2359
2360 if (!decompose_fx_4_state_add_entries(block, entry_index, entry->args_count - 1))
2361 return 1;
2362
2364
2365 for (i = 0; i < entry->args_count; ++i)
2366 {
2367 const struct function_component *comp = &components[i];
2368 unsigned int arg_index = (i + 1) % entry->args_count;
2369 block->entries[entry_index + i] = clone_stateblock_entry(ctx, entry, comp->name,
2370 comp->lhs_has_index, comp->lhs_index, true, arg_index);
2371 }
2373
2374 return entry->args_count;
2375}
static void get_state_block_function_components(const struct state_block_function_info *info, struct function_component *components, unsigned int comp_count)
Definition: fx.c:121
static const struct state_block_function_info * get_state_block_function_info(const char *name)
Definition: fx.c:99
void hlsl_free_state_block_entry(struct hlsl_state_block_entry *entry)
Definition: hlsl.c:137
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 char * hlsl_strdup(struct hlsl_ctx *ctx, const char *string)
Definition: hlsl.h:1327
static void vkd3d_free(void *ptr)
Definition: vkd3d_memory.h:52
@ VKD3D_SHADER_ERROR_HLSL_INVALID_STATE_BLOCK_ENTRY

Referenced by decompose_fx_4_state_block().

◆ fx_2_parse()

static int fx_2_parse ( struct fx_parser *  parser)
static

Definition at line 2952 of file fx.c.

2953{
2954 fx_parser_error(parser, VKD3D_SHADER_ERROR_FX_NOT_IMPLEMENTED, "Parsing fx_2_0 binaries is not implemented.\n");
2955
2956 return -1;
2957}
Definition: import.c:81
@ VKD3D_SHADER_ERROR_FX_NOT_IMPLEMENTED

Referenced by fx_parse().

◆ fx_4_get_string()

static const char * fx_4_get_string ( struct fx_parser *  parser,
uint32_t  offset 
)
static

Definition at line 2984 of file fx.c.

2985{
2986 const uint8_t *ptr = parser->unstructured.ptr;
2987 const uint8_t *end = parser->unstructured.end;
2988
2989 if (offset >= parser->unstructured.size)
2990 {
2991 parser->failed = true;
2992 return "<invalid>";
2993 }
2994
2995 ptr += offset;
2996
2997 while (ptr < end && *ptr)
2998 ++ptr;
2999
3000 if (*ptr)
3001 {
3002 parser->failed = true;
3003 return "<invalid>";
3004 }
3005
3006 return (const char *)(parser->unstructured.ptr + offset);
3007}
unsigned char uint8_t
Definition: stdint.h:33
GLuint GLuint end
Definition: gl.h:1545
GLintptr offset
Definition: glext.h:5920
static PVOID ptr
Definition: dispmode.c:27
const CHAR * end
Definition: inffile.c:88

Referenced by fx_4_parse_objects(), fx_4_parse_shader_initializer(), fx_4_parse_state_object_initializer(), fx_4_parse_string_initializer(), fx_parse_buffers(), fx_parse_fx_4_annotations(), fx_parse_fx_4_numeric_variables(), fx_parse_fx_4_technique(), and fx_parse_groups().

◆ fx_4_object_has_initializer()

static bool fx_4_object_has_initializer ( const struct fx_4_binary_type *  type)
static

Definition at line 3330 of file fx.c.

Referenced by fx_4_parse_object_initializer().

◆ fx_4_parse()

static int fx_4_parse ( struct fx_parser *  parser)
static

Definition at line 3683 of file fx.c.

3684{
3685 struct fx_4_header
3686 {
3689 uint32_t numeric_variable_count;
3691 uint32_t shared_buffer_count;
3692 uint32_t shared_numeric_variable_count;
3693 uint32_t shared_object_count;
3694 uint32_t technique_count;
3695 uint32_t unstructured_size;
3696 uint32_t string_count;
3697 uint32_t texture_count;
3698 uint32_t depth_stencil_state_count;
3699 uint32_t blend_state_count;
3700 uint32_t rasterizer_state_count;
3701 uint32_t sampler_state_count;
3702 uint32_t rtv_count;
3703 uint32_t dsv_count;
3704 uint32_t shader_count;
3705 uint32_t inline_shader_count;
3706 } header;
3707 uint32_t i;
3708
3709 parser->version = 10;
3711 parser->buffer_count = header.buffer_count;
3712 parser->object_count = header.object_count;
3713
3714 if (parser->end - parser->ptr < header.unstructured_size)
3715 {
3716 parser->failed = true;
3717 return -1;
3718 }
3719
3720 parser->unstructured.ptr = parser->ptr;
3721 parser->unstructured.end = parser->ptr + header.unstructured_size;
3722 parser->unstructured.size = header.unstructured_size;
3723 fx_parser_skip(parser, header.unstructured_size);
3724
3727
3728 for (i = 0; i < header.technique_count; ++i)
3730
3731 return parser->failed ? - 1 : 0;
3732}
UINT32 uint32_t
Definition: types.h:75
static const WCHAR version[]
Definition: asmname.c:66
static void fx_parse_buffers(struct fx_parser *parser)
Definition: fx.c:3180
static void fx_4_parse_objects(struct fx_parser *parser)
Definition: fx.c:3555
static void fx_parse_fx_4_technique(struct fx_parser *parser)
Definition: fx.c:3592
static void fx_parser_skip(struct fx_parser *parser, size_t size)
Definition: fx.c:2929
static void fx_parser_read_u32s(struct fx_parser *parser, void *dst, size_t size)
Definition: fx.c:2920
long object_count
Definition: nc_alloc.cpp:37
size_t const buffer_count
Definition: xtoa.cpp:36

Referenced by fx_parse().

◆ fx_4_parse_object_initializer()

static void fx_4_parse_object_initializer ( struct fx_parser *  parser,
const struct fx_4_binary_type *  type 
)
static

Definition at line 3497 of file fx.c.

3498{
3499 static const enum hlsl_type_class type_classes[] =
3500 {
3505 };
3506 unsigned int i, element_count, count;
3508
3510 return;
3511
3512 vkd3d_string_buffer_printf(&parser->buffer, " = {\n");
3513 element_count = max(type->element_count, 1);
3514 for (i = 0; i < element_count; ++i)
3515 {
3516 switch (type->typeinfo)
3517 {
3519 vkd3d_string_buffer_printf(&parser->buffer, " ");
3522 break;
3528
3530 fx_4_parse_state_object_initializer(parser, count, type_classes[type->typeinfo]);
3532 break;
3544 break;
3545 default:
3547 "Parsing object type %u is not implemented.", type->typeinfo);
3548 return;
3549 }
3550 vkd3d_string_buffer_printf(&parser->buffer, ",\n");
3551 }
3552 vkd3d_string_buffer_printf(&parser->buffer, "}");
3553}
static uint32_t fx_parser_read_u32(struct fx_parser *parser)
Definition: fx.c:2904
static void parse_fx_end_indent(struct fx_parser *parser)
Definition: fx.c:3014
static void fx_4_parse_state_object_initializer(struct fx_parser *parser, uint32_t count, enum hlsl_type_class type_class)
Definition: fx.c:3361
static void fx_4_parse_string_initializer(struct fx_parser *parser, uint32_t offset)
Definition: fx.c:3057
static bool fx_4_object_has_initializer(const struct fx_4_binary_type *type)
Definition: fx.c:3330
static void fx_4_parse_shader_initializer(struct fx_parser *parser, unsigned int object_type)
Definition: fx.c:3213
static void parse_fx_start_indent(struct fx_parser *parser)
Definition: fx.c:3009
hlsl_type_class
Definition: hlsl.h:82
@ HLSL_CLASS_RASTERIZER_STATE
Definition: hlsl.h:94
@ HLSL_CLASS_SAMPLER
Definition: hlsl.h:96
@ HLSL_CLASS_DEPTH_STENCIL_STATE
Definition: hlsl.h:89
static ULONG ** element_count
Definition: exception.c:124
#define max(a, b)
Definition: svc.c:63
Definition: pdh_main.c:64
int vkd3d_string_buffer_printf(struct vkd3d_string_buffer *buffer, const char *format,...)

Referenced by fx_4_parse_objects().

◆ fx_4_parse_objects()

static void fx_4_parse_objects ( struct fx_parser *  parser)
static

Definition at line 3555 of file fx.c.

3556{
3557 struct fx_4_object_variable
3558 {
3559 uint32_t name;
3560 uint32_t type;
3561 uint32_t semantic;
3562 uint32_t bind_point;
3563 } var;
3564 struct fx_4_binary_type type;
3565 const char *name, *type_name;
3566 uint32_t i;
3567
3568 if (parser->failed)
3569 return;
3570
3571 for (i = 0; i < parser->object_count; ++i)
3572 {
3573 if (parser->failed)
3574 return;
3575
3576 fx_parser_read_u32s(parser, &var, sizeof(var));
3578
3579 name = fx_4_get_string(parser, var.name);
3580 type_name = fx_4_get_string(parser, type.name);
3581 vkd3d_string_buffer_printf(&parser->buffer, "%s %s", type_name, name);
3582 if (type.element_count)
3583 vkd3d_string_buffer_printf(&parser->buffer, "[%u]", type.element_count);
3584
3586 vkd3d_string_buffer_printf(&parser->buffer, ";\n");
3587
3589 }
3590}
static void fx_4_parse_object_initializer(struct fx_parser *parser, const struct fx_4_binary_type *type)
Definition: fx.c:3497
static void fx_parser_read_unstructured(struct fx_parser *parser, void *dst, uint32_t offset, size_t size)
Definition: fx.c:2973
static const char * fx_4_get_string(struct fx_parser *parser, uint32_t offset)
Definition: fx.c:2984
static void fx_parse_fx_4_annotations(struct fx_parser *parser)
Definition: fx.c:3063
uint32_t name
Definition: fx.c:30
Definition: name.c:39

Referenced by fx_4_parse(), and fx_5_parse().

◆ fx_4_parse_shader_initializer()

static void fx_4_parse_shader_initializer ( struct fx_parser *  parser,
unsigned int  object_type 
)
static

Definition at line 3213 of file fx.c.

3214{
3215 struct vkd3d_shader_compile_info info = { 0 };
3216 struct vkd3d_shader_code output;
3217 uint32_t data_size, offset;
3218 const void *data = NULL;
3219 const char *p, *q, *end;
3220 struct fx_5_shader
3221 {
3223 uint32_t sodecl[4];
3224 uint32_t sodecl_count;
3225 uint32_t rast_stream;
3226 uint32_t iface_bindings_count;
3227 uint32_t iface_bindings;
3228 } shader5;
3229 struct fx_4_gs_so
3230 {
3232 uint32_t sodecl;
3233 } gs_so;
3234 int ret;
3235
3236 static const struct vkd3d_shader_compile_option options[] =
3237 {
3239 };
3240
3241 switch (object_type)
3242 {
3247 break;
3248
3250 fx_parser_read_u32s(parser, &gs_so, sizeof(gs_so));
3251 offset = gs_so.offset;
3252 break;
3253
3258 fx_parser_read_u32s(parser, &shader5, sizeof(shader5));
3259 offset = shader5.offset;
3260 break;
3261
3262 default:
3263 parser->failed = true;
3264 return;
3265 }
3266
3267 fx_parser_read_unstructured(parser, &data_size, offset, sizeof(data_size));
3268 if (data_size)
3270
3271 if (!data)
3272 return;
3273
3275 info.source.code = data;
3276 info.source.size = data_size;
3277 info.source_type = VKD3D_SHADER_SOURCE_DXBC_TPF;
3278 info.target_type = VKD3D_SHADER_TARGET_D3D_ASM;
3279 info.options = options;
3280 info.option_count = ARRAY_SIZE(options);
3281 info.log_level = VKD3D_SHADER_LOG_INFO;
3282
3283 if ((ret = vkd3d_shader_compile(&info, &output, NULL)) < 0)
3284 {
3286 "Failed to disassemble shader blob.\n");
3287 return;
3288 }
3290 vkd3d_string_buffer_printf(&parser->buffer, "asm {\n");
3291
3293
3294 end = (const char *)output.code + output.size;
3295 for (p = output.code; p < end; p = q)
3296 {
3297 if (!(q = memchr(p, '\n', end - p)))
3298 q = end;
3299 else
3300 ++q;
3301
3303 vkd3d_string_buffer_printf(&parser->buffer, "%.*s", (int)(q - p), p);
3304 }
3305
3307
3309 vkd3d_string_buffer_printf(&parser->buffer, "}");
3310 if (object_type == FX_4_OBJECT_TYPE_GEOMETRY_SHADER_SO && gs_so.sodecl)
3311 {
3312 vkd3d_string_buffer_printf(&parser->buffer, "\n/* Stream output declaration: \"%s\" */",
3313 fx_4_get_string(parser, gs_so.sodecl));
3314 }
3315 else if (object_type == FX_5_OBJECT_TYPE_GEOMETRY_SHADER)
3316 {
3317 for (unsigned int i = 0; i < ARRAY_SIZE(shader5.sodecl); ++i)
3318 {
3319 if (shader5.sodecl[i])
3320 vkd3d_string_buffer_printf(&parser->buffer, "\n/* Stream output %u declaration: \"%s\" */",
3321 i, fx_4_get_string(parser, shader5.sodecl[i]));
3322 }
3323 if (shader5.sodecl_count)
3324 vkd3d_string_buffer_printf(&parser->buffer, "\n/* Rasterized stream %u */", shader5.rast_stream);
3325 }
3326
3328}
#define NULL
Definition: types.h:112
return ret
Definition: mutex.c:147
static const void * fx_parser_get_unstructured_ptr(struct fx_parser *parser, uint32_t offset, size_t size)
Definition: fx.c:2959
static void parse_fx_print_indent(struct fx_parser *parser)
Definition: fx.c:3019
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLfloat GLfloat p
Definition: glext.h:8902
#define memchr(s, c, n)
Definition: mkisofs.h:875
for(i=0;i< sizeof(testsuite)/sizeof(testsuite[0]);++i) ok(call_test(testsuite[i].func)
@ VKD3D_SHADER_COMPILE_OPTION_API_VERSION
Definition: vkd3d_shader.h:279
VKD3D_SHADER_API void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code)
@ VKD3D_SHADER_SOURCE_DXBC_TPF
@ VKD3D_SHADER_LOG_INFO
@ VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO
Definition: vkd3d_shader.h:68
@ VKD3D_SHADER_API_VERSION_1_14
Definition: vkd3d_shader.h:59
VKD3D_SHADER_API int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, char **messages)
@ VKD3D_SHADER_TARGET_D3D_ASM
@ VKD3D_SHADER_ERROR_FX_INVALID_DATA

Referenced by fx_4_parse_object_initializer().

◆ fx_4_parse_state_object_initializer()

static void fx_4_parse_state_object_initializer ( struct fx_parser *  parser,
uint32_t  count,
enum hlsl_type_class  type_class 
)
static

Definition at line 3361 of file fx.c.

3363{
3364 struct fx_4_assignment
3365 {
3366 uint32_t id;
3367 uint32_t lhs_index;
3368 uint32_t type;
3370 } entry;
3371 struct
3372 {
3373 uint32_t name;
3375 } index;
3376 struct
3377 {
3378 uint32_t type;
3379 union
3380 {
3381 uint32_t u;
3382 float f;
3383 };
3384 } value;
3385 static const char *value_types[FX_COMPONENT_TYPE_COUNT] =
3386 {
3387 [FX_BOOL] = "bool",
3388 [FX_FLOAT] = "float",
3389 [FX_UINT] = "uint",
3390 [FX_UINT8] = "byte",
3391 };
3392 const struct rhs_named_value *named_value;
3393 uint32_t i, j, comp_count;
3394 struct fx_4_state *state;
3395
3396 for (i = 0; i < count; ++i)
3397 {
3399
3402 {
3403 fx_parser_error(parser, VKD3D_SHADER_ERROR_FX_INVALID_DATA, "Unrecognized state id %#x.\n", entry.id);
3404 break;
3405 }
3406
3407 if (state->container != type_class)
3408 {
3410 "State '%s' does not belong to object type class %#x.", state->name, type_class);
3411 break;
3412 }
3413
3415 vkd3d_string_buffer_printf(&parser->buffer, "%s", state->name);
3416 if (state->array_size > 1)
3417 vkd3d_string_buffer_printf(&parser->buffer, "[%u]", entry.lhs_index);
3418 vkd3d_string_buffer_printf(&parser->buffer, " = ");
3419
3420 switch (entry.type)
3421 {
3423
3424 if (value_types[state->type])
3425 vkd3d_string_buffer_printf(&parser->buffer, "%s", value_types[state->type]);
3426 if (state->dimx > 1)
3427 vkd3d_string_buffer_printf(&parser->buffer, "%u", state->dimx);
3428 vkd3d_string_buffer_printf(&parser->buffer, "(");
3429
3430 fx_parser_read_unstructured(parser, &comp_count, entry.value, sizeof(uint32_t));
3431
3432 named_value = NULL;
3433 if (comp_count == 1 && state->values && (state->type == FX_UINT || state->type == FX_BOOL))
3434 {
3435 const struct rhs_named_value *ptr = state->values;
3436
3437 fx_parser_read_unstructured(parser, &value, entry.value + 4, sizeof(value));
3438
3439 while (ptr->name)
3440 {
3441 if (value.u == ptr->value)
3442 {
3443 named_value = ptr;
3444 break;
3445 }
3446 ++ptr;
3447 }
3448 }
3449
3450 if (named_value)
3451 {
3452 vkd3d_string_buffer_printf(&parser->buffer, "%s /* %u */", named_value->name, named_value->value);
3453 }
3454 else
3455 {
3456 uint32_t offset = entry.value + 4;
3457
3458 for (j = 0; j < comp_count; ++j, offset += sizeof(value))
3459 {
3461
3462 if (state->type == FX_UINT8)
3463 vkd3d_string_buffer_printf(&parser->buffer, "0x%.2x", value.u);
3464 else if (state->type == FX_UINT)
3465 vkd3d_string_buffer_printf(&parser->buffer, "%u", value.u);
3466 else if (state->type == FX_FLOAT)
3467 vkd3d_string_buffer_printf(&parser->buffer, "%g", value.f);
3468
3469 if (comp_count > 1 && j < comp_count - 1)
3470 vkd3d_string_buffer_printf(&parser->buffer, ", ");
3471 }
3472 }
3473
3474 vkd3d_string_buffer_printf(&parser->buffer, ")");
3475
3476 break;
3479 break;
3482 vkd3d_string_buffer_printf(&parser->buffer, "%s[%u]", fx_4_get_string(parser, index.name), index.index);
3483 break;
3487 fx_4_get_string(parser, index.index));
3488 break;
3489 default:
3491 "Unsupported assignment type %u.\n", entry.type);
3492 }
3493 vkd3d_string_buffer_printf(&parser->buffer, ";\n");
3494 }
3495}
static int state
Definition: maze.c:121
#define index(s, c)
Definition: various.h:29
static int fx_4_state_id_compare(const void *a, const void *b)
Definition: fx.c:3353
static const struct fx_4_state fx_4_states[]
GLuint index
Definition: glext.h:6031
GLuint id
Definition: glext.h:5910
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
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
#define f
Definition: ke_i.h:83
const char * name
Definition: fx.c:1585
unsigned int value
Definition: fx.c:1586
#define bsearch

Referenced by fx_4_parse_object_initializer(), and fx_parse_fx_4_technique().

◆ fx_4_parse_string_initializer()

static void fx_4_parse_string_initializer ( struct fx_parser *  parser,
uint32_t  offset 
)
static

Definition at line 3057 of file fx.c.

3058{
3059 const char *str = fx_4_get_string(parser, offset);
3060 vkd3d_string_buffer_printf(&parser->buffer, "\"%s\"", str);
3061}
const WCHAR * str

Referenced by fx_4_parse_object_initializer(), and fx_parse_fx_4_annotations().

◆ fx_4_state_id_compare()

static int fx_4_state_id_compare ( const void *  a,
const void *  b 
)
static

Definition at line 3353 of file fx.c.

3354{
3355 const struct fx_4_state *state = b;
3356 int id = *(int *)a;
3357
3358 return id - state->id;
3359}
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define b
Definition: ke_i.h:79

Referenced by fx_4_parse_state_object_initializer().

◆ fx_5_parse()

static int fx_5_parse ( struct fx_parser *  parser)
static

Definition at line 3734 of file fx.c.

3735{
3736 struct fx_5_header
3737 {
3740 uint32_t numeric_variable_count;
3742 uint32_t shared_buffer_count;
3743 uint32_t shared_numeric_variable_count;
3744 uint32_t shared_object_count;
3745 uint32_t technique_count;
3746 uint32_t unstructured_size;
3747 uint32_t string_count;
3748 uint32_t texture_count;
3749 uint32_t depth_stencil_state_count;
3750 uint32_t blend_state_count;
3751 uint32_t rasterizer_state_count;
3752 uint32_t sampler_state_count;
3753 uint32_t rtv_count;
3754 uint32_t dsv_count;
3755 uint32_t shader_count;
3756 uint32_t inline_shader_count;
3757 uint32_t group_count;
3758 uint32_t uav_count;
3759 uint32_t interface_variable_count;
3760 uint32_t interface_variable_element_count;
3761 uint32_t class_instance_element_count;
3762 } header;
3763
3764 parser->version = 11;
3766 parser->buffer_count = header.buffer_count;
3767 parser->object_count = header.object_count;
3768 parser->group_count = header.group_count;
3769
3770 if (parser->end - parser->ptr < header.unstructured_size)
3771 {
3772 parser->failed = true;
3773 return -1;
3774 }
3775
3776 parser->unstructured.ptr = parser->ptr;
3777 parser->unstructured.end = parser->ptr + header.unstructured_size;
3778 parser->unstructured.size = header.unstructured_size;
3779 fx_parser_skip(parser, header.unstructured_size);
3780
3783
3785
3786 return parser->failed ? - 1 : 0;
3787}
static void fx_parse_groups(struct fx_parser *parser)
Definition: fx.c:3650

Referenced by fx_parse().

◆ fx_parse()

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

Definition at line 3789 of file fx.c.

3791{
3792 struct fx_parser parser =
3793 {
3794 .start = compile_info->source.code,
3795 .ptr = compile_info->source.code,
3796 .end = (uint8_t *)compile_info->source.code + compile_info->source.size,
3797 .message_context = message_context,
3798 };
3800 int ret;
3801
3803
3804 if (parser.end - parser.start < sizeof(version))
3805 return -1;
3806 version = *(uint32_t *)parser.ptr;
3807
3808 switch (version)
3809 {
3810 case 0xfeff0901:
3811 ret = fx_2_parse(&parser);
3812 break;
3813 case 0xfeff1001:
3814 case 0xfeff1011:
3815 ret = fx_4_parse(&parser);
3816 break;
3817 case 0xfeff2001:
3818 ret = fx_5_parse(&parser);
3819 break;
3820 default:
3822 "Invalid effect binary version value 0x%08x.", version);
3823 ret = -1;
3824 }
3825
3827
3828 return ret;
3829}
switch(r->id)
Definition: btrfs.c:3046
static int fx_4_parse(struct fx_parser *parser)
Definition: fx.c:3683
static int fx_2_parse(struct fx_parser *parser)
Definition: fx.c:2952
static int fx_5_parse(struct fx_parser *parser)
Definition: fx.c:3734
Definition: fx.c:2886
struct vkd3d_shader_message_context * message_context
Definition: fx.c:2888
const CHAR * start
Definition: inffile.c:87
struct vkd3d_shader_code source
void vkd3d_string_buffer_init(struct vkd3d_string_buffer *buffer)
void vkd3d_shader_code_from_string_buffer(struct vkd3d_shader_code *code, struct vkd3d_string_buffer *buffer)
@ VKD3D_SHADER_ERROR_FX_INVALID_VERSION
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

Referenced by vkd3d_shader_compile().

◆ fx_parse_buffers()

static void fx_parse_buffers ( struct fx_parser *  parser)
static

Definition at line 3180 of file fx.c.

3181{
3182 struct fx_buffer
3183 {
3184 uint32_t name;
3185 uint32_t size;
3188 uint32_t bind_point;
3189 } buffer;
3190 const char *name;
3191 uint32_t i;
3192
3193 if (parser->failed)
3194 return;
3195
3196 for (i = 0; i < parser->buffer_count; ++i)
3197 {
3199
3201
3202 vkd3d_string_buffer_printf(&parser->buffer, "cbuffer %s", name);
3204
3205 vkd3d_string_buffer_printf(&parser->buffer, "\n{\n");
3209 vkd3d_string_buffer_printf(&parser->buffer, "}\n\n");
3210 }
3211}
static void fx_parse_fx_4_numeric_variables(struct fx_parser *parser, uint32_t count)
Definition: fx.c:3136
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLbitfield flags
Definition: glext.h:7161

Referenced by fx_4_parse(), and fx_5_parse().

◆ fx_parse_fx_4_annotations()

static void fx_parse_fx_4_annotations ( struct fx_parser *  parser)
static

Definition at line 3063 of file fx.c.

3064{
3065 struct fx_4_annotation
3066 {
3067 uint32_t name;
3068 uint32_t type;
3069 } var;
3070 struct fx_4_binary_type type;
3071 const char *name, *type_name;
3073
3074 if (parser->failed)
3075 return;
3076
3078
3079 if (!count)
3080 return;
3081
3082 vkd3d_string_buffer_printf(&parser->buffer, "\n");
3084 vkd3d_string_buffer_printf(&parser->buffer, "<\n");
3086
3087 for (i = 0; i < count; ++i)
3088 {
3089 fx_parser_read_u32s(parser, &var, sizeof(var));
3091
3092 name = fx_4_get_string(parser, var.name);
3093 type_name = fx_4_get_string(parser, type.name);
3094
3096 vkd3d_string_buffer_printf(&parser->buffer, "%s %s", type_name, name);
3097 if (type.element_count)
3098 vkd3d_string_buffer_printf(&parser->buffer, "[%u]", type.element_count);
3099 vkd3d_string_buffer_printf(&parser->buffer, " = ");
3100 if (type.element_count)
3101 vkd3d_string_buffer_printf(&parser->buffer, "{ ");
3102
3103 if (type.class == FX_4_TYPE_CLASS_NUMERIC)
3104 {
3107 }
3108 else if (type.class == FX_4_TYPE_CLASS_OBJECT && type.typeinfo == FX_4_OBJECT_TYPE_STRING)
3109 {
3110 uint32_t element_count = max(type.element_count, 1);
3111
3112 for (uint32_t j = 0; j < element_count; ++j)
3113 {
3116 if (j < element_count - 1)
3117 vkd3d_string_buffer_printf(&parser->buffer, ", ");
3118 }
3119 }
3120 else
3121 {
3123 "Only numeric and string types are supported in annotations.\n");
3124 }
3125
3126 if (type.element_count)
3127 vkd3d_string_buffer_printf(&parser->buffer, " }");
3128 vkd3d_string_buffer_printf(&parser->buffer, ";\n");
3129 }
3131
3133 vkd3d_string_buffer_printf(&parser->buffer, ">");
3134}
static void parse_fx_4_numeric_value(struct fx_parser *parser, uint32_t offset, const struct fx_4_binary_type *type)
Definition: fx.c:3024

Referenced by fx_4_parse_objects(), fx_parse_buffers(), fx_parse_fx_4_numeric_variables(), fx_parse_fx_4_technique(), and fx_parse_groups().

◆ fx_parse_fx_4_numeric_variables()

static void fx_parse_fx_4_numeric_variables ( struct fx_parser *  parser,
uint32_t  count 
)
static

Definition at line 3136 of file fx.c.

3137{
3138 struct fx_4_numeric_variable
3139 {
3140 uint32_t name;
3141 uint32_t type;
3142 uint32_t semantic;
3146 } var;
3147 const char *name, *semantic, *type_name;
3148 struct fx_4_binary_type type;
3149 uint32_t i;
3150
3151 for (i = 0; i < count; ++i)
3152 {
3153 fx_parser_read_u32s(parser, &var, sizeof(var));
3155
3156 name = fx_4_get_string(parser, var.name);
3157 type_name = fx_4_get_string(parser, type.name);
3158
3159 vkd3d_string_buffer_printf(&parser->buffer, " %s %s", type_name, name);
3160 if (type.element_count)
3161 vkd3d_string_buffer_printf(&parser->buffer, "[%u]", type.element_count);
3162
3163 if (var.semantic)
3164 {
3165 semantic = fx_4_get_string(parser, var.semantic);
3166 vkd3d_string_buffer_printf(&parser->buffer, " : %s", semantic);
3167 }
3169
3170 if (var.value)
3171 {
3172 vkd3d_string_buffer_printf(&parser->buffer, " = { ");
3174 vkd3d_string_buffer_printf(&parser->buffer, " }");
3175 }
3176 vkd3d_string_buffer_printf(&parser->buffer, "; // Offset: %u, size %u.\n", var.offset, type.unpacked_size);
3177 }
3178}

Referenced by fx_parse_buffers().

◆ fx_parse_fx_4_technique()

static void fx_parse_fx_4_technique ( struct fx_parser *  parser)
static

Definition at line 3592 of file fx.c.

3593{
3594 struct fx_technique
3595 {
3596 uint32_t name;
3598 } technique;
3599 struct fx_pass
3600 {
3601 uint32_t name;
3603 } pass;
3604 const char *name;
3605 uint32_t i;
3606
3607 if (parser->failed)
3608 return;
3609
3610 fx_parser_read_u32s(parser, &technique, sizeof(technique));
3611
3612 name = fx_4_get_string(parser, technique.name);
3613
3615 vkd3d_string_buffer_printf(&parser->buffer, "technique%u %s", parser->version, name);
3617
3618 vkd3d_string_buffer_printf(&parser->buffer, "\n");
3620 vkd3d_string_buffer_printf(&parser->buffer, "{\n");
3621
3623 for (i = 0; i < technique.count; ++i)
3624 {
3625 fx_parser_read_u32s(parser, &pass, sizeof(pass));
3627
3629 vkd3d_string_buffer_printf(&parser->buffer, "pass %s", name);
3631
3632 vkd3d_string_buffer_printf(&parser->buffer, "\n");
3634 vkd3d_string_buffer_printf(&parser->buffer, "{\n");
3635
3639
3641 vkd3d_string_buffer_printf(&parser->buffer, "}\n\n");
3642 }
3643
3645
3647 vkd3d_string_buffer_printf(&parser->buffer, "}\n\n");
3648}
@ HLSL_CLASS_PASS
Definition: hlsl.h:92
pass
Definition: typegen.h:25

Referenced by fx_4_parse(), and fx_parse_groups().

◆ fx_parse_groups()

static void fx_parse_groups ( struct fx_parser *  parser)
static

Definition at line 3650 of file fx.c.

3651{
3652 struct fx_group
3653 {
3654 uint32_t name;
3656 } group;
3657 const char *name;
3658 uint32_t i, j;
3659
3660 if (parser->failed)
3661 return;
3662
3663 for (i = 0; i < parser->group_count; ++i)
3664 {
3666
3668
3669 vkd3d_string_buffer_printf(&parser->buffer, "fxgroup %s", name);
3671
3672 vkd3d_string_buffer_printf(&parser->buffer, "\n{\n");
3674
3675 for (j = 0; j < group.count; ++j)
3677
3679 vkd3d_string_buffer_printf(&parser->buffer, "}\n\n");
3680 }
3681}
GLboolean GLuint group
Definition: glext.h:11120

Referenced by fx_5_parse().

◆ fx_parser_get_unstructured_ptr()

static const void * fx_parser_get_unstructured_ptr ( struct fx_parser *  parser,
uint32_t  offset,
size_t  size 
)
static

Definition at line 2959 of file fx.c.

2960{
2961 const uint8_t *ptr = parser->unstructured.ptr;
2962
2963 if (offset >= parser->unstructured.size
2964 || size > parser->unstructured.size - offset)
2965 {
2966 parser->failed = true;
2967 return NULL;
2968 }
2969
2970 return &ptr[offset];
2971}

Referenced by fx_4_parse_shader_initializer(), and fx_parser_read_unstructured().

◆ fx_parser_read_u32()

static uint32_t fx_parser_read_u32 ( struct fx_parser *  parser)
static

Definition at line 2904 of file fx.c.

2905{
2906 uint32_t ret;
2907
2908 if ((parser->end - parser->ptr) < sizeof(uint32_t))
2909 {
2910 parser->failed = true;
2911 return 0;
2912 }
2913
2914 ret = *(uint32_t *)parser->ptr;
2915 parser->ptr += sizeof(uint32_t);
2916
2917 return ret;
2918}

Referenced by fx_4_parse_object_initializer(), fx_4_parse_shader_initializer(), fx_parse_fx_4_annotations(), and fx_parser_read_u32s().

◆ fx_parser_read_u32s()

static void fx_parser_read_u32s ( struct fx_parser *  parser,
void *  dst,
size_t  size 
)
static

◆ fx_parser_read_unstructured()

static void fx_parser_read_unstructured ( struct fx_parser *  parser,
void *  dst,
uint32_t  offset,
size_t  size 
)
static

Definition at line 2973 of file fx.c.

2974{
2975 const uint8_t *ptr;
2976
2977 memset(dst, 0, size);
2979 return;
2980
2981 memcpy(dst, ptr, size);
2982}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define memset(x, y, z)
Definition: compat.h:39

Referenced by fx_4_parse_objects(), fx_4_parse_shader_initializer(), fx_4_parse_state_object_initializer(), fx_parse_fx_4_annotations(), fx_parse_fx_4_numeric_variables(), and parse_fx_4_numeric_value().

◆ fx_parser_skip()

static void fx_parser_skip ( struct fx_parser *  parser,
size_t  size 
)
static

Definition at line 2929 of file fx.c.

2930{
2931 if ((parser->end - parser->ptr) < size)
2932 {
2933 parser->ptr = parser->end;
2934 parser->failed = true;
2935 return;
2936 }
2937 parser->ptr += size;
2938}

Referenced by fx_4_parse(), and fx_5_parse().

◆ fx_write_context_cleanup()

static int fx_write_context_cleanup ( struct fx_write_context *  fx)
static

Definition at line 381 of file fx.c.

382{
383 struct type_entry *type, *next_type;
384
386
387 LIST_FOR_EACH_ENTRY_SAFE(type, next_type, &fx->types, struct type_entry, entry)
388 {
389 list_remove(&type->entry);
391 }
392
393 return fx->ctx->result;
394}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static void string_storage_destroy(struct rb_entry *entry, void *context)
Definition: fx.c:64
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:242
static void rb_destroy(struct rb_tree *tree, rb_traverse_func_t *callback, void *context)
Definition: rbtree.h:185
Definition: fx.c:48

Referenced by hlsl_fx_2_write(), hlsl_fx_4_write(), and hlsl_fx_5_write().

◆ fx_write_context_init()

static void fx_write_context_init ( struct hlsl_ctx *  ctx,
const struct fx_write_context_ops *  ops,
struct fx_write_context *  fx 
)
static

Definition at line 337 of file fx.c.

339{
340 unsigned int version = ctx->profile->major_version;
341 struct hlsl_ir_var *var;
342
343 memset(fx, 0, sizeof(*fx));
344
345 fx->ctx = ctx;
346 fx->ops = ops;
347 if (version == 2)
348 {
349 fx->min_technique_version = 9;
350 fx->max_technique_version = 9;
351 }
352 else if (version == 4)
353 {
354 fx->min_technique_version = 10;
355 fx->max_technique_version = 10;
356 }
357 else if (version == 5)
358 {
359 fx->min_technique_version = 10;
360 fx->max_technique_version = 11;
361 }
362
364 list_init(&fx->types);
365
366 fx->child_effect = fx->ops->are_child_effects_supported && ctx->child_effect;
367 fx->include_empty_buffers = version == 4 && ctx->include_empty_buffers;
368
369 LIST_FOR_EACH_ENTRY(var, &ctx->globals->vars, struct hlsl_ir_var, scope_entry)
370 {
371 if (var->storage_modifiers & HLSL_STORAGE_UNIFORM)
372 {
373 list_add_tail(&ctx->extern_vars, &var->extern_entry);
374 var->is_uniform = 1;
375 }
376 }
377
379}
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
static int string_storage_compare(const void *key, const struct rb_entry *entry)
Definition: fx.c:56
#define HLSL_STORAGE_UNIFORM
Definition: hlsl.h:403
void hlsl_calculate_buffer_offsets(struct hlsl_ctx *ctx)
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:236
static void rb_init(struct rb_tree *tree, rb_compare_func_t compare)
Definition: rbtree.h:173
struct list scope_entry
Definition: hlsl.h:466

Referenced by hlsl_fx_2_write(), hlsl_fx_4_write(), and hlsl_fx_5_write().

◆ get_fx_2_type_class()

static uint32_t get_fx_2_type_class ( const struct hlsl_type *  type)
static

Definition at line 1004 of file fx.c.

1005{
1006 if (type->class == HLSL_CLASS_MATRIX)
1007 return D3DXPC_MATRIX_ROWS;
1008 return hlsl_sm1_class(type);
1009}
D3DXPARAMETER_CLASS hlsl_sm1_class(const struct hlsl_type *type)
Definition: d3dbc.c:1528
@ D3DXPC_MATRIX_ROWS
Definition: d3dx9shader.h:64
@ HLSL_CLASS_MATRIX
Definition: hlsl.h:85

Referenced by write_fx_2_parameter().

◆ get_fx_4_numeric_type_description()

static uint32_t get_fx_4_numeric_type_description ( const struct hlsl_type *  type,
struct fx_write_context *  fx 
)
static

Definition at line 564 of file fx.c.

565{
566 static const uint32_t numeric_type_class[] =
567 {
571 };
572 struct hlsl_ctx *ctx = fx->ctx;
573 uint32_t value = 0;
574
575 switch (type->class)
576 {
580 value |= numeric_type_class[type->class];
581 break;
582 default:
583 hlsl_fixme(ctx, &ctx->location, "Not implemented for type class %u.", type->class);
584 return 0;
585 }
586
587 switch (type->e.numeric.type)
588 {
589 case HLSL_TYPE_FLOAT:
590 case HLSL_TYPE_HALF:
591 case HLSL_TYPE_INT:
592 case HLSL_TYPE_UINT:
593 case HLSL_TYPE_BOOL:
595 break;
596 default:
597 hlsl_fixme(ctx, &ctx->location, "Not implemented for base type %u.", type->e.numeric.type);
598 return 0;
599 }
600
601 value |= (type->dimy & 0x7) << FX_4_NUMERIC_ROWS_SHIFT;
602 value |= (type->dimx & 0x7) << FX_4_NUMERIC_COLUMNS_SHIFT;
603 if (type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR)
605
606 return value;
607}
static const uint32_t fx_4_numeric_base_types[]
Definition: fx.c:555
void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, const char *fmt,...)
Definition: hlsl.c:58
@ HLSL_CLASS_VECTOR
Definition: hlsl.h:84
@ HLSL_CLASS_SCALAR
Definition: hlsl.h:83
@ HLSL_TYPE_HALF
Definition: hlsl.h:116
@ HLSL_TYPE_BOOL
Definition: hlsl.h:120
@ HLSL_TYPE_UINT
Definition: hlsl.h:119
@ HLSL_TYPE_INT
Definition: hlsl.h:118
@ HLSL_TYPE_FLOAT
Definition: hlsl.h:115
#define HLSL_MODIFIER_COLUMN_MAJOR
Definition: hlsl.h:407

Referenced by write_fx_4_type().

◆ get_fx_4_state_enum_value()

static bool get_fx_4_state_enum_value ( const struct rhs_named_value *  pairs,
const char *  name,
unsigned int *  value 
)
static

Definition at line 1589 of file fx.c.

1591{
1592 while (pairs->name)
1593 {
1594 if (!ascii_strcasecmp(pairs->name, name))
1595 {
1596 *value = pairs->value;
1597 return true;
1598 }
1599
1600 pairs++;
1601 }
1602
1603 return false;
1604}

Referenced by replace_state_block_constant().

◆ get_fx_4_type_name()

static const char * get_fx_4_type_name ( const struct hlsl_type *  type)
static

Definition at line 609 of file fx.c.

610{
611 static const char * const texture_type_names[] =
612 {
613 [HLSL_SAMPLER_DIM_GENERIC] = "texture",
614 [HLSL_SAMPLER_DIM_1D] = "Texture1D",
615 [HLSL_SAMPLER_DIM_1DARRAY] = "Texture1DArray",
616 [HLSL_SAMPLER_DIM_2D] = "Texture2D",
617 [HLSL_SAMPLER_DIM_2DARRAY] = "Texture2DArray",
618 [HLSL_SAMPLER_DIM_2DMS] = "Texture2DMS",
619 [HLSL_SAMPLER_DIM_2DMSARRAY] = "Texture2DMSArray",
620 [HLSL_SAMPLER_DIM_3D] = "Texture3D",
621 [HLSL_SAMPLER_DIM_CUBE] = "TextureCube",
622 [HLSL_SAMPLER_DIM_CUBEARRAY] = "TextureCubeArray",
623 };
624 static const char * const uav_type_names[] =
625 {
626 [HLSL_SAMPLER_DIM_1D] = "RWTexture1D",
627 [HLSL_SAMPLER_DIM_1DARRAY] = "RWTexture1DArray",
628 [HLSL_SAMPLER_DIM_2D] = "RWTexture2D",
629 [HLSL_SAMPLER_DIM_2DARRAY] = "RWTexture2DArray",
630 [HLSL_SAMPLER_DIM_3D] = "RWTexture3D",
631 [HLSL_SAMPLER_DIM_BUFFER] = "RWBuffer",
632 [HLSL_SAMPLER_DIM_STRUCTURED_BUFFER] = "RWStructuredBuffer",
633 [HLSL_SAMPLER_DIM_RAW_BUFFER] = "RWByteAddressBuffer",
634 };
635
636 switch (type->class)
637 {
639 return "SamplerState";
640
642 return texture_type_names[type->sampler_dim];
643
644 case HLSL_CLASS_UAV:
645 return uav_type_names[type->sampler_dim];
646
648 return "DepthStencilState";
649
651 return "DepthStencilView";
652
654 return "RenderTargetView";
655
657 return "VertexShader";
658
660 return "GeometryShader";
661
663 return "PixelShader";
664
666 return "String";
667
671 if (type->e.numeric.type == HLSL_TYPE_HALF)
672 return "float";
673 /* fall-through */
674 default:
675 return type->name;
676 }
677}
@ HLSL_CLASS_RENDER_TARGET_VIEW
Definition: hlsl.h:95
@ HLSL_CLASS_VERTEX_SHADER
Definition: hlsl.h:101
@ HLSL_CLASS_GEOMETRY_SHADER
Definition: hlsl.h:105
@ HLSL_CLASS_UAV
Definition: hlsl.h:100
@ HLSL_CLASS_TEXTURE
Definition: hlsl.h:99
@ HLSL_CLASS_DEPTH_STENCIL_VIEW
Definition: hlsl.h:90
@ HLSL_CLASS_PIXEL_SHADER
Definition: hlsl.h:93
@ HLSL_CLASS_STRING
Definition: hlsl.h:97
@ HLSL_SAMPLER_DIM_GENERIC
Definition: hlsl.h:126
@ HLSL_SAMPLER_DIM_1DARRAY
Definition: hlsl.h:133
@ HLSL_SAMPLER_DIM_CUBEARRAY
Definition: hlsl.h:137
@ HLSL_SAMPLER_DIM_2DMSARRAY
Definition: hlsl.h:136
@ HLSL_SAMPLER_DIM_BUFFER
Definition: hlsl.h:138
@ HLSL_SAMPLER_DIM_2DMS
Definition: hlsl.h:135
@ HLSL_SAMPLER_DIM_2DARRAY
Definition: hlsl.h:134
@ HLSL_SAMPLER_DIM_CUBE
Definition: hlsl.h:131
@ HLSL_SAMPLER_DIM_3D
Definition: hlsl.h:130
@ HLSL_SAMPLER_DIM_2D
Definition: hlsl.h:129
@ HLSL_SAMPLER_DIM_RAW_BUFFER
Definition: hlsl.h:140
@ HLSL_SAMPLER_DIM_STRUCTURED_BUFFER
Definition: hlsl.h:139
@ HLSL_SAMPLER_DIM_1D
Definition: hlsl.h:128

Referenced by write_fx_4_type(), and write_type().

◆ get_fx_4_type_size()

static uint32_t get_fx_4_type_size ( const struct hlsl_type *  type)
static

Definition at line 474 of file fx.c.

475{
476 uint32_t elements_count;
477
478 elements_count = hlsl_get_multiarray_size(type);
480
481 return type->reg_size[HLSL_REGSET_NUMERIC] * sizeof(float) * elements_count;
482}
unsigned int hlsl_get_multiarray_size(const struct hlsl_type *type)
Definition: hlsl.c:233
@ HLSL_REGSET_NUMERIC
Definition: hlsl.h:151
static float(__cdecl *square_half_float)(float x

Referenced by write_fx_4_buffer().

◆ get_state_block_function_components()

static void get_state_block_function_components ( const struct state_block_function_info *  info,
struct function_component *  components,
unsigned int  comp_count 
)
static

Definition at line 121 of file fx.c.

123{
124 unsigned int i;
125
126 VKD3D_ASSERT(comp_count <= info->max_args);
127
128 if (info->min_args == info->max_args)
129 {
130 const struct function_component *c = info->components;
131 for (i = 0; i < comp_count; ++i, ++c)
132 add_function_component(&components, c->name, c->lhs_has_index, c->lhs_index);
133 return;
134 }
135
136 if (!strcmp(info->name, "OMSetRenderTargets"))
137 {
138 for (i = 0; i < comp_count - 2; ++i)
139 add_function_component(&components, "RenderTargetView", true, i + 1);
140 add_function_component(&components, "DepthStencilView", false, 0);
141 add_function_component(&components, "RenderTargetView", true, 0);
142 }
143}
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
static void add_function_component(struct function_component **components, const char *name, bool lhs_has_index, unsigned int lhs_index)
Definition: fx.c:109
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
int max_args
Definition: vfdcmd.c:86
#define VKD3D_ASSERT(cond)
Definition: vkd3d_common.h:49

Referenced by decompose_fx_4_state_function_call().

◆ get_state_block_function_info()

static const struct state_block_function_info * get_state_block_function_info ( const char *  name)
static

Definition at line 99 of file fx.c.

100{
101 for (unsigned int i = 0; i < ARRAY_SIZE(function_info); ++i)
102 {
104 return &function_info[i];
105 }
106 return NULL;
107}

Referenced by decompose_fx_4_state_function_call(), and hlsl_validate_state_block_entry().

◆ hlsl_emit_effect_binary()

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

Definition at line 2865 of file fx.c.

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

Referenced by hlsl_compile_shader().

◆ hlsl_fx_2_write()

static int hlsl_fx_2_write ( struct hlsl_ctx *  ctx,
struct vkd3d_shader_code *  out 
)
static

Definition at line 1362 of file fx.c.

1363{
1364 uint32_t offset, size, technique_count, shader_count, parameter_count, object_count;
1365 struct vkd3d_bytecode_buffer buffer = { 0 };
1366 struct vkd3d_bytecode_buffer *structured;
1367 struct fx_write_context fx;
1368
1370 fx.object_variable_count = 1;
1371 structured = &fx.structured;
1372
1373 /* First entry is always zeroed and skipped. */
1374 put_u32(&fx.unstructured, 0);
1375
1376 put_u32(&buffer, 0xfeff0901); /* Version. */
1377 offset = put_u32(&buffer, 0);
1378
1379 parameter_count = put_u32(structured, 0); /* Parameter count */
1383
1385 write_techniques(ctx->globals, &fx);
1386 put_u32(structured, fx.object_variable_count - 1);
1387 put_u32(structured, 0); /* Resource count */
1388
1389 bytecode_put_bytes(structured, fx.objects.data, fx.objects.size);
1390 /* TODO: resources */
1391
1392 set_u32(structured, parameter_count, fx.parameter_count);
1393 set_u32(structured, object_count, fx.object_variable_count);
1394 set_u32(structured, technique_count, fx.technique_count);
1395 set_u32(structured, shader_count, fx.shader_count);
1396
1397 size = align(fx.unstructured.size, 4);
1399
1400 bytecode_put_bytes(&buffer, fx.unstructured.data, fx.unstructured.size);
1401 bytecode_put_bytes(&buffer, fx.structured.data, fx.structured.size);
1402
1403 vkd3d_free(fx.unstructured.data);
1404 vkd3d_free(fx.structured.data);
1405 vkd3d_free(fx.objects.data);
1406
1407 if (!fx.technique_count)
1408 hlsl_error(ctx, &ctx->location, VKD3D_SHADER_ERROR_HLSL_MISSING_TECHNIQUE, "No techniques found.");
1409
1410 if (fx.status < 0)
1411 ctx->result = fx.status;
1412
1413 if (!ctx->result)
1414 {
1415 out->code = buffer.data;
1416 out->size = buffer.size;
1417 }
1418
1420}
static void put_u32(struct bytecode_buffer *buffer, uint32_t value)
static void write_fx_2_parameters(struct fx_write_context *fx)
Definition: fx.c:1308
static void write_techniques(struct hlsl_scope *scope, struct fx_write_context *fx)
Definition: fx.c:928
static void fx_write_context_init(struct hlsl_ctx *ctx, const struct fx_write_context_ops *ops, struct fx_write_context *fx)
Definition: fx.c:337
static const struct fx_write_context_ops fx_2_ops
Definition: fx.c:1354
static int fx_write_context_cleanup(struct fx_write_context *fx)
Definition: fx.c:381
uint32_t parameter_count
Definition: fx.c:213
uint32_t technique_count
Definition: fx.c:204
uint32_t shader_count
Definition: fx.c:212
struct vkd3d_bytecode_buffer structured
Definition: fx.c:195
void set_u32(struct vkd3d_bytecode_buffer *buffer, size_t offset, uint32_t value)
size_t bytecode_put_bytes(struct vkd3d_bytecode_buffer *buffer, const void *bytes, size_t size)
@ VKD3D_SHADER_ERROR_HLSL_MISSING_TECHNIQUE
static size_t align(size_t addr, size_t alignment)

Referenced by hlsl_emit_effect_binary().

◆ hlsl_fx_4_write()

static int hlsl_fx_4_write ( struct hlsl_ctx *  ctx,
struct vkd3d_shader_code *  out 
)
static

Definition at line 2743 of file fx.c.

2744{
2745 struct vkd3d_bytecode_buffer buffer = { 0 };
2746 struct fx_write_context fx;
2747 uint32_t size_offset;
2748
2750
2751 put_u32(&fx.unstructured, 0); /* Empty string placeholder. */
2752
2753 write_buffers(&fx, false);
2754 write_objects(&fx, false);
2755 write_buffers(&fx, true);
2756 write_objects(&fx, true);
2757
2758 write_techniques(ctx->globals, &fx);
2759
2760 put_u32(&buffer, ctx->profile->minor_version == 0 ? 0xfeff1001 : 0xfeff1011); /* Version. */
2761 put_u32(&buffer, fx.buffer_count); /* Buffer count. */
2762 put_u32(&buffer, fx.numeric_variable_count); /* Numeric variable count. */
2763 put_u32(&buffer, fx.object_variable_count); /* Object variable count. */
2764 put_u32(&buffer, fx.shared_buffer_count);
2765 put_u32(&buffer, fx.shared_numeric_variable_count);
2766 put_u32(&buffer, fx.shared_object_count);
2767 put_u32(&buffer, fx.technique_count);
2768 size_offset = put_u32(&buffer, 0); /* Unstructured size. */
2769 put_u32(&buffer, fx.string_count);
2770 put_u32(&buffer, fx.texture_count);
2771 put_u32(&buffer, fx.depth_stencil_state_count);
2772 put_u32(&buffer, fx.blend_state_count);
2773 put_u32(&buffer, fx.rasterizer_state_count);
2774 put_u32(&buffer, fx.sampler_state_count);
2775 put_u32(&buffer, fx.rtv_count);
2776 put_u32(&buffer, fx.dsv_count);
2777 put_u32(&buffer, fx.shader_count);
2778 put_u32(&buffer, 0); /* Inline shader count. */
2779
2780 set_u32(&buffer, size_offset, fx.unstructured.size);
2781
2782 bytecode_put_bytes(&buffer, fx.unstructured.data, fx.unstructured.size);
2783 bytecode_put_bytes_unaligned(&buffer, fx.structured.data, fx.structured.size);
2784
2785 vkd3d_free(fx.unstructured.data);
2786 vkd3d_free(fx.structured.data);
2787
2788 set_status(&fx, buffer.status);
2789
2790 if (fx.status < 0)
2791 ctx->result = fx.status;
2792
2793 if (!ctx->result)
2794 {
2795 out->code = buffer.data;
2796 out->size = buffer.size;
2797 }
2798
2800}
static void set_status(struct fx_write_context *fx, int status)
Definition: fx.c:231
static void write_objects(struct fx_write_context *fx, bool shared)
Definition: fx.c:2723
static const struct fx_write_context_ops fx_4_ops
Definition: fx.c:1422
static void write_buffers(struct fx_write_context *fx, bool shared)
Definition: fx.c:2668
size_t bytecode_put_bytes_unaligned(struct vkd3d_bytecode_buffer *buffer, const void *bytes, size_t size)

Referenced by hlsl_emit_effect_binary().

◆ hlsl_fx_5_write()

static int hlsl_fx_5_write ( struct hlsl_ctx *  ctx,
struct vkd3d_shader_code *  out 
)
static

Definition at line 2802 of file fx.c.

2803{
2804 struct vkd3d_bytecode_buffer buffer = { 0 };
2805 struct fx_write_context fx;
2806 uint32_t size_offset;
2807
2809
2810 put_u32(&fx.unstructured, 0); /* Empty string placeholder. */
2811
2812 write_buffers(&fx, false);
2813 write_objects(&fx, false);
2814 /* TODO: interface variables */
2815
2816 write_groups(&fx);
2817
2818 put_u32(&buffer, 0xfeff2001); /* Version. */
2819 put_u32(&buffer, fx.buffer_count); /* Buffer count. */
2820 put_u32(&buffer, fx.numeric_variable_count); /* Numeric variable count. */
2821 put_u32(&buffer, fx.object_variable_count); /* Object variable count. */
2822 put_u32(&buffer, fx.shared_buffer_count);
2823 put_u32(&buffer, fx.shared_numeric_variable_count);
2824 put_u32(&buffer, fx.shared_object_count);
2825 put_u32(&buffer, fx.technique_count);
2826 size_offset = put_u32(&buffer, 0); /* Unstructured size. */
2827 put_u32(&buffer, fx.string_count);
2828 put_u32(&buffer, fx.texture_count);
2829 put_u32(&buffer, fx.depth_stencil_state_count);
2830 put_u32(&buffer, fx.blend_state_count);
2831 put_u32(&buffer, fx.rasterizer_state_count);
2832 put_u32(&buffer, fx.sampler_state_count);
2833 put_u32(&buffer, fx.rtv_count);
2834 put_u32(&buffer, fx.dsv_count);
2835 put_u32(&buffer, fx.shader_count);
2836 put_u32(&buffer, 0); /* Inline shader count. */
2837 put_u32(&buffer, fx.group_count); /* Group count. */
2838 put_u32(&buffer, fx.uav_count);
2839 put_u32(&buffer, 0); /* Interface variables count. */
2840 put_u32(&buffer, 0); /* Interface variable element count. */
2841 put_u32(&buffer, 0); /* Class instance elements count. */
2842
2843 set_u32(&buffer, size_offset, fx.unstructured.size);
2844
2845 bytecode_put_bytes(&buffer, fx.unstructured.data, fx.unstructured.size);
2846 bytecode_put_bytes_unaligned(&buffer, fx.structured.data, fx.structured.size);
2847
2848 vkd3d_free(fx.unstructured.data);
2849 vkd3d_free(fx.structured.data);
2850
2851 set_status(&fx, buffer.status);
2852
2853 if (fx.status < 0)
2854 ctx->result = fx.status;
2855
2856 if (!ctx->result)
2857 {
2858 out->code = buffer.data;
2859 out->size = buffer.size;
2860 }
2861
2863}
static void write_groups(struct fx_write_context *fx)
Definition: fx.c:962

Referenced by hlsl_emit_effect_binary().

◆ hlsl_type_class_from_fx_type()

static enum hlsl_type_class hlsl_type_class_from_fx_type ( enum state_property_component_type  type)
inlinestatic

Definition at line 1861 of file fx.c.

1862{
1863 switch (type)
1864 {
1865 case FX_DEPTHSTENCIL:
1867 case FX_RASTERIZER:
1869 case FX_DOMAINSHADER:
1871 case FX_HULLSHADER:
1873 case FX_COMPUTESHADER:
1875 case FX_TEXTURE:
1876 return HLSL_CLASS_TEXTURE;
1881 case FX_BLEND:
1883 case FX_VERTEXSHADER:
1885 case FX_PIXELSHADER:
1887 default:
1889 }
1890}
@ HLSL_CLASS_COMPUTE_SHADER
Definition: hlsl.h:102
@ HLSL_CLASS_HULL_SHADER
Definition: hlsl.h:104
@ HLSL_CLASS_DOMAIN_SHADER
Definition: hlsl.h:103

Referenced by resolve_fx_4_state_block_values().

◆ hlsl_type_from_fx_type()

static enum hlsl_base_type hlsl_type_from_fx_type ( enum state_property_component_type  type)
inlinestatic

Definition at line 1892 of file fx.c.

1893{
1894 switch (type)
1895 {
1896 case FX_BOOL:
1897 return HLSL_TYPE_BOOL;
1898 case FX_FLOAT:
1899 return HLSL_TYPE_FLOAT;
1900 case FX_UINT:
1901 case FX_UINT8:
1902 return HLSL_TYPE_UINT;
1903 default:
1905 }
1906}

Referenced by resolve_fx_4_state_block_values().

◆ hlsl_validate_state_block_entry()

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

Definition at line 145 of file fx.c.

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

◆ is_numeric_fx_4_type()

static bool is_numeric_fx_4_type ( const struct hlsl_type *  type)
static

Definition at line 679 of file fx.c.

680{
682 return type->class == HLSL_CLASS_STRUCT || hlsl_is_numeric_type(type);
683}
@ HLSL_CLASS_STRUCT
Definition: hlsl.h:87
static bool hlsl_is_numeric_type(const struct hlsl_type *type)
Definition: hlsl.h:1388

Referenced by write_fx_4_buffer(), and write_fx_4_type().

◆ is_object_fx_type()

static bool is_object_fx_type ( enum state_property_component_type  type)
inlinestatic

Definition at line 1840 of file fx.c.

1841{
1842 switch (type)
1843 {
1844 case FX_DEPTHSTENCIL:
1845 case FX_RASTERIZER:
1846 case FX_DOMAINSHADER:
1847 case FX_HULLSHADER:
1848 case FX_COMPUTESHADER:
1849 case FX_TEXTURE:
1852 case FX_BLEND:
1853 case FX_VERTEXSHADER:
1854 case FX_PIXELSHADER:
1855 return true;
1856 default:
1857 return false;
1858 }
1859}

Referenced by resolve_fx_4_state_block_values().

◆ is_supported_object_variable()

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

Definition at line 2688 of file fx.c.

2689{
2690 const struct hlsl_type *type = hlsl_get_multiarray_element_type(var->data_type);
2691
2692 switch (type->class)
2693 {
2699 case HLSL_CLASS_SAMPLER:
2700 case HLSL_CLASS_TEXTURE:
2703 case HLSL_CLASS_STRING:
2704 return true;
2708 if (ctx->profile->major_version < 5)
2709 return false;
2710 return true;
2711 case HLSL_CLASS_UAV:
2712 if (ctx->profile->major_version < 5)
2713 return false;
2714 if (type->e.resource.rasteriser_ordered)
2715 return false;
2716 return true;
2717
2718 default:
2719 return false;
2720 }
2721}

Referenced by write_objects().

◆ is_type_supported_fx_2()

static bool is_type_supported_fx_2 ( struct hlsl_ctx *  ctx,
const struct hlsl_type *  type,
const struct vkd3d_shader_location *  loc 
)
static

Definition at line 1241 of file fx.c.

1243{
1244 switch (type->class)
1245 {
1246 case HLSL_CLASS_STRUCT:
1247 /* Note that the fields must all be numeric; this was validated in
1248 * check_invalid_object_fields(). */
1249 return true;
1250
1251 case HLSL_CLASS_SCALAR:
1252 case HLSL_CLASS_VECTOR:
1253 case HLSL_CLASS_MATRIX:
1254 return true;
1255
1256 case HLSL_CLASS_ARRAY:
1257 return is_type_supported_fx_2(ctx, type->e.array.type, loc);
1258
1259 case HLSL_CLASS_TEXTURE:
1260 case HLSL_CLASS_SAMPLER:
1261 switch (type->sampler_dim)
1262 {
1268 return true;
1269 default:
1270 return false;
1271 }
1272 break;
1273
1274 case HLSL_CLASS_STRING:
1275 return true;
1276
1279 hlsl_fixme(ctx, loc, "Write fx 2.0 parameter class %#x.", type->class);
1280 return false;
1281
1284 case HLSL_CLASS_UAV:
1287 case HLSL_CLASS_VOID:
1293 return false;
1294
1296 case HLSL_CLASS_ERROR:
1297 case HLSL_CLASS_PASS:
1300 case HLSL_CLASS_NULL:
1301 /* This cannot appear as an extern variable. */
1302 break;
1303 }
1304
1306}
static bool is_type_supported_fx_2(struct hlsl_ctx *ctx, const struct hlsl_type *type, const struct vkd3d_shader_location *loc)
Definition: fx.c:1241
@ HLSL_CLASS_TECHNIQUE
Definition: hlsl.h:98
@ HLSL_CLASS_CONSTANT_BUFFER
Definition: hlsl.h:106
@ HLSL_CLASS_VOID
Definition: hlsl.h:108
@ HLSL_CLASS_EFFECT_GROUP
Definition: hlsl.h:91
@ HLSL_CLASS_NULL
Definition: hlsl.h:109
@ HLSL_CLASS_ARRAY
Definition: hlsl.h:88
@ HLSL_CLASS_ERROR
Definition: hlsl.h:110

Referenced by is_type_supported_fx_2(), and write_fx_2_parameters().

◆ lower_null_constant()

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

Definition at line 1773 of file fx.c.

1774{
1775 struct hlsl_ir_node *c;
1776
1777 if (instr->type != HLSL_IR_CONSTANT)
1778 return false;
1779 if (instr->data_type->class != HLSL_CLASS_NULL)
1780 return false;
1781
1782 if (!(c = hlsl_new_uint_constant(ctx, 0, &instr->loc)))
1783 return false;
1784
1785 list_add_before(&instr->entry, &c->entry);
1786 hlsl_replace_node(instr, c);
1787
1788 return true;
1789}
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
void hlsl_replace_node(struct hlsl_ir_node *old, struct hlsl_ir_node *new)
Definition: hlsl.c:3626
@ HLSL_IR_CONSTANT
Definition: hlsl.h:316
__WINE_SERVER_LIST_INLINE void list_add_before(struct list *elem, struct list *to_add)
Definition: list.h:89
struct list entry
Definition: hlsl.h:341
enum hlsl_ir_node_type type
Definition: hlsl.h:345
struct hlsl_type * data_type
Definition: hlsl.h:349
struct vkd3d_shader_location loc
Definition: hlsl.h:355

Referenced by resolve_fx_4_state_block_values().

◆ parse_fx_4_numeric_value()

static void parse_fx_4_numeric_value ( struct fx_parser *  parser,
uint32_t  offset,
const struct fx_4_binary_type *  type 
)
static

Definition at line 3024 of file fx.c.

3026{
3027 unsigned int base_type, comp_count;
3028 size_t i;
3029
3030 base_type = (type->typeinfo >> FX_4_NUMERIC_BASE_TYPE_SHIFT) & 0xf;
3031
3032 comp_count = type->packed_size / sizeof(uint32_t);
3033 for (i = 0; i < comp_count; ++i)
3034 {
3036
3038
3039 if (base_type == FX_4_NUMERIC_TYPE_FLOAT)
3040 vkd3d_string_buffer_printf(&parser->buffer, "%f", value.f);
3041 else if (base_type == FX_4_NUMERIC_TYPE_INT)
3042 vkd3d_string_buffer_printf(&parser->buffer, "%d", value.i);
3043 else if (base_type == FX_4_NUMERIC_TYPE_UINT)
3044 vkd3d_string_buffer_printf(&parser->buffer, "%u", value.u);
3045 else if (base_type == FX_4_NUMERIC_TYPE_BOOL)
3046 vkd3d_string_buffer_printf(&parser->buffer, "%s", value.u ? "true" : "false" );
3047 else
3048 vkd3d_string_buffer_printf(&parser->buffer, "%#x", value.u);
3049
3050 if (i < comp_count - 1)
3051 vkd3d_string_buffer_printf(&parser->buffer, ", ");
3052
3053 offset += sizeof(uint32_t);
3054 }
3055}

Referenced by fx_parse_fx_4_annotations(), and fx_parse_fx_4_numeric_variables().

◆ parse_fx_end_indent()

static void parse_fx_end_indent ( struct fx_parser *  parser)
static

◆ parse_fx_print_indent()

static void parse_fx_print_indent ( struct fx_parser *  parser)
static

Definition at line 3019 of file fx.c.

3020{
3021 vkd3d_string_buffer_printf(&parser->buffer, "%*s", 4 * parser->indent, "");
3022}

Referenced by fx_4_parse_shader_initializer(), fx_4_parse_state_object_initializer(), fx_parse_fx_4_annotations(), and fx_parse_fx_4_technique().

◆ parse_fx_start_indent()

static void parse_fx_start_indent ( struct fx_parser *  parser)
static

◆ put_u32_unaligned()

static size_t put_u32_unaligned ( struct vkd3d_bytecode_buffer *  buffer,
uint32_t  value 
)
inlinestatic

Definition at line 23 of file fx.c.

24{
26}

Referenced by write_fx_4_default_value(), write_fx_4_state_numeric_value(), and write_fx_4_type().

◆ replace_state_block_constant()

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

Definition at line 1791 of file fx.c.

1792{
1793 struct replace_state_context *replace_context = context;
1794 struct hlsl_ir_stateblock_constant *state_constant;
1795 struct hlsl_ir_node *c;
1796 unsigned int value;
1797
1798 if (!replace_context->values)
1799 return false;
1800 if (instr->type != HLSL_IR_STATEBLOCK_CONSTANT)
1801 return false;
1802
1803 state_constant = hlsl_ir_stateblock_constant(instr);
1804 if (!get_fx_4_state_enum_value(replace_context->values, state_constant->name, &value))
1805 {
1807 "Unrecognized state constant %s.", state_constant->name);
1808 return false;
1809 }
1810
1811 if (!(c = hlsl_new_uint_constant(ctx, value, &replace_context->var->loc)))
1812 return false;
1813
1814 list_add_before(&state_constant->node.entry, &c->entry);
1815 hlsl_replace_node(&state_constant->node, c);
1816
1817 return true;
1818}
static bool get_fx_4_state_enum_value(const struct rhs_named_value *pairs, const char *name, unsigned int *value)
Definition: fx.c:1589
@ HLSL_IR_STATEBLOCK_CONSTANT
Definition: hlsl.h:332
Definition: http.c:7252
struct hlsl_ir_node node
Definition: hlsl.h:933
struct hlsl_ir_var * var
Definition: fx.c:1770
const struct rhs_named_value * values
Definition: fx.c:1769
@ VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX

Referenced by resolve_fx_4_state_block_values().

◆ resolve_fx_4_state_block_values()

static void resolve_fx_4_state_block_values ( struct hlsl_ir_var *  var,
struct hlsl_state_block_entry *  entry,
struct fx_write_context *  fx 
)
static

Definition at line 2125 of file fx.c.

2127{
2128 static const struct fx_4_state fx_5_blend_states[] =
2129 {
2130 { "AlphaToCoverageEnable", HLSL_CLASS_BLEND_STATE, HLSL_CLASS_SCALAR, FX_BOOL, 1, 1, 36, bool_values },
2131 { "BlendEnable", HLSL_CLASS_BLEND_STATE, HLSL_CLASS_SCALAR, FX_BOOL, 1, 8, 37, bool_values },
2132 { "SrcBlend", HLSL_CLASS_BLEND_STATE, HLSL_CLASS_SCALAR, FX_UINT, 1, 8, 38, blend_values },
2133 { "DestBlend", HLSL_CLASS_BLEND_STATE, HLSL_CLASS_SCALAR, FX_UINT, 1, 8, 39, blend_values },
2135 { "SrcBlendAlpha", HLSL_CLASS_BLEND_STATE, HLSL_CLASS_SCALAR, FX_UINT, 1, 8, 41, blend_values },
2136 { "DestBlendAlpha", HLSL_CLASS_BLEND_STATE, HLSL_CLASS_SCALAR, FX_UINT, 1, 8, 42, blend_values },
2137 { "BlendOpAlpha", HLSL_CLASS_BLEND_STATE, HLSL_CLASS_SCALAR, FX_UINT, 1, 8, 43, blendop_values },
2138 { "RenderTargetWriteMask", HLSL_CLASS_BLEND_STATE, HLSL_CLASS_SCALAR, FX_UINT8, 1, 8, 44 },
2139 };
2140
2141 struct state_table
2142 {
2143 const struct fx_4_state *ptr;
2144 unsigned int count;
2145 } table;
2146
2147 const struct hlsl_type *type = hlsl_get_multiarray_element_type(var->data_type);
2148 struct replace_state_context replace_context;
2149 const struct fx_4_state *state = NULL;
2150 struct hlsl_type *state_type = NULL;
2151 struct hlsl_ir_node *node, *cast;
2152 struct hlsl_ctx *ctx = fx->ctx;
2153 enum hlsl_base_type base_type;
2154 unsigned int i;
2155
2156 if (type->class == HLSL_CLASS_BLEND_STATE && ctx->profile->major_version == 5)
2157 {
2158 table.ptr = fx_5_blend_states;
2159 table.count = ARRAY_SIZE(fx_5_blend_states);
2160 }
2161 else
2162 {
2163 table.ptr = fx_4_states;
2164 table.count = ARRAY_SIZE(fx_4_states);
2165 }
2166
2167 for (i = 0; i < table.count; ++i)
2168 {
2169 if (type->class == table.ptr[i].container
2170 && !ascii_strcasecmp(entry->name, table.ptr[i].name))
2171 {
2172 state = &table.ptr[i];
2173 break;
2174 }
2175 }
2176
2177 if (!state)
2178 {
2179 hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Unrecognized state name %s.", entry->name);
2180 return;
2181 }
2182
2183 if (entry->args_count != 1)
2184 {
2185 hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Unrecognized initializer for the state %s.",
2186 entry->name);
2187 return;
2188 }
2189
2190 if (entry->lhs_has_index && state->array_size == 1)
2191 {
2192 hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Can't use array-style access for non-array state %s.",
2193 entry->name);
2194 return;
2195 }
2196
2197 if (!entry->lhs_has_index && state->array_size > 1)
2198 {
2199 hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Expected array index for array state %s.",
2200 entry->name);
2201 return;
2202 }
2203
2204 if (entry->lhs_has_index && (state->array_size <= entry->lhs_index))
2205 {
2206 hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid element index %u for the state %s[%u].",
2207 entry->lhs_index, state->name, state->array_size);
2208 return;
2209 }
2210
2211 entry->name_id = state->id;
2212
2213 replace_context.values = state->values;
2214 replace_context.var = var;
2215
2216 /* Turn named constants to actual constants. */
2218 hlsl_transform_ir(ctx, replace_state_block_constant, entry->instrs, &replace_context);
2220
2221 /* Now cast and run folding again. */
2222
2223 if (is_object_fx_type(state->type))
2224 {
2225 node = entry->args->node;
2226
2227 switch (node->type)
2228 {
2229 case HLSL_IR_LOAD:
2230 {
2232
2233 if (load->src.path_len)
2234 hlsl_fixme(ctx, &ctx->location, "Arrays are not supported for RHS.");
2235
2236 if (load->src.var->data_type->class != hlsl_type_class_from_fx_type(state->type))
2237 {
2238 hlsl_error(ctx, &ctx->location, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Type mismatch for the %s state value",
2239 entry->name);
2240 }
2241
2242 break;
2243 }
2244 case HLSL_IR_CONSTANT:
2245 {
2247 struct hlsl_type *data_type = c->node.data_type;
2248
2249 if (data_type->class == HLSL_CLASS_SCALAR && data_type->e.numeric.type == HLSL_TYPE_UINT)
2250 {
2251 if (c->value.u[0].u != 0)
2253 "Only 0 integer constants are allowed for object-typed fields.");
2254 }
2255 else
2256 {
2258 "Unexpected constant used for object-typed field.");
2259 }
2260
2261 break;
2262 }
2263 default:
2264 hlsl_fixme(ctx, &ctx->location, "Unhandled node type for object-typed field.");
2265 }
2266
2267 return;
2268 }
2269
2270 base_type = hlsl_type_from_fx_type(state->type);
2271 switch (state->class)
2272 {
2273 case HLSL_CLASS_VECTOR:
2274 state_type = hlsl_get_vector_type(ctx, base_type, state->dimx);
2275 break;
2276 case HLSL_CLASS_SCALAR:
2277 state_type = hlsl_get_scalar_type(ctx, base_type);
2278 break;
2279 case HLSL_CLASS_TEXTURE:
2280 hlsl_fixme(ctx, &ctx->location, "Object type fields are not supported.");
2281 break;
2282 default:
2283 ;
2284 }
2285
2286 if (state_type)
2287 {
2288 node = entry->args->node;
2289 if (!(cast = hlsl_new_cast(ctx, node, state_type, &var->loc)))
2290 return;
2291 list_add_after(&node->entry, &cast->entry);
2292
2293 /* FX_UINT8 values are using 32-bits in the binary. Mask higher 24 bits for those. */
2294 if (state->type == FX_UINT8)
2295 {
2296 struct hlsl_ir_node *mask;
2297
2298 if (!(mask = hlsl_new_uint_constant(ctx, 0xff, &var->loc)))
2299 return;
2300 list_add_after(&cast->entry, &mask->entry);
2301
2302 if (!(cast = hlsl_new_binary_expr(ctx, HLSL_OP2_BIT_AND, cast, mask)))
2303 return;
2304 list_add_after(&mask->entry, &cast->entry);
2305 }
2306
2307 hlsl_src_remove(entry->args);
2308 hlsl_src_from_node(entry->args, cast);
2309
2311 }
2312}
static const struct @282 state_table[]
static const struct rhs_named_value blend_values[]
Definition: fx.c:2002
static bool is_object_fx_type(enum state_property_component_type type)
Definition: fx.c:1840
static bool replace_state_block_constant(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
Definition: fx.c:1791
static const struct rhs_named_value blendop_values[]
Definition: fx.c:2024
static enum hlsl_type_class hlsl_type_class_from_fx_type(enum state_property_component_type type)
Definition: fx.c:1861
static const struct rhs_named_value bool_values[]
Definition: fx.c:2034
static enum hlsl_base_type hlsl_type_from_fx_type(enum state_property_component_type type)
Definition: fx.c:1892
static bool lower_null_constant(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
Definition: fx.c:1773
GLenum GLint GLuint mask
Definition: glext.h:6028
enum wined3d_data_type data_type
Definition: glsl_shader.c:71
struct hlsl_ir_node * hlsl_new_cast(struct hlsl_ctx *ctx, struct hlsl_ir_node *node, struct hlsl_type *type, const struct vkd3d_shader_location *loc)
Definition: hlsl.c:1294
struct hlsl_ir_node * hlsl_new_binary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2)
Definition: hlsl.c:1619
static void hlsl_src_from_node(struct hlsl_src *src, struct hlsl_ir_node *node)
Definition: hlsl.h:1286
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
@ HLSL_IR_LOAD
Definition: hlsl.h:320
hlsl_base_type
Definition: hlsl.h:114
static struct hlsl_type * hlsl_get_scalar_type(const struct hlsl_ctx *ctx, enum hlsl_base_type base_type)
Definition: hlsl.h:1360
bool hlsl_transform_ir(struct hlsl_ctx *ctx, bool(*func)(struct hlsl_ctx *ctx, struct hlsl_ir_node *, void *), struct hlsl_block *block, void *context)
Definition: hlsl_codegen.c:642
static void hlsl_src_remove(struct hlsl_src *src)
Definition: hlsl.h:1293
@ HLSL_OP2_BIT_AND
Definition: hlsl.h:719
void hlsl_run_const_passes(struct hlsl_ctx *ctx, struct hlsl_block *body)
int load
Definition: msacm.c:1365
__WINE_SERVER_LIST_INLINE void list_add_after(struct list *elem, struct list *to_add)
Definition: list.h:80
const WCHAR * name
Definition: dlist.c:348

Referenced by write_fx_4_state_block().

◆ set_status()

static void set_status ( struct fx_write_context *  fx,
int  status 
)
static

Definition at line 231 of file fx.c.

232{
233 if (fx->status < 0)
234 return;
235 if (status < 0)
236 fx->status = status;
237}
Definition: ps.c:97

Referenced by hlsl_fx_4_write(), hlsl_fx_5_write(), write_fx_4_type(), and write_techniques().

◆ state_block_contains_state()

static bool state_block_contains_state ( const struct hlsl_state_block_entry *  entry,
unsigned int  start_index,
struct hlsl_state_block *  block 
)
static

Definition at line 1740 of file fx.c.

1742{
1743 unsigned int i;
1744
1745 for (i = start_index; i < block->count; ++i)
1746 {
1747 const struct hlsl_state_block_entry *cur = block->entries[i];
1748
1749 if (cur->is_function_call)
1750 continue;
1751
1752 if (ascii_strcasecmp(cur->name, entry->name))
1753 continue;
1754
1755 if (cur->lhs_has_index != entry->lhs_has_index)
1756 continue;
1757
1758 if (cur->lhs_has_index && cur->lhs_index != entry->lhs_index)
1759 continue;
1760
1761 return true;
1762 }
1763
1764 return false;
1765}
FxCollectionEntry * cur

Referenced by write_fx_4_state_block().

◆ string_storage_compare()

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

Definition at line 56 of file fx.c.

57{
59 const char *string = key;
60
61 return strcmp(string, string_entry->string);
62}
#define RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:26
Definition: copy.c:22
Definition: fx.c:40
const char * string
Definition: fx.c:43

Referenced by fx_write_context_init().

◆ string_storage_destroy()

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

Definition at line 64 of file fx.c.

Referenced by fx_write_context_cleanup().

◆ technique_matches_version()

static bool technique_matches_version ( const struct hlsl_ir_var *  var,
const struct fx_write_context *  fx 
)
static

Definition at line 396 of file fx.c.

397{
398 const struct hlsl_type *type = var->data_type;
399
400 if (type->class != HLSL_CLASS_TECHNIQUE)
401 return false;
402
403 return type->e.version >= fx->min_technique_version && type->e.version <= fx->max_technique_version;
404}

Referenced by write_groups(), and write_techniques().

◆ VKD3D_PRINTF_FUNC()

static void VKD3D_PRINTF_FUNC ( 3  ,
4   
)
static

Definition at line 2940 of file fx.c.

2942{
2943 va_list args;
2944
2946 vkd3d_shader_verror(parser->message_context, NULL, error, format, args);
2947 va_end(args);
2948
2949 parser->failed = true;
2950}
#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
#define args
Definition: format.c:66
Definition: match.c:390
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)

◆ write_annotations()

static uint32_t write_annotations ( struct hlsl_scope *  scope,
struct fx_write_context *  fx 
)
static

Definition at line 249 of file fx.c.

250{
251 struct hlsl_ctx *ctx = fx->ctx;
252 struct hlsl_ir_var *v;
253 uint32_t count = 0;
254
255 if (!scope)
256 return 0;
257
259 {
260 if (!v->default_values)
262 "Annotation variable is missing default value.");
263
264 fx->ops->write_annotation(v, fx);
265 ++count;
266 }
267
268 return count;
269}
const GLdouble * v
Definition: gl.h:2040
struct hlsl_scope * scope
Definition: hlsl.h:470

Referenced by write_fx_2_annotations(), and write_fx_4_annotations().

◆ write_buffers()

static void write_buffers ( struct fx_write_context *  fx,
bool  shared 
)
static

Definition at line 2668 of file fx.c.

2669{
2670 struct hlsl_buffer *buffer;
2671
2672 if (shared && !fx->child_effect)
2673 return;
2674
2675 LIST_FOR_EACH_ENTRY(buffer, &fx->ctx->buffers, struct hlsl_buffer, entry)
2676 {
2677 if (!buffer->size && !fx->include_empty_buffers)
2678 continue;
2679 if (!strcmp(buffer->name, "$Params"))
2680 continue;
2681 if (fx->child_effect && (shared != !!(buffer->modifiers & HLSL_STORAGE_SHARED)))
2682 continue;
2683
2685 }
2686}
static void write_fx_4_buffer(struct hlsl_buffer *b, struct fx_write_context *fx)
Definition: fx.c:2607
#define HLSL_STORAGE_SHARED
Definition: hlsl.h:400

Referenced by hlsl_fx_4_write(), and hlsl_fx_5_write().

◆ write_fx_2_annotation()

static void write_fx_2_annotation ( struct hlsl_ir_var *  var,
struct fx_write_context *  fx 
)
static

Definition at line 1342 of file fx.c.

1343{
1344 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
1345 uint32_t desc_offset, value_offset;
1346
1347 desc_offset = write_fx_2_parameter(var->data_type, var->name, &var->semantic, fx);
1348 value_offset = write_fx_2_initial_value(var, fx);
1349
1350 put_u32(buffer, desc_offset);
1351 put_u32(buffer, value_offset);
1352}
static uint32_t write_fx_2_initial_value(const struct hlsl_ir_var *var, struct fx_write_context *fx)
Definition: fx.c:1207
static uint32_t write_fx_2_parameter(const struct hlsl_type *type, const char *name, const struct hlsl_semantic *semantic, struct fx_write_context *fx)
Definition: fx.c:1011

◆ write_fx_2_annotations()

static void write_fx_2_annotations ( struct hlsl_ir_var *  var,
uint32_t  count_offset,
struct fx_write_context *  fx 
)
static

Definition at line 445 of file fx.c.

446{
447 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
449
450 count = write_annotations(var->annotations, fx);
451 set_u32(buffer, count_offset, count);
452}
static uint32_t write_annotations(struct hlsl_scope *scope, struct fx_write_context *fx)
Definition: fx.c:249

Referenced by write_fx_2_parameters(), write_fx_2_pass(), and write_fx_2_technique().

◆ write_fx_2_default_value()

static uint32_t write_fx_2_default_value ( struct hlsl_type *  value_type,
struct hlsl_default_value *  value,
struct fx_write_context *  fx 
)
static

Definition at line 1093 of file fx.c.

1095{
1096 const struct hlsl_type *type = hlsl_get_multiarray_element_type(value_type);
1098 struct vkd3d_bytecode_buffer *buffer = &fx->unstructured;
1099 struct hlsl_ctx *ctx = fx->ctx;
1100 uint32_t offset = buffer->size;
1101 unsigned int comp_count;
1102
1103 if (!value)
1104 return 0;
1105
1106 comp_count = hlsl_type_component_count(type);
1107
1108 for (i = 0; i < elements_count; ++i)
1109 {
1110 switch (type->class)
1111 {
1112 case HLSL_CLASS_SCALAR:
1113 case HLSL_CLASS_VECTOR:
1114 case HLSL_CLASS_MATRIX:
1115 {
1116 switch (type->e.numeric.type)
1117 {
1118 case HLSL_TYPE_FLOAT:
1119 case HLSL_TYPE_HALF:
1120 case HLSL_TYPE_INT:
1121 case HLSL_TYPE_UINT:
1122 case HLSL_TYPE_BOOL:
1123
1124 for (j = 0; j < comp_count; ++j)
1125 {
1126 put_u32(buffer, value->number.u);
1127 value++;
1128 }
1129 break;
1130 default:
1131 hlsl_fixme(ctx, &ctx->location, "Writing default values for numeric type %u is not implemented.",
1132 type->e.numeric.type);
1133 }
1134
1135 break;
1136 }
1137 case HLSL_CLASS_STRUCT:
1138 {
1139 struct hlsl_struct_field *fields = type->e.record.fields;
1140
1141 for (j = 0; j < type->e.record.field_count; ++j)
1142 {
1145 }
1146 break;
1147 }
1148 default:
1149 hlsl_fixme(ctx, &ctx->location, "Writing default values for class %u is not implemented.", type->class);
1150 }
1151 }
1152
1153 return offset;
1154}
static uint32_t write_fx_2_default_value(struct hlsl_type *value_type, struct hlsl_default_value *value, struct fx_write_context *fx)
Definition: fx.c:1093
unsigned int hlsl_type_component_count(const struct hlsl_type *type)
Definition: hlsl.c:1042
const char * fields[10]
Definition: parser.c:313
unsigned int elements_count
Definition: hlsl.h:210

Referenced by write_fx_2_default_value(), and write_fx_2_initial_value().

◆ write_fx_2_initial_value()

static uint32_t write_fx_2_initial_value ( const struct hlsl_ir_var *  var,
struct fx_write_context *  fx 
)
static

Definition at line 1207 of file fx.c.

1208{
1209 const struct hlsl_type *type = hlsl_get_multiarray_element_type(var->data_type);
1210 struct hlsl_ctx *ctx = fx->ctx;
1212
1213 /* Note that struct fields must all be numeric;
1214 * this was validated in check_invalid_object_fields(). */
1215 switch (type->class)
1216 {
1217 case HLSL_CLASS_SCALAR:
1218 case HLSL_CLASS_VECTOR:
1219 case HLSL_CLASS_MATRIX:
1220 case HLSL_CLASS_STRUCT:
1221 offset = write_fx_2_default_value(var->data_type, var->default_values, fx);
1222 break;
1223
1224 case HLSL_CLASS_SAMPLER:
1225 case HLSL_CLASS_TEXTURE:
1226 case HLSL_CLASS_STRING:
1230 break;
1231
1232 default:
1233 offset = 0;
1234 hlsl_fixme(ctx, &var->loc, "Writing initializer not implemented for parameter class %#x.", type->class);
1235 break;
1236 }
1237
1238 return offset;
1239}
static uint32_t write_fx_2_object_initializer(const struct hlsl_ir_var *var, struct fx_write_context *fx)
Definition: fx.c:1156

Referenced by write_fx_2_annotation(), and write_fx_2_parameters().

◆ write_fx_2_object_initializer()

static uint32_t write_fx_2_object_initializer ( const struct hlsl_ir_var *  var,
struct fx_write_context *  fx 
)
static

Definition at line 1156 of file fx.c.

1157{
1158 const struct hlsl_type *type = hlsl_get_multiarray_element_type(var->data_type);
1159 unsigned int i, elements_count = hlsl_get_multiarray_size(var->data_type);
1160 struct vkd3d_bytecode_buffer *buffer = &fx->objects;
1161 uint32_t offset = fx->unstructured.size, id, size;
1162 struct hlsl_ctx *ctx = fx->ctx;
1163 const void *data;
1164
1165 for (i = 0; i < elements_count; ++i)
1166 {
1167 if (type->class == HLSL_CLASS_SAMPLER)
1168 {
1169 hlsl_fixme(ctx, &var->loc, "Writing fx_2_0 sampler objects initializers is not implemented.");
1170 }
1171 else
1172 {
1173 switch (type->class)
1174 {
1175 case HLSL_CLASS_STRING:
1176 {
1177 const char *string = var->default_values[i].string ? var->default_values[i].string : "";
1178 size = strlen(string) + 1;
1179 data = string;
1180 break;
1181 }
1182 case HLSL_CLASS_TEXTURE:
1183 size = 0;
1184 break;
1187 size = 0;
1188 hlsl_fixme(ctx, &var->loc, "Writing fx_2_0 shader objects initializers is not implemented.");
1189 break;
1190 default:
1192 }
1193 id = fx->object_variable_count++;
1194
1195 put_u32(&fx->unstructured, id);
1196
1197 put_u32(buffer, id);
1199 if (size)
1201 }
1202 }
1203
1204 return offset;
1205}
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
char string[160]
Definition: util.h:11

Referenced by write_fx_2_initial_value().

◆ write_fx_2_parameter()

static uint32_t write_fx_2_parameter ( const struct hlsl_type *  type,
const char *  name,
const struct hlsl_semantic *  semantic,
struct fx_write_context *  fx 
)
static

Definition at line 1011 of file fx.c.

1013{
1014 struct vkd3d_bytecode_buffer *buffer = &fx->unstructured;
1015 uint32_t semantic_offset, offset, elements_count = 0, name_offset;
1016 size_t i;
1017
1018 /* Resolve arrays to element type and number of elements. */
1019 if (type->class == HLSL_CLASS_ARRAY)
1020 {
1021 elements_count = hlsl_get_multiarray_size(type);
1023 }
1024
1025 name_offset = write_string(name, fx);
1026 semantic_offset = semantic->raw_name ? write_string(semantic->raw_name, fx) : 0;
1027
1030 put_u32(buffer, name_offset);
1031 put_u32(buffer, semantic_offset);
1032 put_u32(buffer, elements_count);
1033
1034 switch (type->class)
1035 {
1036 case HLSL_CLASS_VECTOR:
1037 put_u32(buffer, type->dimx);
1038 put_u32(buffer, type->dimy);
1039 break;
1040 case HLSL_CLASS_SCALAR:
1041 case HLSL_CLASS_MATRIX:
1042 put_u32(buffer, type->dimy);
1043 put_u32(buffer, type->dimx);
1044 break;
1045 case HLSL_CLASS_STRUCT:
1046 put_u32(buffer, type->e.record.field_count);
1047 break;
1050 fx->shader_count += elements_count;
1051 break;
1052 default:
1053 ;
1054 }
1055
1056 if (type->class == HLSL_CLASS_STRUCT)
1057 {
1058 for (i = 0; i < type->e.record.field_count; ++i)
1059 {
1060 const struct hlsl_struct_field *field = &type->e.record.fields[i];
1061
1062 /* Validated in check_invalid_object_fields(). */
1064 write_fx_2_parameter(field->type, field->name, &field->semantic, fx);
1065 }
1066 }
1067
1068 return offset;
1069}
D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type)
Definition: d3dbc.c:1575
static uint32_t write_string(const char *string, struct fx_write_context *fx)
Definition: fx.c:239
static uint32_t get_fx_2_type_class(const struct hlsl_type *type)
Definition: fx.c:1004
Definition: parser.c:44
const char * raw_name
Definition: hlsl.h:245

Referenced by write_fx_2_annotation(), write_fx_2_parameter(), and write_fx_2_parameters().

◆ write_fx_2_parameters()

static void write_fx_2_parameters ( struct fx_write_context *  fx)
static

Definition at line 1308 of file fx.c.

1309{
1310 uint32_t desc_offset, value_offset, flags, annotation_count_offset;
1311 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
1312 struct hlsl_ctx *ctx = fx->ctx;
1313 struct hlsl_ir_var *var;
1314 enum fx_2_parameter_flags
1315 {
1316 IS_SHARED = 0x1,
1317 };
1318
1319 LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
1320 {
1321 if (!is_type_supported_fx_2(ctx, var->data_type, &var->loc))
1322 continue;
1323
1324 desc_offset = write_fx_2_parameter(var->data_type, var->name, &var->semantic, fx);
1325 value_offset = write_fx_2_initial_value(var, fx);
1326
1327 flags = 0;
1328 if (var->storage_modifiers & HLSL_STORAGE_SHARED)
1329 flags |= IS_SHARED;
1330
1331 put_u32(buffer, desc_offset);
1332 put_u32(buffer, value_offset);
1334
1335 annotation_count_offset = put_u32(buffer, 0);
1336 write_fx_2_annotations(var, annotation_count_offset, fx);
1337
1338 ++fx->parameter_count;
1339 }
1340}
static void write_fx_2_annotations(struct hlsl_ir_var *var, uint32_t count_offset, struct fx_write_context *fx)
Definition: fx.c:445
struct list extern_entry
Definition: hlsl.h:468

Referenced by hlsl_fx_2_write().

◆ write_fx_2_pass()

static void write_fx_2_pass ( struct hlsl_ir_var *  var,
struct fx_write_context *  fx 
)
static

Definition at line 454 of file fx.c.

455{
456 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
457 uint32_t name_offset, annotation_count_offset;
458
459 name_offset = write_string(var->name, fx);
460 put_u32(buffer, name_offset);
461 annotation_count_offset = put_u32(buffer, 0);
462 put_u32(buffer, 0); /* Assignment count. */
463
464 write_fx_2_annotations(var, annotation_count_offset, fx);
465 /* TODO: assignments */
466
467 if (var->state_block_count && var->state_blocks[0]->count)
468 hlsl_fixme(fx->ctx, &var->loc, "Write pass assignments.");
469
470 /* For some reason every pass adds to the total shader object count. */
471 fx->shader_count++;
472}

◆ write_fx_2_string()

static uint32_t write_fx_2_string ( const char *  string,
struct fx_write_context *  fx 
)
static

Definition at line 988 of file fx.c.

989{
990 struct vkd3d_bytecode_buffer *buffer = &fx->unstructured;
991 const char *s = string ? string : "";
992 static const char tail[3];
994
995 size = strlen(s) + 1;
998 size %= 4;
999 if (size)
1001 return offset;
1002}
struct outqueuenode * tail
Definition: adnsresfilter.c:66
GLdouble s
Definition: gl.h:2039

◆ write_fx_2_technique()

static void write_fx_2_technique ( struct hlsl_ir_var *  var,
struct fx_write_context *  fx 
)
static

Definition at line 1071 of file fx.c.

1072{
1073 uint32_t name_offset, pass_count_offset, annotation_count_offset, count = 0;
1074 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
1075 struct hlsl_ir_var *pass;
1076
1077 name_offset = write_string(var->name, fx);
1078 put_u32(buffer, name_offset);
1079 annotation_count_offset = put_u32(buffer, 0);
1080 pass_count_offset = put_u32(buffer, 0);
1081
1082 write_fx_2_annotations(var, annotation_count_offset, fx);
1083
1084 LIST_FOR_EACH_ENTRY(pass, &var->scope->vars, struct hlsl_ir_var, scope_entry)
1085 {
1086 write_pass(pass, fx);
1087 ++count;
1088 }
1089
1090 set_u32(buffer, pass_count_offset, count);
1091}
static void write_pass(struct hlsl_ir_var *var, struct fx_write_context *fx)
Definition: fx.c:244

◆ write_fx_4_annotation()

static void write_fx_4_annotation ( struct hlsl_ir_var *  var,
struct fx_write_context *  fx 
)
static

Definition at line 1555 of file fx.c.

1556{
1557 const struct hlsl_type *type = hlsl_get_multiarray_element_type(var->data_type);
1558 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
1559 uint32_t name_offset, type_offset, offset;
1560 struct hlsl_ctx *ctx = fx->ctx;
1561
1562 name_offset = write_string(var->name, fx);
1563 type_offset = write_type(var->data_type, fx);
1564
1565 put_u32(buffer, name_offset);
1566 put_u32(buffer, type_offset);
1567
1569 {
1570 offset = write_fx_4_default_value(var->data_type, var->default_values, fx);
1572 }
1573 else if (type->class == HLSL_CLASS_STRING)
1574 {
1576 }
1577 else
1578 {
1579 hlsl_fixme(ctx, &var->loc, "Writing annotations for type class %u is not implemented.", type->class);
1580 }
1581}
static void write_fx_4_string_initializer(struct hlsl_ir_var *var, struct fx_write_context *fx)
Definition: fx.c:1494
static uint32_t write_fx_4_default_value(struct hlsl_type *value_type, struct hlsl_default_value *value, struct fx_write_context *fx)
Definition: fx.c:1431
static uint32_t write_type(const struct hlsl_type *type, struct fx_write_context *fx)
Definition: fx.c:287

◆ write_fx_4_annotations()

static void write_fx_4_annotations ( struct hlsl_scope *  scope,
struct fx_write_context *  fx 
)
static

Definition at line 271 of file fx.c.

272{
273 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
274 uint32_t count_offset, count;
275
276 count_offset = put_u32(buffer, 0);
277 count = write_annotations(scope, fx);
278 set_u32(buffer, count_offset, count);
279}

Referenced by write_fx_4_buffer(), write_fx_4_numeric_variable(), write_fx_4_object_variable(), write_fx_4_pass(), write_fx_4_technique(), and write_group().

◆ write_fx_4_buffer()

static void write_fx_4_buffer ( struct hlsl_buffer *  b,
struct fx_write_context *  fx 
)
static

Definition at line 2607 of file fx.c.

2608{
2609 enum fx_4_buffer_flags
2610 {
2611 IS_TBUFFER = 0x1,
2612 IS_SINGLE = 0x2,
2613 };
2614 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
2615 uint32_t count = 0, bind_point = ~0u, flags = 0, size;
2616 uint32_t name_offset, size_offset;
2617 struct hlsl_ctx *ctx = fx->ctx;
2618 struct hlsl_ir_var *var;
2619 uint32_t count_offset;
2620 bool shared;
2621
2622 shared = fx->child_effect && b->modifiers & HLSL_STORAGE_SHARED;
2623
2624 if (b->reservation.reg_type)
2625 bind_point = b->reservation.reg_index;
2626 if (b->type == HLSL_BUFFER_TEXTURE)
2627 flags |= IS_TBUFFER;
2628 if (ctx->profile->major_version == 5 && b->modifiers & HLSL_MODIFIER_SINGLE)
2629 flags |= IS_SINGLE;
2630
2631 name_offset = write_string(b->name, fx);
2632
2633 put_u32(buffer, name_offset); /* Name */
2634 size_offset = put_u32(buffer, 0); /* Data size */
2635 put_u32(buffer, flags); /* Flags */
2636 count_offset = put_u32(buffer, 0);
2637 put_u32(buffer, bind_point); /* Bind point */
2638
2639 if (shared)
2640 {
2641 ++fx->shared_buffer_count;
2642 }
2643 else
2644 {
2645 write_fx_4_annotations(b->annotations, fx);
2646 ++fx->buffer_count;
2647 }
2648
2649 count = 0;
2650 size = 0;
2651 LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
2652 {
2653 if (!is_numeric_fx_4_type(var->data_type))
2654 continue;
2655
2656 if (var->buffer != b)
2657 continue;
2658
2660 size += get_fx_4_type_size(var->data_type);
2661 ++count;
2662 }
2663
2664 set_u32(buffer, count_offset, count);
2665 set_u32(buffer, size_offset, align(size, 16));
2666}
static void write_fx_4_numeric_variable(struct hlsl_ir_var *var, bool shared, struct fx_write_context *fx)
Definition: fx.c:1515
static void write_fx_4_annotations(struct hlsl_scope *scope, struct fx_write_context *fx)
Definition: fx.c:271
static bool is_numeric_fx_4_type(const struct hlsl_type *type)
Definition: fx.c:679
static uint32_t get_fx_4_type_size(const struct hlsl_type *type)
Definition: fx.c:474
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
@ HLSL_BUFFER_TEXTURE
Definition: hlsl.h:986
#define HLSL_MODIFIER_SINGLE
Definition: hlsl.h:414

Referenced by write_buffers().

◆ write_fx_4_default_value()

static uint32_t write_fx_4_default_value ( struct hlsl_type *  value_type,
struct hlsl_default_value *  value,
struct fx_write_context *  fx 
)
static

Definition at line 1431 of file fx.c.

1433{
1434 const struct hlsl_type *type = hlsl_get_multiarray_element_type(value_type);
1436 struct vkd3d_bytecode_buffer *buffer = &fx->unstructured;
1437 struct hlsl_ctx *ctx = fx->ctx;
1438 uint32_t offset = buffer->size;
1439 unsigned int comp_count;
1440
1441 if (!value)
1442 return 0;
1443
1444 comp_count = hlsl_type_component_count(type);
1445
1446 for (i = 0; i < elements_count; ++i)
1447 {
1448 switch (type->class)
1449 {
1450 case HLSL_CLASS_SCALAR:
1451 case HLSL_CLASS_VECTOR:
1452 case HLSL_CLASS_MATRIX:
1453 {
1454 switch (type->e.numeric.type)
1455 {
1456 case HLSL_TYPE_FLOAT:
1457 case HLSL_TYPE_HALF:
1458 case HLSL_TYPE_INT:
1459 case HLSL_TYPE_UINT:
1460 case HLSL_TYPE_BOOL:
1461
1462 for (j = 0; j < comp_count; ++j)
1463 {
1464 put_u32_unaligned(buffer, value->number.u);
1465 value++;
1466 }
1467 break;
1468 default:
1469 hlsl_fixme(ctx, &ctx->location, "Writing default values for numeric type %u is not implemented.",
1470 type->e.numeric.type);
1471 }
1472
1473 break;
1474 }
1475 case HLSL_CLASS_STRUCT:
1476 {
1477 struct hlsl_struct_field *fields = type->e.record.fields;
1478
1479 for (j = 0; j < type->e.record.field_count; ++j)
1480 {
1483 }
1484 break;
1485 }
1486 default:
1487 hlsl_fixme(ctx, &ctx->location, "Writing default values for class %u is not implemented.", type->class);
1488 }
1489 }
1490
1491 return offset;
1492}
static size_t put_u32_unaligned(struct vkd3d_bytecode_buffer *buffer, uint32_t value)
Definition: fx.c:23

Referenced by write_fx_4_annotation(), write_fx_4_default_value(), and write_fx_4_numeric_variable().

◆ write_fx_4_numeric_variable()

static void write_fx_4_numeric_variable ( struct hlsl_ir_var *  var,
bool  shared,
struct fx_write_context *  fx 
)
static

Definition at line 1515 of file fx.c.

1516{
1517 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
1518 uint32_t name_offset, type_offset, value_offset;
1519 uint32_t semantic_offset, flags = 0;
1520 enum fx_4_numeric_variable_flags
1521 {
1522 HAS_EXPLICIT_BIND_POINT = 0x4,
1523 };
1524
1525 if (var->has_explicit_bind_point)
1526 flags |= HAS_EXPLICIT_BIND_POINT;
1527
1528 type_offset = write_type(var->data_type, fx);
1529 name_offset = write_string(var->name, fx);
1530 semantic_offset = write_string(var->semantic.raw_name, fx);
1531
1532 put_u32(buffer, name_offset);
1533 put_u32(buffer, type_offset);
1534
1535 semantic_offset = put_u32(buffer, semantic_offset); /* Semantic */
1536 put_u32(buffer, var->buffer_offset * 4); /* Offset in the constant buffer, in bytes. */
1537 value_offset = put_u32(buffer, 0);
1538 put_u32(buffer, flags); /* Flags */
1539
1540 if (shared)
1541 {
1542 fx->shared_numeric_variable_count++;
1543 }
1544 else
1545 {
1546 uint32_t offset = write_fx_4_default_value(var->data_type, var->default_values, fx);
1547 set_u32(buffer, value_offset, offset);
1548
1549 write_fx_4_annotations(var->annotations, fx);
1550
1551 fx->numeric_variable_count++;
1552 }
1553}

Referenced by write_fx_4_buffer().

◆ write_fx_4_object_variable()

static void write_fx_4_object_variable ( struct hlsl_ir_var *  var,
struct fx_write_context *  fx 
)
static

Definition at line 2514 of file fx.c.

2515{
2516 const struct hlsl_type *type = hlsl_get_multiarray_element_type(var->data_type);
2518 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
2519 uint32_t semantic_offset, bind_point = ~0u;
2520 uint32_t name_offset, type_offset;
2521 struct hlsl_ctx *ctx = fx->ctx;
2522
2523 if (var->reg_reservation.reg_type)
2524 bind_point = var->reg_reservation.reg_index;
2525
2526 type_offset = write_type(var->data_type, fx);
2527 name_offset = write_string(var->name, fx);
2528 semantic_offset = write_string(var->semantic.raw_name, fx);
2529
2530 put_u32(buffer, name_offset);
2531 put_u32(buffer, type_offset);
2532
2533 semantic_offset = put_u32(buffer, semantic_offset); /* Semantic */
2534 put_u32(buffer, bind_point); /* Explicit bind point */
2535
2536 if (fx->child_effect && var->storage_modifiers & HLSL_STORAGE_SHARED)
2537 {
2538 ++fx->shared_object_count;
2539 return;
2540 }
2541
2542 /* Initializer */
2543 switch (type->class)
2544 {
2546 fx->rtv_count += elements_count;
2547 break;
2548 case HLSL_CLASS_TEXTURE:
2549 fx->texture_count += elements_count;
2550 break;
2551 case HLSL_CLASS_UAV:
2552 fx->uav_count += elements_count;
2553 break;
2554
2558 fx->shader_count += elements_count;
2559 break;
2560
2565 fx->shader_count += elements_count;
2566 break;
2567
2569 fx->dsv_count += elements_count;
2570 break;
2571
2574 fx->depth_stencil_state_count += elements_count;
2575 break;
2576
2577 case HLSL_CLASS_SAMPLER:
2579 fx->sampler_state_count += elements_count;
2580 break;
2581
2584 fx->rasterizer_state_count += elements_count;
2585 break;
2586
2589 fx->blend_state_count += elements_count;
2590 break;
2591
2592 case HLSL_CLASS_STRING:
2594 fx->string_count += elements_count;
2595 break;
2596
2597 default:
2598 hlsl_fixme(ctx, &ctx->location, "Writing initializer for object class %u is not implemented.",
2599 type->class);
2600 }
2601
2602 write_fx_4_annotations(var->annotations, fx);
2603
2604 ++fx->object_variable_count;
2605}
static void write_fx_4_state_object_initializer(struct hlsl_ir_var *var, struct fx_write_context *fx)
Definition: fx.c:2468
static void write_fx_4_shader_initializer(struct hlsl_ir_var *var, struct fx_write_context *fx)
Definition: fx.c:2482
static void write_fx_5_shader_initializer(struct hlsl_ir_var *var, struct fx_write_context *fx)
Definition: fx.c:2493

Referenced by write_objects().

◆ write_fx_4_pass()

static void write_fx_4_pass ( struct hlsl_ir_var *  var,
struct fx_write_context *  fx 
)
static

Definition at line 432 of file fx.c.

433{
434 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
435 uint32_t name_offset, count_offset;
436
437 name_offset = write_string(var->name, fx);
438 put_u32(buffer, name_offset);
439 count_offset = put_u32(buffer, 0);
440
441 write_fx_4_annotations(var->annotations, fx);
442 write_fx_4_state_block(var, 0, count_offset, fx);
443}
static void write_fx_4_state_block(struct hlsl_ir_var *var, unsigned int block_index, uint32_t count_offset, struct fx_write_context *fx)
Definition: fx.c:2433

◆ write_fx_4_shader_initializer()

static void write_fx_4_shader_initializer ( struct hlsl_ir_var *  var,
struct fx_write_context *  fx 
)
static

Definition at line 2482 of file fx.c.

2483{
2484 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
2485 uint32_t elements_count = hlsl_get_multiarray_size(var->data_type);
2486 unsigned int i;
2487
2488 /* FIXME: write shader blobs, once parser support works. */
2489 for (i = 0; i < elements_count; ++i)
2490 put_u32(buffer, 0);
2491}

Referenced by write_fx_4_object_variable().

◆ write_fx_4_state_assignment()

static void write_fx_4_state_assignment ( const struct hlsl_ir_var *  var,
struct hlsl_state_block_entry *  entry,
struct fx_write_context *  fx 
)
static

Definition at line 1638 of file fx.c.

1640{
1641 uint32_t value_offset = 0, assignment_type = 0, rhs_offset, type_offset, offset;
1642 struct vkd3d_bytecode_buffer *unstructured = &fx->unstructured;
1643 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
1644 struct hlsl_ir_node *value = entry->args->node;
1645 struct hlsl_ctx *ctx = fx->ctx;
1646 struct hlsl_ir_var *index_var;
1647 struct hlsl_ir_constant *c;
1648 struct hlsl_ir_load *load;
1649
1650 put_u32(buffer, entry->name_id);
1651 put_u32(buffer, entry->lhs_index);
1652 type_offset = put_u32(buffer, 0);
1653 rhs_offset = put_u32(buffer, 0);
1654
1655 switch (value->type)
1656 {
1657 case HLSL_IR_CONSTANT:
1658 {
1660
1661 value_offset = write_fx_4_state_numeric_value(c, fx);
1662 assignment_type = FX_4_ASSIGNMENT_CONSTANT;
1663 break;
1664 }
1665 case HLSL_IR_LOAD:
1666 {
1668
1669 if (load->src.path_len)
1670 hlsl_fixme(ctx, &var->loc, "Indexed access in RHS values is not implemented.");
1671
1672 value_offset = write_fx_4_string(load->src.var->name, fx);
1673 assignment_type = FX_4_ASSIGNMENT_VARIABLE;
1674 break;
1675 }
1676 case HLSL_IR_INDEX:
1677 {
1679 struct hlsl_ir_node *val = index->val.node;
1680 struct hlsl_ir_node *idx = index->idx.node;
1681 struct hlsl_type *type;
1682
1683 if (val->type != HLSL_IR_LOAD)
1684 {
1685 hlsl_fixme(ctx, &var->loc, "Unexpected indexed RHS value type.");
1686 break;
1687 }
1688
1690 value_offset = write_fx_4_string(load->src.var->name, fx);
1691 type = load->src.var->data_type;
1692
1693 switch (idx->type)
1694 {
1695 case HLSL_IR_CONSTANT:
1696 {
1698 value_offset = put_u32(unstructured, value_offset);
1699 put_u32(unstructured, c->value.u[0].u);
1700 assignment_type = FX_4_ASSIGNMENT_ARRAY_CONSTANT_INDEX;
1701
1702 if (c->value.u[0].u >= type->e.array.elements_count)
1704 "Array index %u exceeds array size %u.", c->value.u[0].u, type->e.array.elements_count);
1705 break;
1706 }
1707
1708 case HLSL_IR_LOAD:
1709 {
1711 index_var = load->src.var;
1712
1713 /* Special case for uint index variables, for anything more complex use an expression. */
1715 && !load->src.path_len)
1716 {
1717 offset = write_fx_4_string(index_var->name, fx);
1718
1719 value_offset = put_u32(unstructured, value_offset);
1720 put_u32(unstructured, offset);
1721 assignment_type = FX_4_ASSIGNMENT_ARRAY_VARIABLE_INDEX;
1722 break;
1723 }
1724 }
1725 /* fall through */
1726
1727 default:
1728 hlsl_fixme(ctx, &var->loc, "Complex array index expressions in RHS values are not implemented.");
1729 }
1730 break;
1731 }
1732 default:
1733 hlsl_fixme(ctx, &var->loc, "Unsupported assignment type for state %s.", entry->name);
1734 }
1735
1736 set_u32(buffer, type_offset, assignment_type);
1737 set_u32(buffer, rhs_offset, value_offset);
1738}
unsigned int idx
Definition: utils.c:40
static uint32_t write_fx_4_string(const char *string, struct fx_write_context *fx)
Definition: fx.c:406
static uint32_t write_fx_4_state_numeric_value(struct hlsl_ir_constant *value, struct fx_write_context *fx)
Definition: fx.c:1606
GLuint GLfloat * val
Definition: glext.h:7180
bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2)
Definition: hlsl.c:1095
@ HLSL_IR_INDEX
Definition: hlsl.h:319
const char * name
Definition: hlsl.h:456
struct hlsl_type * data_type
Definition: hlsl.h:454
@ VKD3D_SHADER_ERROR_HLSL_OFFSET_OUT_OF_BOUNDS

Referenced by write_fx_4_state_block().

◆ write_fx_4_state_block()

static void write_fx_4_state_block ( struct hlsl_ir_var *  var,
unsigned int  block_index,
uint32_t  count_offset,
struct fx_write_context *  fx 
)
static

Definition at line 2433 of file fx.c.

2435{
2436 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
2437 struct hlsl_state_block *block;
2438 uint32_t i, count = 0;
2439
2440 if (var->state_blocks)
2441 {
2442 block = var->state_blocks[block_index];
2443
2444 for (i = 0; i < block->count;)
2445 {
2447 }
2448
2449 for (i = 0; i < block->count; ++i)
2450 {
2451 struct hlsl_state_block_entry *entry = block->entries[i];
2452
2453 /* Skip if property is reassigned later. This will use the last assignment. */
2455 continue;
2456
2457 /* Resolve special constant names and property names. */
2459
2461 ++count;
2462 }
2463 }
2464
2465 set_u32(buffer, count_offset, count);
2466}
static unsigned int decompose_fx_4_state_block(struct hlsl_ir_var *var, struct hlsl_state_block *block, unsigned int entry_index, struct fx_write_context *fx)
Definition: fx.c:2422
static void write_fx_4_state_assignment(const struct hlsl_ir_var *var, struct hlsl_state_block_entry *entry, struct fx_write_context *fx)
Definition: fx.c:1638
static void resolve_fx_4_state_block_values(struct hlsl_ir_var *var, struct hlsl_state_block_entry *entry, struct fx_write_context *fx)
Definition: fx.c:2125
static bool state_block_contains_state(const struct hlsl_state_block_entry *entry, unsigned int start_index, struct hlsl_state_block *block)
Definition: fx.c:1740

Referenced by write_fx_4_pass(), and write_fx_4_state_object_initializer().

◆ write_fx_4_state_numeric_value()

static uint32_t write_fx_4_state_numeric_value ( struct hlsl_ir_constant *  value,
struct fx_write_context *  fx 
)
static

Definition at line 1606 of file fx.c.

1607{
1608 struct vkd3d_bytecode_buffer *buffer = &fx->unstructured;
1609 struct hlsl_type *data_type = value->node.data_type;
1610 struct hlsl_ctx *ctx = fx->ctx;
1613
1615
1616 for (i = 0; i < count; ++i)
1617 {
1618 switch (data_type->e.numeric.type)
1619 {
1620 case HLSL_TYPE_FLOAT:
1621 case HLSL_TYPE_INT:
1622 case HLSL_TYPE_UINT:
1623 case HLSL_TYPE_BOOL:
1624 type = fx_4_numeric_base_types[data_type->e.numeric.type];
1625 break;
1626 default:
1627 type = 0;
1628 hlsl_fixme(ctx, &ctx->location, "Unsupported numeric state value type %u.", data_type->e.numeric.type);
1629 }
1630
1632 put_u32_unaligned(buffer, value->value.u[i].u);
1633 }
1634
1635 return offset;
1636}

Referenced by write_fx_4_state_assignment().

◆ write_fx_4_state_object_initializer()

static void write_fx_4_state_object_initializer ( struct hlsl_ir_var *  var,
struct fx_write_context *  fx 
)
static

Definition at line 2468 of file fx.c.

2469{
2470 uint32_t elements_count = hlsl_get_multiarray_size(var->data_type), i;
2471 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
2472 uint32_t count_offset;
2473
2474 for (i = 0; i < elements_count; ++i)
2475 {
2476 count_offset = put_u32(buffer, 0);
2477
2478 write_fx_4_state_block(var, i, count_offset, fx);
2479 }
2480}

Referenced by write_fx_4_object_variable().

◆ write_fx_4_string()

static uint32_t write_fx_4_string ( const char *  string,
struct fx_write_context *  fx 
)
static

Definition at line 406 of file fx.c.

407{
409 struct rb_entry *entry;
410
411 /* NULLs are emitted as empty strings using the same 4 bytes at the start of the section. */
412 if (!string)
413 return 0;
414
415 if ((entry = rb_get(&fx->strings, string)))
416 {
418 return string_entry->offset;
419 }
420
421 if (!(string_entry = hlsl_alloc(fx->ctx, sizeof(*string_entry))))
422 return 0;
423
424 string_entry->offset = bytecode_put_bytes_unaligned(&fx->unstructured, string, strlen(string) + 1);
426
427 rb_put(&fx->strings, string, &string_entry->entry);
428
429 return string_entry->offset;
430}
static void * hlsl_alloc(struct hlsl_ctx *ctx, size_t size)
Definition: hlsl.h:1300
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
Definition: rbtree.h:30
uint32_t offset
Definition: fx.c:44
struct rb_entry entry
Definition: fx.c:41

Referenced by write_fx_4_state_assignment(), and write_fx_4_string_initializer().

◆ write_fx_4_string_initializer()

static void write_fx_4_string_initializer ( struct hlsl_ir_var *  var,
struct fx_write_context *  fx 
)
static

Definition at line 1494 of file fx.c.

1495{
1496 uint32_t elements_count = hlsl_get_multiarray_size(var->data_type), i;
1497 const struct hlsl_default_value *value = var->default_values;
1498 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
1499 struct hlsl_ctx *ctx = fx->ctx;
1501
1502 if (!value)
1503 {
1504 hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "String objects have to be initialized.");
1505 return;
1506 }
1507
1508 for (i = 0; i < elements_count; ++i, ++value)
1509 {
1510 offset = write_fx_4_string(value->string, fx);
1512 }
1513}

Referenced by write_fx_4_annotation(), and write_fx_4_object_variable().

◆ write_fx_4_technique()

static void write_fx_4_technique ( struct hlsl_ir_var *  var,
struct fx_write_context *  fx 
)
static

Definition at line 906 of file fx.c.

907{
908 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
909 uint32_t name_offset, count = 0;
910 struct hlsl_ir_var *pass;
911 uint32_t count_offset;
912
913 name_offset = write_string(var->name, fx);
914 put_u32(buffer, name_offset);
915 count_offset = put_u32(buffer, 0);
916 write_fx_4_annotations(var->annotations, fx);
917
918 count = 0;
919 LIST_FOR_EACH_ENTRY(pass, &var->scope->vars, struct hlsl_ir_var, scope_entry)
920 {
922 ++count;
923 }
924
925 set_u32(buffer, count_offset, count);
926}

◆ write_fx_4_type()

static uint32_t write_fx_4_type ( const struct hlsl_type *  type,
struct fx_write_context *  fx 
)
static

Definition at line 685 of file fx.c.

686{
687 struct field_offsets
688 {
690 uint32_t semantic;
693 };
694 uint32_t name_offset, offset, unpacked_size, packed_size, stride, numeric_desc;
695 struct vkd3d_bytecode_buffer *buffer = &fx->unstructured;
696 struct field_offsets *field_offsets = NULL;
697 const struct hlsl_type *element_type;
698 struct hlsl_ctx *ctx = fx->ctx;
699 uint32_t elements_count = 0;
700 const char *name;
701 size_t i;
702
703 if (type->class == HLSL_CLASS_ARRAY)
704 elements_count = hlsl_get_multiarray_size(type);
706
707 name = get_fx_4_type_name(element_type);
708
709 name_offset = write_string(name, fx);
710 if (element_type->class == HLSL_CLASS_STRUCT)
711 {
712 if (!(field_offsets = hlsl_calloc(ctx, element_type->e.record.field_count, sizeof(*field_offsets))))
713 return 0;
714
715 for (i = 0; i < element_type->e.record.field_count; ++i)
716 {
717 const struct hlsl_struct_field *field = &element_type->e.record.fields[i];
718
719 field_offsets[i].name = write_string(field->name, fx);
720 field_offsets[i].semantic = write_string(field->semantic.raw_name, fx);
721 field_offsets[i].offset = field->reg_offset[HLSL_REGSET_NUMERIC] * sizeof(float);
722 field_offsets[i].type = write_type(field->type, fx);
723 }
724 }
725
726 offset = put_u32_unaligned(buffer, name_offset);
727
728 switch (element_type->class)
729 {
734 break;
735
743 case HLSL_CLASS_UAV:
752 break;
753
756 break;
757
758 case HLSL_CLASS_ARRAY:
760 case HLSL_CLASS_ERROR:
761 case HLSL_CLASS_PASS:
764 case HLSL_CLASS_NULL:
766
767 case HLSL_CLASS_VOID:
768 FIXME("Writing type class %u is not implemented.\n", element_type->class);
770 return 0;
771 }
772
773 /* Structures can only contain numeric fields, this is validated during variable declaration. */
774 unpacked_size = type->reg_size[HLSL_REGSET_NUMERIC] * sizeof(float);
775
776 packed_size = 0;
777 if (is_numeric_fx_4_type(element_type))
778 packed_size = hlsl_type_component_count(element_type) * sizeof(float);
779 if (elements_count)
780 packed_size *= elements_count;
781
782 stride = element_type->reg_size[HLSL_REGSET_NUMERIC] * sizeof(float);
783 stride = align(stride, 4 * sizeof(float));
784
785 put_u32_unaligned(buffer, elements_count);
786 put_u32_unaligned(buffer, unpacked_size);
788 put_u32_unaligned(buffer, packed_size);
789
790 if (element_type->class == HLSL_CLASS_STRUCT)
791 {
792 put_u32_unaligned(buffer, element_type->e.record.field_count);
793 for (i = 0; i < element_type->e.record.field_count; ++i)
794 {
795 const struct field_offsets *field = &field_offsets[i];
796
798 put_u32_unaligned(buffer, field->semantic);
801 }
802
803 if (ctx->profile->major_version == 5)
804 {
805 put_u32_unaligned(buffer, 0); /* Base class type */
806 put_u32_unaligned(buffer, 0); /* Interface count */
807 }
808 }
809 else if (element_type->class == HLSL_CLASS_TEXTURE)
810 {
811 static const uint32_t texture_type[] =
812 {
823 };
824
825 put_u32_unaligned(buffer, texture_type[element_type->sampler_dim]);
826 }
827 else if (element_type->class == HLSL_CLASS_SAMPLER)
828 {
830 }
831 else if (element_type->class == HLSL_CLASS_UAV)
832 {
833 static const uint32_t uav_type[] =
834 {
843 };
844
845 put_u32_unaligned(buffer, uav_type[element_type->sampler_dim]);
846 }
847 else if (element_type->class == HLSL_CLASS_DEPTH_STENCIL_VIEW)
848 {
850 }
851 else if (element_type->class == HLSL_CLASS_RENDER_TARGET_VIEW)
852 {
854 }
855 else if (element_type->class == HLSL_CLASS_PIXEL_SHADER)
856 {
858 }
859 else if (element_type->class == HLSL_CLASS_VERTEX_SHADER)
860 {
862 }
863 else if (element_type->class == HLSL_CLASS_RASTERIZER_STATE)
864 {
866 }
867 else if (element_type->class == HLSL_CLASS_DEPTH_STENCIL_STATE)
868 {
870 }
871 else if (element_type->class == HLSL_CLASS_BLEND_STATE)
872 {
874 }
875 else if (element_type->class == HLSL_CLASS_STRING)
876 {
878 }
879 else if (hlsl_is_numeric_type(element_type))
880 {
881 numeric_desc = get_fx_4_numeric_type_description(element_type, fx);
882 put_u32_unaligned(buffer, numeric_desc);
883 }
884 else if (element_type->class == HLSL_CLASS_COMPUTE_SHADER)
885 {
887 }
888 else if (element_type->class == HLSL_CLASS_HULL_SHADER)
889 {
891 }
892 else if (element_type->class == HLSL_CLASS_DOMAIN_SHADER)
893 {
895 }
896 else
897 {
898 FIXME("Type %u is not supported.\n", element_type->class);
900 }
901
902 vkd3d_free(field_offsets);
903 return offset;
904}
#define FIXME(fmt,...)
Definition: precomp.h:53
static const char * get_fx_4_type_name(const struct hlsl_type *type)
Definition: fx.c:609
static uint32_t get_fx_4_numeric_type_description(const struct hlsl_type *type, struct fx_write_context *fx)
Definition: fx.c:564
GLsizei stride
Definition: glext.h:5848
static void * hlsl_calloc(struct hlsl_ctx *ctx, size_t count, size_t size)
Definition: hlsl.h:1309
enum hlsl_sampler_dim sampler_dim
Definition: hlsl.h:172
union hlsl_type::@5997 e
unsigned int reg_size[HLSL_REGSET_LAST+1]
Definition: hlsl.h:230
struct hlsl_type::@5997::@5999 record
enum hlsl_type_class class
Definition: hlsl.h:163
@ VKD3D_ERROR_NOT_IMPLEMENTED
Definition: vkd3d_types.h:55

Referenced by write_type().

◆ write_fx_5_shader_initializer()

static void write_fx_5_shader_initializer ( struct hlsl_ir_var *  var,
struct fx_write_context *  fx 
)
static

Definition at line 2493 of file fx.c.

2494{
2495 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
2496 uint32_t elements_count = hlsl_get_multiarray_size(var->data_type);
2497 unsigned int i;
2498
2499 /* FIXME: write shader blobs, once parser support works. */
2500 for (i = 0; i < elements_count; ++i)
2501 {
2502 put_u32(buffer, 0); /* Blob offset */
2503 put_u32(buffer, 0); /* SODecl[0] offset */
2504 put_u32(buffer, 0); /* SODecl[1] offset */
2505 put_u32(buffer, 0); /* SODecl[2] offset */
2506 put_u32(buffer, 0); /* SODecl[3] offset */
2507 put_u32(buffer, 0); /* SODecl count */
2508 put_u32(buffer, 0); /* Rasterizer stream */
2509 put_u32(buffer, 0); /* Interface bindings count */
2510 put_u32(buffer, 0); /* Interface initializer offset */
2511 }
2512}

Referenced by write_fx_4_object_variable().

◆ write_group()

static void write_group ( struct hlsl_ir_var *  var,
struct fx_write_context *  fx 
)
static

Definition at line 945 of file fx.c.

946{
947 struct vkd3d_bytecode_buffer *buffer = &fx->structured;
948 uint32_t name_offset = write_string(var ? var->name : NULL, fx);
949 uint32_t count_offset, count;
950
951 put_u32(buffer, name_offset);
952 count_offset = put_u32(buffer, 0); /* Technique count */
953 write_fx_4_annotations(var ? var->annotations : NULL, fx);
954
955 count = fx->technique_count;
956 write_techniques(var ? var->scope : fx->ctx->globals, fx);
957 set_u32(buffer, count_offset, fx->technique_count - count);
958
959 ++fx->group_count;
960}

Referenced by write_groups().

◆ write_groups()

static void write_groups ( struct fx_write_context *  fx)
static

Definition at line 962 of file fx.c.

963{
964 struct hlsl_scope *scope = fx->ctx->globals;
965 bool needs_default_group = false;
966 struct hlsl_ir_var *var;
967
969 {
971 {
972 needs_default_group = true;
973 break;
974 }
975 }
976
977 if (needs_default_group)
980 {
981 const struct hlsl_type *type = var->data_type;
982
983 if (type->class == HLSL_CLASS_EFFECT_GROUP)
985 }
986}
static bool technique_matches_version(const struct hlsl_ir_var *var, const struct fx_write_context *fx)
Definition: fx.c:396
static void write_group(struct hlsl_ir_var *var, struct fx_write_context *fx)
Definition: fx.c:945

Referenced by hlsl_fx_5_write().

◆ write_objects()

static void write_objects ( struct fx_write_context *  fx,
bool  shared 
)
static

Definition at line 2723 of file fx.c.

2724{
2725 struct hlsl_ctx *ctx = fx->ctx;
2726 struct hlsl_ir_var *var;
2727
2728 if (shared && !fx->child_effect)
2729 return;
2730
2731 LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
2732 {
2734 continue;
2735
2736 if (fx->child_effect && (shared != !!(var->storage_modifiers & HLSL_STORAGE_SHARED)))
2737 continue;
2738
2740 }
2741}
static void write_fx_4_object_variable(struct hlsl_ir_var *var, struct fx_write_context *fx)
Definition: fx.c:2514
static bool is_supported_object_variable(const struct hlsl_ctx *ctx, const struct hlsl_ir_var *var)
Definition: fx.c:2688

Referenced by hlsl_fx_4_write(), and hlsl_fx_5_write().

◆ write_pass()

static void write_pass ( struct hlsl_ir_var *  var,
struct fx_write_context *  fx 
)
static

Definition at line 244 of file fx.c.

245{
246 fx->ops->write_pass(var, fx);
247}

Referenced by write_fx_2_technique(), and write_fx_4_technique().

◆ write_string()

◆ write_techniques()

static void write_techniques ( struct hlsl_scope *  scope,
struct fx_write_context *  fx 
)
static

Definition at line 928 of file fx.c.

929{
930 struct hlsl_ir_var *var;
931
933 {
935 {
936 fx->ops->write_technique(var, fx);
937 ++fx->technique_count;
938 }
939 }
940
941 set_status(fx, fx->unstructured.status);
942 set_status(fx, fx->structured.status);
943}

Referenced by hlsl_fx_2_write(), hlsl_fx_4_write(), and write_group().

◆ write_type()

static uint32_t write_type ( const struct hlsl_type *  type,
struct fx_write_context *  fx 
)
static

Definition at line 287 of file fx.c.

288{
289 unsigned int elements_count, modifiers;
290 const struct hlsl_type *element_type;
291 struct type_entry *type_entry;
292 const char *name;
293
294 VKD3D_ASSERT(fx->ctx->profile->major_version >= 4);
295
296 if (type->class == HLSL_CLASS_ARRAY)
297 {
300 }
301 else
302 {
303 elements_count = 0;
304 element_type = type;
305 }
306
307 name = get_fx_4_type_name(element_type);
309
311 {
312 if (strcmp(type_entry->name, name))
313 continue;
314
316 continue;
317
319 continue;
320
321 return type_entry->offset;
322 }
323
324 if (!(type_entry = hlsl_alloc(fx->ctx, sizeof(*type_entry))))
325 return 0;
326
331
332 list_add_tail(&fx->types, &type_entry->entry);
333
334 return type_entry->offset;
335}
static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_context *fx)
Definition: fx.c:685
#define HLSL_MODIFIERS_MAJORITY_MASK
Definition: hlsl.h:427
uint32_t modifiers
Definition: hlsl.h:178
const char * name
Definition: fx.c:50
uint32_t elements_count
Definition: fx.c:51
struct list entry
Definition: fx.c:49
uint32_t offset
Definition: fx.c:53
uint32_t modifiers
Definition: fx.c:52

Referenced by write_fx_4_annotation(), write_fx_4_numeric_variable(), write_fx_4_object_variable(), and write_fx_4_type().

Variable Documentation

◆ address_values

const struct rhs_named_value address_values[]
static
Initial value:
=
{
{ "WRAP", 1 },
{ "MIRROR", 2 },
{ "CLAMP", 3 },
{ "BORDER", 4 },
{ "MIRROR_ONCE", 5 },
{ NULL },
}

Definition at line 1931 of file fx.c.

◆ blend_values

const struct rhs_named_value blend_values[]
static
Initial value:
=
{
{ "ZERO", 1 },
{ "ONE", 2 },
{ "SRC_COLOR", 3 },
{ "INV_SRC_COLOR", 4 },
{ "SRC_ALPHA", 5 },
{ "INV_SRC_ALPHA", 6 },
{ "DEST_ALPHA", 7 },
{ "INV_DEST_ALPHA", 8 },
{ "DEST_COLOR", 9 },
{ "INV_DEST_COLOR", 10 },
{ "SRC_ALPHA_SAT", 11 },
{ "BLEND_FACTOR", 14 },
{ "INV_BLEND_FACTOR", 15 },
{ "SRC1_COLOR", 16 },
{ "INV_SRC1_COLOR", 17 },
{ "SRC1_ALPHA", 18 },
{ "INV_SRC1_ALPHA", 19 },
{ NULL }
}

Definition at line 2002 of file fx.c.

Referenced by resolve_fx_4_state_block_values().

◆ blendop_values

const struct rhs_named_value blendop_values[]
static
Initial value:
=
{
{ "ADD", 1 },
{ "SUBTRACT", 2 },
{ "REV_SUBTRACT", 3 },
{ "MIN", 4 },
{ "MAX", 5 },
{ NULL }
}

Definition at line 2024 of file fx.c.

Referenced by resolve_fx_4_state_block_values().

◆ bool_values

const struct rhs_named_value bool_values[]
static
Initial value:
=
{
{ "FALSE", 0 },
{ "TRUE", 1 },
{ NULL }
}

Definition at line 2034 of file fx.c.

Referenced by resolve_fx_4_state_block_values().

◆ compare_func_values

const struct rhs_named_value compare_func_values[]
static
Initial value:
=
{
{ "NEVER", 1 },
{ "LESS", 2 },
{ "EQUAL", 3 },
{ "LESS_EQUAL", 4 },
{ "GREATER", 5 },
{ "NOT_EQUAL", 6 },
{ "GREATER_EQUAL", 7 },
{ "ALWAYS", 8 },
{ NULL }
}

Definition at line 1941 of file fx.c.

◆ comparison_values

const struct rhs_named_value comparison_values[]
static
Initial value:
=
{
{ "NEVER", 1 },
{ "LESS", 2 },
{ "EQUAL", 3 },
{ "LESS_EQUAL", 4 },
{ "GREATER", 5 },
{ "NOT_EQUAL", 6 },
{ "GREATER_EQUAL", 7 },
{ "ALWAYS", 8 },
{ NULL }
}

Definition at line 1961 of file fx.c.

◆ cull_values

const struct rhs_named_value cull_values[]
static
Initial value:
=
{
{ "NONE", 1 },
{ "FRONT", 2 },
{ "BACK", 3 },
{ NULL }
}

Definition at line 1994 of file fx.c.

◆ depth_write_mask_values

const struct rhs_named_value depth_write_mask_values[]
static
Initial value:
=
{
{ "ZERO", 0 },
{ "ALL", 1 },
{ NULL }
}

Definition at line 1954 of file fx.c.

◆ fill_values

const struct rhs_named_value fill_values[]
static
Initial value:
=
{
{ "WIREFRAME", 2 },
{ "SOLID", 3 },
{ NULL }
}

Definition at line 1987 of file fx.c.

◆ filter_values

const struct rhs_named_value filter_values[]
static
Initial value:
=
{
{ "MIN_MAG_MIP_POINT", 0x00 },
{ "MIN_MAG_POINT_MIP_LINEAR", 0x01 },
{ "MIN_POINT_MAG_LINEAR_MIP_POINT", 0x04 },
{ "MIN_POINT_MAG_MIP_LINEAR", 0x05 },
{ "MIN_LINEAR_MAG_MIP_POINT", 0x10 },
{ "MIN_LINEAR_MAG_POINT_MIP_LINEAR", 0x11 },
{ "MIN_MAG_LINEAR_MIP_POINT", 0x14 },
{ "MIN_MAG_MIP_LINEAR", 0x15 },
{ "ANISOTROPIC", 0x55 },
{ "COMPARISON_MIN_MAG_MIP_POINT", 0x80 },
{ "COMPARISON_MIN_MAG_POINT_MIP_LINEAR", 0x81 },
{ "COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT", 0x84 },
{ "COMPARISON_MIN_POINT_MAG_MIP_LINEAR", 0x85 },
{ "COMPARISON_MIN_LINEAR_MAG_MIP_POINT", 0x90 },
{ "COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR", 0x91 },
{ "COMPARISON_MIN_MAG_LINEAR_MIP_POINT", 0x94 },
{ "COMPARISON_MIN_MAG_MIP_LINEAR", 0x95 },
{ "COMPARISON_ANISOTROPIC", 0xd5 },
{ NULL },
}

Definition at line 1908 of file fx.c.

◆ function_info

Initial value:
=
{
{"SetBlendState", 3, 3, { { "AB_BlendFactor" }, { "AB_SampleMask" }, { "BlendState" } }, 4 },
{"SetDepthStencilState", 2, 2, { { "DS_StencilRef" }, { "DepthStencilState" } }, 4 },
{"SetRasterizerState", 1, 1, { { "RasterizerState" } }, 4 },
{"SetVertexShader", 1, 1, { { "VertexShader" } }, 4 },
{"SetDomainShader", 1, 1, { { "DomainShader" } }, 5 },
{"SetHullShader", 1, 1, { { "HullShader" } }, 5 },
{"SetGeometryShader", 1, 1, { { "GeometryShader" } }, 4 },
{"SetPixelShader", 1, 1, { { "PixelShader" } }, 4 },
{"SetComputeShader", 1, 1, { { "ComputeShader" } }, 4 },
{"OMSetRenderTargets", 2, 9, { {0} }, 4 },
}

◆ fx_2_ops

Initial value:
=
{
.write_string = write_fx_2_string,
.write_technique = write_fx_2_technique,
.write_pass = write_fx_2_pass,
.write_annotation = write_fx_2_annotation,
}
static void write_fx_2_technique(struct hlsl_ir_var *var, struct fx_write_context *fx)
Definition: fx.c:1071
static uint32_t write_fx_2_string(const char *string, struct fx_write_context *fx)
Definition: fx.c:988
static void write_fx_2_annotation(struct hlsl_ir_var *var, struct fx_write_context *fx)
Definition: fx.c:1342
static void write_fx_2_pass(struct hlsl_ir_var *var, struct fx_write_context *fx)
Definition: fx.c:454

Definition at line 1354 of file fx.c.

Referenced by hlsl_fx_2_write().

◆ fx_4_numeric_base_types

◆ fx_4_ops

Initial value:
=
{
.write_string = write_fx_4_string,
.write_technique = write_fx_4_technique,
.write_pass = write_fx_4_pass,
.write_annotation = write_fx_4_annotation,
.are_child_effects_supported = true,
}
static void write_fx_4_technique(struct hlsl_ir_var *var, struct fx_write_context *fx)
Definition: fx.c:906
static void write_fx_4_annotation(struct hlsl_ir_var *var, struct fx_write_context *fx)
Definition: fx.c:1555
static void write_fx_4_pass(struct hlsl_ir_var *var, struct fx_write_context *fx)
Definition: fx.c:432

Definition at line 1422 of file fx.c.

Referenced by hlsl_fx_4_write(), and hlsl_fx_5_write().

◆ fx_4_states

◆ null_values

const struct rhs_named_value null_values[]
static
Initial value:
=
{
{ "NULL", 0 },
{ NULL }
}

Definition at line 2041 of file fx.c.

◆ stencil_op_values

const struct rhs_named_value stencil_op_values[]
static
Initial value:
=
{
{ "KEEP", 1 },
{ "ZERO", 2 },
{ "REPLACE", 3 },
{ "INCR_SAT", 4 },
{ "DECR_SAT", 5 },
{ "INVERT", 6 },
{ "INCR", 7 },
{ "DECR", 8 },
{ NULL }
}

Definition at line 1974 of file fx.c.