ReactOS 0.4.16-dev-336-gb667d82
shader.c File Reference
#include "config.h"
#include "wine/port.h"
#include <stdio.h>
#include <string.h>
#include "wined3d_private.h"
Include dependency graph for shader.c:

Go to the source code of this file.

Classes

struct  shader_none_priv
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d_shader)
 
static void shader_dump_src_param (struct wined3d_string_buffer *buffer, const struct wined3d_shader_src_param *param, const struct wined3d_shader_version *shader_version)
 
const chardebug_d3dshaderinstructionhandler (enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx)
 
static const charshader_semantic_name_from_usage (enum wined3d_decl_usage usage)
 
static enum wined3d_decl_usage shader_usage_from_semantic_name (const char *name)
 
static enum wined3d_sysval_semantic shader_sysval_semantic_from_usage (enum wined3d_decl_usage usage)
 
BOOL shader_match_semantic (const char *semantic_name, enum wined3d_decl_usage usage)
 
static void shader_signature_from_semantic (struct wined3d_shader_signature_element *e, const struct wined3d_shader_semantic *s)
 
static void shader_signature_from_usage (struct wined3d_shader_signature_element *e, enum wined3d_decl_usage usage, UINT usage_idx, UINT reg_idx, DWORD write_mask)
 
static const struct wined3d_shader_frontendshader_select_frontend (enum wined3d_shader_byte_code_format format)
 
void string_buffer_clear (struct wined3d_string_buffer *buffer)
 
BOOL string_buffer_init (struct wined3d_string_buffer *buffer)
 
void string_buffer_free (struct wined3d_string_buffer *buffer)
 
BOOL string_buffer_resize (struct wined3d_string_buffer *buffer, int rc)
 
int shader_vaddline (struct wined3d_string_buffer *buffer, const char *format, va_list args)
 
int shader_addline (struct wined3d_string_buffer *buffer, const char *format,...)
 
struct wined3d_string_bufferstring_buffer_get (struct wined3d_string_buffer_list *list)
 
static int string_buffer_vsprintf (struct wined3d_string_buffer *buffer, const char *format, va_list args)
 
void string_buffer_sprintf (struct wined3d_string_buffer *buffer, const char *format,...)
 
void string_buffer_release (struct wined3d_string_buffer_list *list, struct wined3d_string_buffer *buffer)
 
void string_buffer_list_init (struct wined3d_string_buffer_list *list)
 
void string_buffer_list_cleanup (struct wined3d_string_buffer_list *list)
 
static unsigned int shader_get_float_offset (enum wined3d_shader_register_type register_type, UINT register_idx)
 
static void shader_delete_constant_list (struct list *clist)
 
static void shader_set_limits (struct wined3d_shader *shader)
 
static BOOL shader_record_register_usage (struct wined3d_shader *shader, struct wined3d_shader_reg_maps *reg_maps, const struct wined3d_shader_register *reg, enum wined3d_shader_type shader_type, unsigned int constf_size)
 
static void shader_record_sample (struct wined3d_shader_reg_maps *reg_maps, unsigned int resource_idx, unsigned int sampler_idx, unsigned int bind_idx)
 
static unsigned int get_instr_extra_regcount (enum WINED3D_SHADER_INSTRUCTION_HANDLER instr, unsigned int param)
 
static HRESULT shader_reg_maps_add_tgsm (struct wined3d_shader_reg_maps *reg_maps, unsigned int register_idx, unsigned int size, unsigned int stride)
 
static HRESULT shader_record_shader_phase (struct wined3d_shader *shader, struct wined3d_shader_phase **current_phase, const struct wined3d_shader_instruction *ins, const DWORD *current_instruction_ptr, const DWORD *previous_instruction_ptr)
 
static HRESULT shader_calculate_clip_or_cull_distance_mask (const struct wined3d_shader_signature_element *e, unsigned int *mask)
 
static void wined3d_insert_interpolation_mode (DWORD *packed_interpolation_mode, unsigned int register_idx, enum wined3d_shader_interpolation_mode mode)
 
static HRESULT shader_get_registers_used (struct wined3d_shader *shader, const struct wined3d_shader_frontend *fe, struct wined3d_shader_reg_maps *reg_maps, struct wined3d_shader_signature *input_signature, struct wined3d_shader_signature *output_signature, DWORD constf_size)
 
static void shader_cleanup_reg_maps (struct wined3d_shader_reg_maps *reg_maps)
 
unsigned int shader_find_free_input_register (const struct wined3d_shader_reg_maps *reg_maps, unsigned int max)
 
static void shader_dump_global_flags (struct wined3d_string_buffer *buffer, DWORD global_flags)
 
static void shader_dump_sync_flags (struct wined3d_string_buffer *buffer, DWORD sync_flags)
 
static void shader_dump_uav_flags (struct wined3d_string_buffer *buffer, DWORD uav_flags)
 
static void shader_dump_tessellator_domain (struct wined3d_string_buffer *buffer, enum wined3d_tessellator_domain domain)
 
static void shader_dump_tessellator_output_primitive (struct wined3d_string_buffer *buffer, enum wined3d_tessellator_output_primitive output_primitive)
 
static void shader_dump_tessellator_partitioning (struct wined3d_string_buffer *buffer, enum wined3d_tessellator_partitioning partitioning)
 
static void shader_dump_shader_input_sysval_semantic (struct wined3d_string_buffer *buffer, enum wined3d_shader_input_sysval_semantic semantic)
 
static void shader_dump_decl_usage (struct wined3d_string_buffer *buffer, const struct wined3d_shader_semantic *semantic, unsigned int flags, const struct wined3d_shader_version *shader_version)
 
static void shader_dump_register (struct wined3d_string_buffer *buffer, const struct wined3d_shader_register *reg, const struct wined3d_shader_version *shader_version)
 
static void shader_dump_dst_param (struct wined3d_string_buffer *buffer, const struct wined3d_shader_dst_param *param, const struct wined3d_shader_version *shader_version)
 
HRESULT shader_generate_code (const struct wined3d_shader *shader, struct wined3d_string_buffer *buffer, const struct wined3d_shader_reg_maps *reg_maps, void *backend_ctx, const DWORD *start, const DWORD *end)
 
static void shader_dump_ins_modifiers (struct wined3d_string_buffer *buffer, const struct wined3d_shader_dst_param *dst)
 
static void shader_dump_primitive_type (struct wined3d_string_buffer *buffer, const struct wined3d_shader_primitive_type *primitive_type)
 
static void shader_dump_interpolation_mode (struct wined3d_string_buffer *buffer, enum wined3d_shader_interpolation_mode interpolation_mode)
 
static void shader_trace_init (const struct wined3d_shader_frontend *fe, void *fe_data)
 
static void shader_cleanup (struct wined3d_shader *shader)
 
static void shader_none_handle_instruction (const struct wined3d_shader_instruction *ins)
 
static void shader_none_precompile (void *shader_priv, struct wined3d_shader *shader)
 
static void shader_none_select_compute (void *shader_priv, struct wined3d_context *context, const struct wined3d_state *state)
 
static void shader_none_update_float_vertex_constants (struct wined3d_device *device, UINT start, UINT count)
 
static void shader_none_update_float_pixel_constants (struct wined3d_device *device, UINT start, UINT count)
 
static void shader_none_load_constants (void *shader_priv, struct wined3d_context *context, const struct wined3d_state *state)
 
static void shader_none_destroy (struct wined3d_shader *shader)
 
static void shader_none_free_context_data (struct wined3d_context *context)
 
static void shader_none_init_context_state (struct wined3d_context *context)
 
static void shader_none_select (void *shader_priv, struct wined3d_context *context, const struct wined3d_state *state)
 
static void shader_none_disable (void *shader_priv, struct wined3d_context *context)
 
static HRESULT shader_none_alloc (struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe, const struct fragment_pipeline *fragment_pipe)
 
static void shader_none_free (struct wined3d_device *device)
 
static BOOL shader_none_allocate_context_data (struct wined3d_context *context)
 
static void shader_none_get_caps (const struct wined3d_gl_info *gl_info, struct shader_caps *caps)
 
static BOOL shader_none_color_fixup_supported (struct color_fixup_desc fixup)
 
static BOOL shader_none_has_ffp_proj_control (void *shader_priv)
 
static HRESULT shader_set_function (struct wined3d_shader *shader, DWORD float_const_count, enum wined3d_shader_type type, unsigned int max_version)
 
ULONG CDECL wined3d_shader_incref (struct wined3d_shader *shader)
 
static void wined3d_shader_init_object (void *object)
 
static void wined3d_shader_destroy_object (void *object)
 
ULONG CDECL wined3d_shader_decref (struct wined3d_shader *shader)
 
void *CDECL wined3d_shader_get_parent (const struct wined3d_shader *shader)
 
HRESULT CDECL wined3d_shader_get_byte_code (const struct wined3d_shader *shader, void *byte_code, UINT *byte_code_size)
 
HRESULT CDECL wined3d_shader_set_local_constants_float (struct wined3d_shader *shader, UINT start_idx, const float *src_data, UINT count)
 
static void init_interpolation_compile_args (DWORD *interpolation_args, const struct wined3d_shader *pixel_shader, const struct wined3d_gl_info *gl_info)
 
void find_vs_compile_args (const struct wined3d_state *state, const struct wined3d_shader *shader, WORD swizzle_map, struct vs_compile_args *args, const struct wined3d_context *context)
 
static BOOL match_usage (BYTE usage1, BYTE usage_idx1, BYTE usage2, BYTE usage_idx2)
 
BOOL vshader_get_input (const struct wined3d_shader *shader, BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum)
 
static HRESULT shader_signature_calculate_strings_length (const struct wined3d_shader_signature *signature, SIZE_T *total)
 
static HRESULT shader_signature_copy (struct wined3d_shader_signature *dst, const struct wined3d_shader_signature *src, char **signature_strings)
 
static HRESULT shader_init (struct wined3d_shader *shader, struct wined3d_device *device, const struct wined3d_shader_desc *desc, DWORD float_const_count, enum wined3d_shader_type type, void *parent, const struct wined3d_parent_ops *parent_ops)
 
static HRESULT vertex_shader_init (struct wined3d_shader *shader, struct wined3d_device *device, const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
 
static HRESULT geometry_shader_init (struct wined3d_shader *shader, struct wined3d_device *device, const struct wined3d_shader_desc *desc, const struct wined3d_stream_output_desc *so_desc, void *parent, const struct wined3d_parent_ops *parent_ops)
 
void find_ds_compile_args (const struct wined3d_state *state, const struct wined3d_shader *shader, struct ds_compile_args *args, const struct wined3d_context *context)
 
void find_gs_compile_args (const struct wined3d_state *state, const struct wined3d_shader *shader, struct gs_compile_args *args, const struct wined3d_context *context)
 
void find_ps_compile_args (const struct wined3d_state *state, const struct wined3d_shader *shader, BOOL position_transformed, struct ps_compile_args *args, const struct wined3d_context *context)
 
static HRESULT pixel_shader_init (struct wined3d_shader *shader, struct wined3d_device *device, const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
 
void pixelshader_update_resource_types (struct wined3d_shader *shader, WORD tex_types)
 
HRESULT CDECL wined3d_shader_create_cs (struct wined3d_device *device, const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
 
HRESULT CDECL wined3d_shader_create_ds (struct wined3d_device *device, const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
 
HRESULT CDECL wined3d_shader_create_gs (struct wined3d_device *device, const struct wined3d_shader_desc *desc, const struct wined3d_stream_output_desc *so_desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
 
HRESULT CDECL wined3d_shader_create_hs (struct wined3d_device *device, const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
 
HRESULT CDECL wined3d_shader_create_ps (struct wined3d_device *device, const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
 
HRESULT CDECL wined3d_shader_create_vs (struct wined3d_device *device, const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
 

Variables

const float wined3d_srgb_const0 [] = {0.41666f, 1.055f, 0.055f, 12.92f}
 
const float wined3d_srgb_const1 [] = {0.0031308f, 0.0f, 0.0f, 0.0f}
 
static const char *const shader_opcode_names []
 
static const char *const semantic_names []
 
struct {
   enum wined3d_shader_input_sysval_semantic   sysval_semantic
 
   const char *   sysval_name
 
shader_input_sysval_semantic_names []
 
const struct wined3d_shader_backend_ops none_shader_backend
 

Function Documentation

◆ debug_d3dshaderinstructionhandler()

const char * debug_d3dshaderinstructionhandler ( enum WINED3D_SHADER_INSTRUCTION_HANDLER  handler_idx)

Definition at line 334 of file shader.c.

335{
336 if (handler_idx >= ARRAY_SIZE(shader_opcode_names))
337 return wine_dbg_sprintf("UNRECOGNIZED(%#x)", handler_idx);
338
339 return shader_opcode_names[handler_idx];
340}
#define ARRAY_SIZE(A)
Definition: main.h:20
static const char *const shader_opcode_names[]
Definition: shader.c:40
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:296

Referenced by shader_arb_handle_instruction(), shader_get_registers_used(), shader_glsl_binop(), shader_glsl_compare(), shader_glsl_handle_instruction(), shader_glsl_map2gl(), shader_glsl_sample(), shader_glsl_unary_op(), shader_hw_map2gl(), shader_hw_mnxn(), shader_hw_scalar_op(), shader_record_shader_phase(), and shader_sm1_validate_instruction().

◆ find_ds_compile_args()

void find_ds_compile_args ( const struct wined3d_state state,
const struct wined3d_shader shader,
struct ds_compile_args args,
const struct wined3d_context context 
)

Definition at line 3748 of file shader.c.

3750{
3751 const struct wined3d_shader *geometry_shader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY];
3752 const struct wined3d_shader *pixel_shader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
3753 const struct wined3d_shader *hull_shader = state->shader[WINED3D_SHADER_TYPE_HULL];
3754 const struct wined3d_gl_info *gl_info = context->gl_info;
3755
3756 args->tessellator_output_primitive = hull_shader->u.hs.tessellator_output_primitive;
3757 args->tessellator_partitioning = hull_shader->u.hs.tessellator_partitioning;
3758
3759 args->output_count = geometry_shader ? geometry_shader->limits->packed_input
3760 : pixel_shader ? pixel_shader->limits->packed_input : shader->limits->packed_output;
3761 args->next_shader_type = geometry_shader ? WINED3D_SHADER_TYPE_GEOMETRY : WINED3D_SHADER_TYPE_PIXEL;
3762
3763 args->render_offscreen = context->render_offscreen;
3764
3765 init_interpolation_compile_args(args->interpolation_mode,
3766 args->next_shader_type == WINED3D_SHADER_TYPE_PIXEL ? pixel_shader : NULL, gl_info);
3767
3768 args->padding = 0;
3769}
static int state
Definition: maze.c:121
#define NULL
Definition: types.h:112
static void init_interpolation_compile_args(DWORD *interpolation_args, const struct wined3d_shader *pixel_shader, const struct wined3d_gl_info *gl_info)
Definition: shader.c:3449
GLuint shader
Definition: glext.h:6030
Definition: match.c:390
Definition: http.c:7252
const struct wined3d_shader_limits * limits
union wined3d_shader::@283 u
struct wined3d_hull_shader hs
@ WINED3D_SHADER_TYPE_HULL
@ WINED3D_SHADER_TYPE_PIXEL
@ WINED3D_SHADER_TYPE_GEOMETRY

Referenced by set_glsl_shader_program().

◆ find_gs_compile_args()

void find_gs_compile_args ( const struct wined3d_state state,
const struct wined3d_shader shader,
struct gs_compile_args args,
const struct wined3d_context context 
)

Definition at line 3771 of file shader.c.

3773{
3774 const struct wined3d_shader *pixel_shader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
3775 const struct wined3d_gl_info *gl_info = context->gl_info;
3776
3777 args->output_count = pixel_shader ? pixel_shader->limits->packed_input : shader->limits->packed_output;
3778
3779 init_interpolation_compile_args(args->interpolation_mode, pixel_shader, gl_info);
3780}

Referenced by set_glsl_shader_program().

◆ find_ps_compile_args()

void find_ps_compile_args ( const struct wined3d_state state,
const struct wined3d_shader shader,
BOOL  position_transformed,
struct ps_compile_args args,
const struct wined3d_context context 
)

Definition at line 3782 of file shader.c.

3784{
3785 const struct wined3d_d3d_info *d3d_info = context->d3d_info;
3786 const struct wined3d_gl_info *gl_info = context->gl_info;
3787 const struct wined3d_texture *texture;
3788 unsigned int i;
3789
3790 memset(args, 0, sizeof(*args)); /* FIXME: Make sure all bits are set. */
3792 {
3793 static unsigned int warned = 0;
3794
3795 args->srgb_correction = 1;
3796 if (state->render_states[WINED3D_RS_ALPHABLENDENABLE] && !warned++)
3797 WARN("Blending into a sRGB render target with no GL_ARB_framebuffer_sRGB "
3798 "support, expect rendering artifacts.\n");
3799 }
3800
3801 if (shader->reg_maps.shader_version.major == 1
3802 && shader->reg_maps.shader_version.minor <= 3)
3803 {
3804 for (i = 0; i < shader->limits->sampler; ++i)
3805 {
3807
3809 {
3810 DWORD tex_transform = flags & ~WINED3D_TTFF_PROJECTED;
3811
3812 if (!state->shader[WINED3D_SHADER_TYPE_VERTEX])
3813 {
3814 enum wined3d_shader_resource_type resource_type = shader->reg_maps.resource_info[i].type;
3815 unsigned int j;
3816 unsigned int index = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX];
3817 DWORD max_valid = WINED3D_TTFF_COUNT4;
3818
3819 for (j = 0; j < state->vertex_declaration->element_count; ++j)
3820 {
3822 &state->vertex_declaration->elements[j];
3823
3825 && element->usage_idx == index)
3826 {
3827 max_valid = element->format->component_count;
3828 break;
3829 }
3830 }
3831 if (!tex_transform || tex_transform > max_valid)
3832 {
3833 WARN("Fixing up projected texture transform flags from %#x to %#x.\n",
3834 tex_transform, max_valid);
3835 tex_transform = max_valid;
3836 }
3837 if ((resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_1D && tex_transform > WINED3D_TTFF_COUNT1)
3838 || (resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_2D
3839 && tex_transform > WINED3D_TTFF_COUNT2)
3840 || (resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_3D
3841 && tex_transform > WINED3D_TTFF_COUNT3))
3842 tex_transform |= WINED3D_PSARGS_PROJECTED;
3843 else
3844 {
3845 WARN("Application requested projected texture with unsuitable texture coordinates.\n");
3846 WARN("(texture unit %u, transform flags %#x, sampler type %u).\n",
3847 i, tex_transform, resource_type);
3848 }
3849 }
3850 else
3852
3853 args->tex_transform |= tex_transform << i * WINED3D_PSARGS_TEXTRANSFORM_SHIFT;
3854 }
3855 }
3856 }
3857 if (shader->reg_maps.shader_version.major == 1
3858 && shader->reg_maps.shader_version.minor <= 4)
3859 {
3860 for (i = 0; i < shader->limits->sampler; ++i)
3861 {
3862 const struct wined3d_texture *texture = state->textures[i];
3863
3864 if (!shader->reg_maps.resource_info[i].type)
3865 continue;
3866
3867 /* Treat unbound textures as 2D. The dummy texture will provide
3868 * the proper sample value. The tex_types bitmap defaults to
3869 * 2D because of the memset. */
3870 if (!texture)
3871 continue;
3872
3873 switch (texture->target)
3874 {
3875 /* RECT textures are distinguished from 2D textures via np2_fixup */
3877 case GL_TEXTURE_2D:
3878 break;
3879
3880 case GL_TEXTURE_3D:
3882 break;
3883
3886 break;
3887 }
3888 }
3889 }
3890
3891 if (shader->reg_maps.shader_version.major >= 4)
3892 {
3893 /* In SM4+ we use dcl_sampler in order to determine if we should use shadow sampler. */
3894 args->shadow = 0;
3895 for (i = 0 ; i < MAX_FRAGMENT_SAMPLERS; ++i)
3896 args->color_fixup[i] = COLOR_FIXUP_IDENTITY;
3897 args->np2_fixup = 0;
3898 }
3899 else
3900 {
3901 for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
3902 {
3903 if (!shader->reg_maps.resource_info[i].type)
3904 continue;
3905
3906 texture = state->textures[i];
3907 if (!texture)
3908 {
3909 args->color_fixup[i] = COLOR_FIXUP_IDENTITY;
3910 continue;
3911 }
3912 if (can_use_texture_swizzle(gl_info, texture->resource.format))
3913 args->color_fixup[i] = COLOR_FIXUP_IDENTITY;
3914 else
3915 args->color_fixup[i] = texture->resource.format->color_fixup;
3916
3917 if (texture->resource.format_flags & WINED3DFMT_FLAG_SHADOW)
3918 args->shadow |= 1u << i;
3919
3920 /* Flag samplers that need NP2 texcoord fixup. */
3922 args->np2_fixup |= (1u << i);
3923 }
3924 }
3925
3926 if (shader->reg_maps.shader_version.major >= 3)
3927 {
3928 if (position_transformed)
3929 args->vp_mode = pretransformed;
3930 else if (use_vs(state))
3931 args->vp_mode = vertexshader;
3932 else
3933 args->vp_mode = fixedfunction;
3935 }
3936 else
3937 {
3938 args->vp_mode = vertexshader;
3939 if (state->render_states[WINED3D_RS_FOGENABLE])
3940 {
3941 switch (state->render_states[WINED3D_RS_FOGTABLEMODE])
3942 {
3943 case WINED3D_FOG_NONE:
3944 if (position_transformed || use_vs(state))
3945 {
3947 break;
3948 }
3949
3950 switch (state->render_states[WINED3D_RS_FOGVERTEXMODE])
3951 {
3952 case WINED3D_FOG_NONE: /* Fall through. */
3954 case WINED3D_FOG_EXP: args->fog = WINED3D_FFP_PS_FOG_EXP; break;
3955 case WINED3D_FOG_EXP2: args->fog = WINED3D_FFP_PS_FOG_EXP2; break;
3956 }
3957 break;
3958
3960 case WINED3D_FOG_EXP: args->fog = WINED3D_FFP_PS_FOG_EXP; break;
3961 case WINED3D_FOG_EXP2: args->fog = WINED3D_FFP_PS_FOG_EXP2; break;
3962 }
3963 }
3964 else
3965 {
3967 }
3968 }
3969
3970 if (context->d3d_info->limits.varying_count < wined3d_max_compat_varyings(context->gl_info))
3971 {
3972 const struct wined3d_shader *vs = state->shader[WINED3D_SHADER_TYPE_VERTEX];
3973
3974 args->texcoords_initialized = 0;
3975 for (i = 0; i < MAX_TEXTURES; ++i)
3976 {
3977 if (vs)
3978 {
3979 if (state->shader[WINED3D_SHADER_TYPE_VERTEX]->reg_maps.output_registers & (1u << i))
3980 args->texcoords_initialized |= 1u << i;
3981 }
3982 else
3983 {
3984 const struct wined3d_stream_info *si = &context->stream_info;
3985 unsigned int coord_idx = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX];
3986
3987 if ((state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX] >> WINED3D_FFP_TCI_SHIFT)
3989 || (coord_idx < MAX_TEXTURES && (si->use_map & (1u << (WINED3D_FFP_TEXCOORD0 + coord_idx)))))
3990 args->texcoords_initialized |= 1u << i;
3991 }
3992 }
3993 }
3994 else
3995 {
3996 args->texcoords_initialized = (1u << MAX_TEXTURES) - 1;
3997 }
3998
3999 args->pointsprite = state->render_states[WINED3D_RS_POINTSPRITEENABLE]
4000 && state->gl_primitive_type == GL_POINTS;
4001
4003 args->alpha_test_func = WINED3D_CMP_ALWAYS - 1;
4004 else
4005 args->alpha_test_func = (state->render_states[WINED3D_RS_ALPHATESTENABLE]
4007 : WINED3D_CMP_ALWAYS) - 1;
4008
4009 if (d3d_info->emulated_flatshading)
4010 args->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT;
4011
4012 args->render_offscreen = shader->reg_maps.vpos && gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS]
4013 ? context->render_offscreen : 0;
4014
4015 args->dual_source_blend = wined3d_dualblend_enabled(state, gl_info);
4016}
#define WARN(fmt,...)
Definition: precomp.h:61
unsigned int wined3d_max_compat_varyings(const struct wined3d_gl_info *gl_info)
Definition: utils.c:5744
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GL_TEXTURE_3D
Definition: gl.h:1515
#define GL_POINTS
Definition: gl.h:190
#define GL_TEXTURE_2D
Definition: gl.h:645
GLenum GLuint texture
Definition: glext.h:6295
GLuint index
Definition: glext.h:6031
#define GL_TEXTURE_CUBE_MAP_ARB
Definition: glext.h:1230
GLbitfield flags
Definition: glext.h:7161
#define GL_TEXTURE_RECTANGLE_ARB
Definition: glext.h:1614
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
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
static vector_t * vs
Definition: server.c:127
#define memset(x, y, z)
Definition: compat.h:39
BOOL supported[WINED3D_GL_EXT_COUNT]
@ WINED3D_SHADE_FLAT
Definition: wined3d.h:479
@ WINED3D_FOG_LINEAR
Definition: wined3d.h:474
@ WINED3D_FOG_EXP
Definition: wined3d.h:472
@ WINED3D_FOG_NONE
Definition: wined3d.h:471
@ WINED3D_FOG_EXP2
Definition: wined3d.h:473
@ WINED3D_DECL_USAGE_TEXCOORD
Definition: wined3d.h:791
@ WINED3D_RS_SHADEMODE
Definition: wined3d.h:271
@ WINED3D_RS_ALPHABLENDENABLE
Definition: wined3d.h:286
@ WINED3D_RS_FOGTABLEMODE
Definition: wined3d.h:294
@ WINED3D_RS_FOGENABLE
Definition: wined3d.h:287
@ WINED3D_RS_POINTSPRITEENABLE
Definition: wined3d.h:341
@ WINED3D_RS_FOGVERTEXMODE
Definition: wined3d.h:327
@ WINED3D_RS_ALPHATESTENABLE
Definition: wined3d.h:277
@ WINED3D_RS_ALPHAFUNC
Definition: wined3d.h:284
@ WINED3D_TSS_TEXCOORD_INDEX
Definition: wined3d.h:585
@ WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
Definition: wined3d.h:588
@ WINED3D_CMP_ALWAYS
Definition: wined3d.h:459
@ WINED3D_TTFF_COUNT2
Definition: wined3d.h:601
@ WINED3D_TTFF_COUNT4
Definition: wined3d.h:603
@ WINED3D_TTFF_COUNT3
Definition: wined3d.h:602
@ WINED3D_TTFF_COUNT1
Definition: wined3d.h:600
@ WINED3D_TTFF_PROJECTED
Definition: wined3d.h:604
@ ARB_FRAMEBUFFER_SRGB
Definition: wined3d_gl.h:74
@ ARB_FRAGMENT_COORD_CONVENTIONS
Definition: wined3d_gl.h:68
@ WINED3D_GL_LEGACY_CONTEXT
Definition: wined3d_gl.h:213
#define MAX_FRAGMENT_SAMPLERS
#define WINED3D_PSARGS_PROJECTED
@ WINED3D_FFP_TEXCOORD0
#define WINED3D_FFP_TCI_SHIFT
#define WINED3DFMT_FLAG_SHADOW
static BOOL use_vs(const struct wined3d_state *state)
#define WINED3D_PSARGS_TEXTRANSFORM_SHIFT
#define WINED3D_TEXTURE_POW2_MAT_IDENT
static BOOL wined3d_dualblend_enabled(const struct wined3d_state *state, const struct wined3d_gl_info *gl_info)
#define WINED3D_FFP_TCI_MASK
wined3d_shader_resource_type
@ WINED3D_SHADER_RESOURCE_TEXTURE_3D
@ WINED3D_SHADER_RESOURCE_TEXTURE_2D
@ WINED3D_SHADER_RESOURCE_TEXTURE_1D
static enum wined3d_cmp_func wined3d_sanitize_cmp_func(enum wined3d_cmp_func func)
#define MAX_TEXTURES
static const struct color_fixup_desc COLOR_FIXUP_IDENTITY
static BOOL needs_srgb_write(const struct wined3d_context *context, const struct wined3d_state *state, const struct wined3d_fb_state *fb)
#define WINED3D_PSARGS_TEXTYPE_SHIFT
@ WINED3D_SHADER_TYPE_VERTEX
@ WINED3D_SHADER_TEX_3D
@ WINED3D_SHADER_TEX_CUBE
@ WINED3D_FFP_PS_FOG_EXP
@ WINED3D_FFP_PS_FOG_OFF
@ WINED3D_FFP_PS_FOG_EXP2
@ WINED3D_FFP_PS_FOG_LINEAR
@ pretransformed
@ vertexshader
@ fixedfunction
static BOOL can_use_texture_swizzle(const struct wined3d_gl_info *gl_info, const struct wined3d_format *format)

Referenced by find_arb_ps_compile_args(), and set_glsl_shader_program().

◆ find_vs_compile_args()

void find_vs_compile_args ( const struct wined3d_state state,
const struct wined3d_shader shader,
WORD  swizzle_map,
struct vs_compile_args args,
const struct wined3d_context context 
)

Definition at line 3463 of file shader.c.

3465{
3466 const struct wined3d_shader *geometry_shader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY];
3467 const struct wined3d_shader *pixel_shader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
3468 const struct wined3d_shader *hull_shader = state->shader[WINED3D_SHADER_TYPE_HULL];
3469 const struct wined3d_d3d_info *d3d_info = context->d3d_info;
3470 const struct wined3d_gl_info *gl_info = context->gl_info;
3471
3472 args->fog_src = state->render_states[WINED3D_RS_FOGTABLEMODE]
3474 args->clip_enabled = state->render_states[WINED3D_RS_CLIPPING]
3475 && state->render_states[WINED3D_RS_CLIPPLANEENABLE];
3476 args->point_size = state->gl_primitive_type == GL_POINTS;
3477 args->per_vertex_point_size = shader->reg_maps.point_size;
3478 args->next_shader_type = hull_shader? WINED3D_SHADER_TYPE_HULL
3480 if (shader->reg_maps.shader_version.major >= 4)
3481 args->next_shader_input_count = hull_shader ? hull_shader->limits->packed_input
3482 : geometry_shader ? geometry_shader->limits->packed_input
3483 : pixel_shader ? pixel_shader->limits->packed_input : 0;
3484 else
3485 args->next_shader_input_count = 0;
3486 args->swizzle_map = swizzle_map;
3487 if (d3d_info->emulated_flatshading)
3488 args->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT;
3489 else
3490 args->flatshading = 0;
3491
3492 init_interpolation_compile_args(args->interpolation_mode,
3493 args->next_shader_type == WINED3D_SHADER_TYPE_PIXEL ? pixel_shader : NULL, gl_info);
3494}
@ WINED3D_RS_CLIPPLANEENABLE
Definition: wined3d.h:337
@ WINED3D_RS_CLIPPING
Definition: wined3d.h:323
@ VS_FOG_COORD
@ VS_FOG_Z

Referenced by find_arb_vs_compile_args(), and set_glsl_shader_program().

◆ geometry_shader_init()

static HRESULT geometry_shader_init ( struct wined3d_shader shader,
struct wined3d_device device,
const struct wined3d_shader_desc desc,
const struct wined3d_stream_output_desc so_desc,
void parent,
const struct wined3d_parent_ops parent_ops 
)
static

Definition at line 3722 of file shader.c.

3725{
3726 struct wined3d_stream_output_element *elements = NULL;
3727 HRESULT hr;
3728
3729 if (so_desc && !(elements = heap_calloc(so_desc->element_count, sizeof(*elements))))
3730 return E_OUTOFMEMORY;
3731
3733 {
3734 heap_free(elements);
3735 return hr;
3736 }
3737
3738 if (so_desc)
3739 {
3740 shader->u.gs.so_desc = *so_desc;
3741 shader->u.gs.so_desc.elements = elements;
3742 memcpy(elements, so_desc->elements, so_desc->element_count * sizeof(*elements));
3743 }
3744
3745 return WINED3D_OK;
3746}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static HRESULT shader_init(struct wined3d_shader *shader, struct wined3d_device *device, const struct wined3d_shader_desc *desc, DWORD float_const_count, enum wined3d_shader_type type, void *parent, const struct wined3d_parent_ops *parent_ops)
Definition: shader.c:3582
r parent
Definition: btrfs.c:3010
#define FAILED(hr)
Definition: intsafe.h:51
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const WCHAR desc[]
Definition: protectdata.c:36
static void * heap_calloc(SIZE_T count, SIZE_T size)
Definition: heap.h:49
HRESULT hr
Definition: shlfolder.c:183
Definition: devices.h:37
struct wined3d_stream_output_element * elements
Definition: wined3d.h:2071
unsigned int element_count
Definition: wined3d.h:2072
#define WINED3D_OK
Definition: wined3d.h:37

Referenced by wined3d_shader_create_gs().

◆ get_instr_extra_regcount()

static unsigned int get_instr_extra_regcount ( enum WINED3D_SHADER_INSTRUCTION_HANDLER  instr,
unsigned int  param 
)
static

Definition at line 857 of file shader.c.

858{
859 switch (instr)
860 {
861 case WINED3DSIH_M4x4:
862 case WINED3DSIH_M3x4:
863 return param == 1 ? 3 : 0;
864
865 case WINED3DSIH_M4x3:
866 case WINED3DSIH_M3x3:
867 return param == 1 ? 2 : 0;
868
869 case WINED3DSIH_M3x2:
870 return param == 1 ? 1 : 0;
871
872 default:
873 return 0;
874 }
875}
GLfloat param
Definition: glext.h:5796
@ WINED3DSIH_M3x3
@ WINED3DSIH_M3x4
@ WINED3DSIH_M3x2
@ WINED3DSIH_M4x3
@ WINED3DSIH_M4x4

Referenced by shader_get_registers_used().

◆ init_interpolation_compile_args()

static void init_interpolation_compile_args ( DWORD interpolation_args,
const struct wined3d_shader pixel_shader,
const struct wined3d_gl_info gl_info 
)
static

Definition at line 3449 of file shader.c.

3451{
3453 || !pixel_shader || pixel_shader->reg_maps.shader_version.major < 4)
3454 {
3455 memset(interpolation_args, 0, sizeof(pixel_shader->u.ps.interpolation_mode));
3456 return;
3457 }
3458
3459 memcpy(interpolation_args, pixel_shader->u.ps.interpolation_mode,
3460 sizeof(pixel_shader->u.ps.interpolation_mode));
3461}
struct wined3d_pixel_shader ps
struct wined3d_shader_reg_maps reg_maps
static BOOL needs_interpolation_qualifiers_for_shader_outputs(const struct wined3d_gl_info *gl_info)

Referenced by find_ds_compile_args(), find_gs_compile_args(), and find_vs_compile_args().

◆ match_usage()

static BOOL match_usage ( BYTE  usage1,
BYTE  usage_idx1,
BYTE  usage2,
BYTE  usage_idx2 
)
static

Definition at line 3496 of file shader.c.

3497{
3498 if (usage_idx1 != usage_idx2)
3499 return FALSE;
3500 if (usage1 == usage2)
3501 return TRUE;
3503 return TRUE;
3505 return TRUE;
3506
3507 return FALSE;
3508}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ WINED3D_DECL_USAGE_POSITION
Definition: wined3d.h:786
@ WINED3D_DECL_USAGE_POSITIONT
Definition: wined3d.h:795

Referenced by vshader_get_input().

◆ pixel_shader_init()

static HRESULT pixel_shader_init ( struct wined3d_shader shader,
struct wined3d_device device,
const struct wined3d_shader_desc desc,
void parent,
const struct wined3d_parent_ops parent_ops 
)
static

Definition at line 4018 of file shader.c.

4020{
4021 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
4022 unsigned int i, highest_reg_used = 0, num_regs_used = 0;
4023 HRESULT hr;
4024
4025 if (FAILED(hr = shader_init(shader, device, desc, device->adapter->d3d_info.limits.ps_uniform_count,
4026 WINED3D_SHADER_TYPE_PIXEL, parent, parent_ops)))
4027 return hr;
4028
4029 for (i = 0; i < MAX_REG_INPUT; ++i)
4030 {
4031 if (shader->u.ps.input_reg_used & (1u << i))
4032 {
4033 ++num_regs_used;
4034 highest_reg_used = i;
4035 }
4036 }
4037
4038 /* Don't do any register mapping magic if it is not needed, or if we can't
4039 * achieve anything anyway */
4040 if (highest_reg_used < (gl_info->limits.glsl_varyings / 4)
4041 || num_regs_used > (gl_info->limits.glsl_varyings / 4)
4042 || shader->reg_maps.shader_version.major >= 4)
4043 {
4044 if (num_regs_used > (gl_info->limits.glsl_varyings / 4))
4045 {
4046 /* This happens with relative addressing. The input mapper function
4047 * warns about this if the higher registers are declared too, so
4048 * don't write a FIXME here */
4049 WARN("More varying registers used than supported\n");
4050 }
4051
4052 for (i = 0; i < MAX_REG_INPUT; ++i)
4053 {
4054 shader->u.ps.input_reg_map[i] = i;
4055 }
4056
4057 shader->u.ps.declared_in_count = highest_reg_used + 1;
4058 }
4059 else
4060 {
4061 shader->u.ps.declared_in_count = 0;
4062 for (i = 0; i < MAX_REG_INPUT; ++i)
4063 {
4064 if (shader->u.ps.input_reg_used & (1u << i))
4065 shader->u.ps.input_reg_map[i] = shader->u.ps.declared_in_count++;
4066 else shader->u.ps.input_reg_map[i] = ~0U;
4067 }
4068 }
4069
4070 return WINED3D_OK;
4071}
#define U(x)
Definition: wordpad.c:45
struct wined3d_gl_limits limits
#define MAX_REG_INPUT

Referenced by wined3d_shader_create_ps().

◆ pixelshader_update_resource_types()

void pixelshader_update_resource_types ( struct wined3d_shader shader,
WORD  tex_types 
)

Definition at line 4073 of file shader.c.

4074{
4075 struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
4076 struct wined3d_shader_resource_info *resource_info = reg_maps->resource_info;
4077 unsigned int i;
4078
4079 if (reg_maps->shader_version.major != 1) return;
4080
4081 for (i = 0; i < shader->limits->sampler; ++i)
4082 {
4083 /* We don't sample from this sampler. */
4084 if (!resource_info[i].type)
4085 continue;
4086
4088 {
4090 resource_info[i].type = WINED3D_SHADER_RESOURCE_TEXTURE_2D;
4091 break;
4092
4094 resource_info[i].type = WINED3D_SHADER_RESOURCE_TEXTURE_3D;
4095 break;
4096
4099 break;
4100 }
4101 }
4102}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
struct wined3d_shader_version shader_version
struct wined3d_shader_resource_info resource_info[MAX_SHADER_RESOURCE_VIEWS]
enum wined3d_shader_resource_type type
#define WINED3D_PSARGS_TEXTYPE_MASK
@ WINED3D_SHADER_RESOURCE_TEXTURE_CUBE
@ WINED3D_SHADER_TEX_2D

Referenced by find_arb_pshader(), and find_glsl_pshader().

◆ shader_addline()

int shader_addline ( struct wined3d_string_buffer buffer,
const char format,
  ... 
)

Definition at line 478 of file shader.c.

479{
481 int ret;
482
483 for (;;)
484 {
487 va_end(args);
488 if (!ret)
489 return ret;
491 return -1;
492 }
493}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
int shader_vaddline(struct wined3d_string_buffer *buffer, const char *format, va_list args)
Definition: shader.c:464
BOOL string_buffer_resize(struct wined3d_string_buffer *buffer, int rc)
Definition: shader.c:446
GLuint buffer
Definition: glext.h:5915
#define args
Definition: format.c:66
Definition: format.c:58
int ret

Referenced by arbfp_add_linear_fog(), arbfp_add_sRGB_correction(), arbfp_gen_plain_shader(), gen_arbfp_ffp_shader(), gen_color_correction(), gen_ffp_instr(), gen_nv12_read(), gen_p8_shader(), gen_planar_yuv_read(), gen_yuv_shader(), gen_yv12_read(), get_argreg(), PRINTF_ATTR(), pshader_hw_bem(), pshader_hw_cmp(), pshader_hw_cnd(), pshader_hw_dp2add(), pshader_hw_tex(), pshader_hw_texbem(), pshader_hw_texcoord(), pshader_hw_texdepth(), pshader_hw_texdp3(), pshader_hw_texdp3tex(), pshader_hw_texkill(), pshader_hw_texm3x2depth(), pshader_hw_texm3x2pad(), pshader_hw_texm3x2tex(), pshader_hw_texm3x3(), pshader_hw_texm3x3pad(), pshader_hw_texm3x3spec(), pshader_hw_texm3x3tex(), pshader_hw_texm3x3vspec(), pshader_hw_texreg2ar(), pshader_hw_texreg2gb(), shader_arb_add_instruction_modifiers(), shader_arb_append_imm_vec4(), shader_arb_generate_pshader(), shader_arb_generate_vshader(), shader_arb_get_src_param(), shader_arb_handle_instruction(), shader_arb_request_a0(), shader_dump_decl_usage(), shader_dump_dst_param(), shader_dump_global_flags(), shader_dump_ins_modifiers(), shader_dump_interpolation_mode(), shader_dump_primitive_type(), shader_dump_register(), shader_dump_shader_input_sysval_semantic(), shader_dump_src_param(), shader_dump_sync_flags(), shader_dump_tessellator_domain(), shader_dump_tessellator_output_primitive(), shader_dump_tessellator_partitioning(), shader_dump_uav_flags(), shader_generate_arb_declarations(), shader_generate_glsl_declarations(), shader_glsl_add_instruction_modifiers(), shader_glsl_add_version_declaration(), shader_glsl_append_dst_ext(), shader_glsl_append_imm_ivec(), shader_glsl_append_imm_vec4(), shader_glsl_append_sampler_binding_qualifier(), shader_glsl_atomic(), shader_glsl_bem(), shader_glsl_binop(), shader_glsl_bitwise_op(), shader_glsl_break(), shader_glsl_breakc(), shader_glsl_bufinfo(), shader_glsl_call(), shader_glsl_callnz(), shader_glsl_case(), shader_glsl_cast(), shader_glsl_cnd(), shader_glsl_color_correction_ext(), shader_glsl_compare(), shader_glsl_conditional_move(), shader_glsl_continue(), shader_glsl_cross(), shader_glsl_cut(), shader_glsl_declare_generic_vertex_attribute(), shader_glsl_declare_shader_inputs(), shader_glsl_declare_shader_outputs(), shader_glsl_declare_typed_vertex_attribute(), shader_glsl_default(), shader_glsl_dot(), shader_glsl_dp2add(), shader_glsl_dst(), shader_glsl_else(), shader_glsl_emit(), shader_glsl_enable_extensions(), shader_glsl_end(), shader_glsl_expp(), shader_glsl_ffp_fragment_op(), shader_glsl_ffp_vertex_lighting(), shader_glsl_ffp_vertex_lighting_footer(), shader_glsl_fixup_position(), shader_glsl_float16(), shader_glsl_gather4(), shader_glsl_gen_sample_c_lz(), shader_glsl_generate_alpha_test(), shader_glsl_generate_clip_or_cull_distances(), shader_glsl_generate_compute_shader(), shader_glsl_generate_conditional_op(), shader_glsl_generate_default_control_point_phase(), shader_glsl_generate_domain_shader(), shader_glsl_generate_ds_epilogue(), shader_glsl_generate_ffp_fragment_shader(), shader_glsl_generate_ffp_vertex_shader(), shader_glsl_generate_fog_code(), shader_glsl_generate_geometry_shader(), shader_glsl_generate_hull_shader(), shader_glsl_generate_patch_constant_name(), shader_glsl_generate_patch_constant_setup(), shader_glsl_generate_ps_epilogue(), shader_glsl_generate_pshader(), shader_glsl_generate_shader_phase(), shader_glsl_generate_shader_phase_invocation(), shader_glsl_generate_sm4_output_setup(), shader_glsl_generate_srgb_write_correction(), shader_glsl_generate_stream_output_setup(), shader_glsl_generate_vs3_rasterizer_input_setup(), shader_glsl_generate_vs_epilogue(), shader_glsl_generate_vshader(), shader_glsl_get_ffp_fragment_op_arg(), shader_glsl_ifc(), shader_glsl_input_pack(), shader_glsl_label(), shader_glsl_ld_raw_structured(), shader_glsl_ld_uav(), shader_glsl_lit(), shader_glsl_loop(), shader_glsl_lrp(), shader_glsl_mad(), shader_glsl_map2gl(), shader_glsl_mov(), shader_glsl_mul_extended(), shader_glsl_nrm(), shader_glsl_pow(), shader_glsl_relop(), shader_glsl_rep(), shader_glsl_resinfo(), shader_glsl_ret(), shader_glsl_scalar_op(), shader_glsl_setup_sm3_rasterizer_input(), shader_glsl_setup_sm4_shader_output(), shader_glsl_setup_vs3_output(), shader_glsl_sgn(), shader_glsl_sincos(), shader_glsl_store_raw_structured(), shader_glsl_store_uav(), shader_glsl_swapc(), shader_glsl_switch(), shader_glsl_sync(), shader_glsl_texbem(), shader_glsl_texcoord(), shader_glsl_texdepth(), shader_glsl_texdp3(), shader_glsl_texkill(), shader_glsl_texm3x2depth(), shader_glsl_texm3x2pad(), shader_glsl_texm3x2tex(), shader_glsl_texm3x3(), shader_glsl_texm3x3pad(), shader_glsl_texm3x3spec(), shader_glsl_texm3x3tex(), shader_glsl_texm3x3vspec(), shader_glsl_uav_counter(), shader_glsl_udiv(), shader_glsl_unary_op(), shader_hw_break(), shader_hw_breakc(), shader_hw_call(), shader_hw_dsy(), shader_hw_else(), shader_hw_endif(), shader_hw_endloop(), shader_hw_endrep(), shader_hw_ifc(), shader_hw_label(), shader_hw_loop(), shader_hw_lrp(), shader_hw_map2gl(), shader_hw_mov(), shader_hw_nrm(), shader_hw_pow(), shader_hw_rep(), shader_hw_ret(), shader_hw_sample(), shader_hw_scalar_op(), shader_hw_sgn(), shader_hw_sincos(), shader_trace_init(), and vshader_add_footer().

◆ shader_calculate_clip_or_cull_distance_mask()

static HRESULT shader_calculate_clip_or_cull_distance_mask ( const struct wined3d_shader_signature_element e,
unsigned int mask 
)
static

Definition at line 959 of file shader.c.

961{
962 /* Clip and cull distances are packed in 4 component registers. 0 and 1 are
963 * the only allowed semantic indices.
964 */
965 if (e->semantic_idx >= MAX_CLIP_DISTANCES / 4)
966 {
967 *mask = 0;
968 WARN("Invalid clip/cull distance index %u.\n", e->semantic_idx);
970 }
971
972 *mask = (e->mask & WINED3DSP_WRITEMASK_ALL) << (4 * e->semantic_idx);
973 return WINED3D_OK;
974}
GLenum GLint GLuint mask
Definition: glext.h:6028
#define e
Definition: ke_i.h:82
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
#define WINED3DSP_WRITEMASK_ALL
#define MAX_CLIP_DISTANCES

Referenced by shader_get_registers_used().

◆ shader_cleanup()

static void shader_cleanup ( struct wined3d_shader shader)
static

Definition at line 3088 of file shader.c.

3089{
3090 if (shader->reg_maps.shader_version.type == WINED3D_SHADER_TYPE_HULL)
3091 {
3092 heap_free(shader->u.hs.phases.control_point);
3093 heap_free(shader->u.hs.phases.fork);
3094 heap_free(shader->u.hs.phases.join);
3095 }
3096 else if (shader->reg_maps.shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY)
3097 {
3098 heap_free(shader->u.gs.so_desc.elements);
3099 }
3100
3101 heap_free(shader->patch_constant_signature.elements);
3102 heap_free(shader->output_signature.elements);
3103 heap_free(shader->input_signature.elements);
3104 heap_free(shader->signature_strings);
3105 shader->device->shader_backend->shader_destroy(shader);
3106 shader_cleanup_reg_maps(&shader->reg_maps);
3107 heap_free(shader->function);
3108 shader_delete_constant_list(&shader->constantsF);
3109 shader_delete_constant_list(&shader->constantsB);
3110 shader_delete_constant_list(&shader->constantsI);
3111 list_remove(&shader->shader_list_entry);
3112
3113 if (shader->frontend && shader->frontend_data)
3114 shader->frontend->shader_free(shader->frontend_data);
3115}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static void shader_delete_constant_list(struct list *clist)
Definition: shader.c:583
static void shader_cleanup_reg_maps(struct wined3d_shader_reg_maps *reg_maps)
Definition: shader.c:1824

Referenced by shader_init(), and wined3d_shader_destroy_object().

◆ shader_cleanup_reg_maps()

static void shader_cleanup_reg_maps ( struct wined3d_shader_reg_maps reg_maps)
static

Definition at line 1824 of file shader.c.

1825{
1826 struct wined3d_shader_indexable_temp *reg, *reg_next;
1827
1828 heap_free(reg_maps->constf);
1829 heap_free(reg_maps->sampler_map.entries);
1830
1832 heap_free(reg);
1833 list_init(&reg_maps->indexable_temps);
1834
1835 heap_free(reg_maps->tgsm);
1836}
static void list_init(struct list_entry *head)
Definition: list.h:51
static int reg
Definition: i386-dis.c:1290
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
struct wined3d_shader_tgsm * tgsm
struct wined3d_shader_sampler_map sampler_map

Referenced by shader_cleanup().

◆ shader_delete_constant_list()

static void shader_delete_constant_list ( struct list clist)
static

Definition at line 583 of file shader.c.

584{
585 struct wined3d_shader_lconst *constant, *constant_next;
586
587 LIST_FOR_EACH_ENTRY_SAFE(constant, constant_next, clist, struct wined3d_shader_lconst, entry)
589 list_init(clist);
590}

Referenced by shader_cleanup().

◆ shader_dump_decl_usage()

static void shader_dump_decl_usage ( struct wined3d_string_buffer buffer,
const struct wined3d_shader_semantic semantic,
unsigned int  flags,
const struct wined3d_shader_version shader_version 
)
static

Definition at line 1992 of file shader.c.

1995{
1996 shader_addline(buffer, "dcl");
1997
1998 if (semantic->reg.reg.type == WINED3DSPR_SAMPLER)
1999 {
2000 switch (semantic->resource_type)
2001 {
2003 shader_addline(buffer, "_2d");
2004 break;
2005
2007 shader_addline(buffer, "_3d");
2008 break;
2009
2011 shader_addline(buffer, "_cube");
2012 break;
2013
2014 default:
2015 shader_addline(buffer, "_unknown_resource_type(%#x)", semantic->resource_type);
2016 break;
2017 }
2018 }
2019 else if (semantic->reg.reg.type == WINED3DSPR_RESOURCE || semantic->reg.reg.type == WINED3DSPR_UAV)
2020 {
2021 if (semantic->reg.reg.type == WINED3DSPR_RESOURCE)
2022 shader_addline(buffer, "_resource_");
2023 else
2024 shader_addline(buffer, "_uav_");
2025 switch (semantic->resource_type)
2026 {
2028 shader_addline(buffer, "buffer");
2029 break;
2030
2032 shader_addline(buffer, "texture1d");
2033 break;
2034
2036 shader_addline(buffer, "texture2d");
2037 break;
2038
2040 shader_addline(buffer, "texture2dms");
2041 break;
2042
2044 shader_addline(buffer, "texture3d");
2045 break;
2046
2048 shader_addline(buffer, "texturecube");
2049 break;
2050
2052 shader_addline(buffer, "texture1darray");
2053 break;
2054
2056 shader_addline(buffer, "texture2darray");
2057 break;
2058
2060 shader_addline(buffer, "texture2dmsarray");
2061 break;
2062
2064 shader_addline(buffer, "texturecubearray");
2065 break;
2066
2067 default:
2068 shader_addline(buffer, "unknown");
2069 break;
2070 }
2071 if (semantic->reg.reg.type == WINED3DSPR_UAV)
2073 switch (semantic->resource_data_type)
2074 {
2075 case WINED3D_DATA_FLOAT:
2076 shader_addline(buffer, " (float)");
2077 break;
2078
2079 case WINED3D_DATA_INT:
2080 shader_addline(buffer, " (int)");
2081 break;
2082
2083 case WINED3D_DATA_UINT:
2084 shader_addline(buffer, " (uint)");
2085 break;
2086
2087 case WINED3D_DATA_UNORM:
2088 shader_addline(buffer, " (unorm)");
2089 break;
2090
2091 case WINED3D_DATA_SNORM:
2092 shader_addline(buffer, " (snorm)");
2093 break;
2094
2095 default:
2096 shader_addline(buffer, " (unknown)");
2097 break;
2098 }
2099 }
2100 else
2101 {
2102 /* Pixel shaders 3.0 don't have usage semantics. */
2103 if (shader_version->major < 3 && shader_version->type == WINED3D_SHADER_TYPE_PIXEL)
2104 return;
2105 else
2106 shader_addline(buffer, "_");
2107
2108 switch (semantic->usage)
2109 {
2111 shader_addline(buffer, "position%u", semantic->usage_idx);
2112 break;
2113
2115 shader_addline(buffer, "blend");
2116 break;
2117
2119 shader_addline(buffer, "weight");
2120 break;
2121
2123 shader_addline(buffer, "normal%u", semantic->usage_idx);
2124 break;
2125
2127 shader_addline(buffer, "psize");
2128 break;
2129
2131 if (!semantic->usage_idx)
2132 shader_addline(buffer, "color");
2133 else
2134 shader_addline(buffer, "specular%u", (semantic->usage_idx - 1));
2135 break;
2136
2138 shader_addline(buffer, "texture%u", semantic->usage_idx);
2139 break;
2140
2142 shader_addline(buffer, "tangent");
2143 break;
2144
2146 shader_addline(buffer, "binormal");
2147 break;
2148
2150 shader_addline(buffer, "tessfactor");
2151 break;
2152
2154 shader_addline(buffer, "positionT%u", semantic->usage_idx);
2155 break;
2156
2158 shader_addline(buffer, "fog");
2159 break;
2160
2162 shader_addline(buffer, "depth");
2163 break;
2164
2166 shader_addline(buffer, "sample");
2167 break;
2168
2169 default:
2170 shader_addline(buffer, "<unknown_semantic(%#x)>", semantic->usage);
2171 FIXME("Unrecognised semantic usage %#x.\n", semantic->usage);
2172 }
2173 }
2174}
#define FIXME(fmt,...)
Definition: precomp.h:53
static void shader_dump_uav_flags(struct wined3d_string_buffer *buffer, DWORD uav_flags)
Definition: shader.c:1892
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:478
struct wined3d_shader_dst_param reg
enum wined3d_decl_usage usage
enum wined3d_data_type resource_data_type
enum wined3d_shader_resource_type resource_type
enum wined3d_shader_type type
@ WINED3D_DECL_USAGE_DEPTH
Definition: wined3d.h:798
@ WINED3D_DECL_USAGE_BLEND_INDICES
Definition: wined3d.h:788
@ WINED3D_DECL_USAGE_TESS_FACTOR
Definition: wined3d.h:794
@ WINED3D_DECL_USAGE_NORMAL
Definition: wined3d.h:789
@ WINED3D_DECL_USAGE_PSIZE
Definition: wined3d.h:790
@ WINED3D_DECL_USAGE_BLEND_WEIGHT
Definition: wined3d.h:787
@ WINED3D_DECL_USAGE_SAMPLE
Definition: wined3d.h:799
@ WINED3D_DECL_USAGE_BINORMAL
Definition: wined3d.h:793
@ WINED3D_DECL_USAGE_COLOR
Definition: wined3d.h:796
@ WINED3D_DECL_USAGE_TANGENT
Definition: wined3d.h:792
@ WINED3D_DECL_USAGE_FOG
Definition: wined3d.h:797
@ WINED3D_DATA_UINT
@ WINED3D_DATA_INT
@ WINED3D_DATA_SNORM
@ WINED3D_DATA_UNORM
@ WINED3D_DATA_FLOAT
@ WINED3D_SHADER_RESOURCE_BUFFER
@ WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY
@ WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY
@ WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY
@ WINED3D_SHADER_RESOURCE_TEXTURE_2DMS
@ WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY
@ WINED3DSPR_RESOURCE
@ WINED3DSPR_UAV
@ WINED3DSPR_SAMPLER

Referenced by shader_trace_init().

◆ shader_dump_dst_param()

static void shader_dump_dst_param ( struct wined3d_string_buffer buffer,
const struct wined3d_shader_dst_param param,
const struct wined3d_shader_version shader_version 
)
static

Definition at line 2471 of file shader.c.

2473{
2474 DWORD write_mask = param->write_mask;
2475
2476 shader_dump_register(buffer, &param->reg, shader_version);
2477
2478 if (write_mask && write_mask != WINED3DSP_WRITEMASK_ALL)
2479 {
2480 static const char write_mask_chars[] = "xyzw";
2481
2482 shader_addline(buffer, ".");
2483 if (write_mask & WINED3DSP_WRITEMASK_0)
2484 shader_addline(buffer, "%c", write_mask_chars[0]);
2485 if (write_mask & WINED3DSP_WRITEMASK_1)
2486 shader_addline(buffer, "%c", write_mask_chars[1]);
2487 if (write_mask & WINED3DSP_WRITEMASK_2)
2488 shader_addline(buffer, "%c", write_mask_chars[2]);
2489 if (write_mask & WINED3DSP_WRITEMASK_3)
2490 shader_addline(buffer, "%c", write_mask_chars[3]);
2491 }
2492}
static void shader_dump_register(struct wined3d_string_buffer *buffer, const struct wined3d_shader_register *reg, const struct wined3d_shader_version *shader_version)
Definition: shader.c:2176
#define WINED3DSP_WRITEMASK_0
#define WINED3DSP_WRITEMASK_3
#define WINED3DSP_WRITEMASK_2
#define WINED3DSP_WRITEMASK_1

Referenced by shader_trace_init().

◆ shader_dump_global_flags()

static void shader_dump_global_flags ( struct wined3d_string_buffer buffer,
DWORD  global_flags 
)
static

Definition at line 1847 of file shader.c.

1848{
1849 if (global_flags & WINED3DSGF_REFACTORING_ALLOWED)
1850 {
1851 shader_addline(buffer, "refactoringAllowed");
1852 global_flags &= ~WINED3DSGF_REFACTORING_ALLOWED;
1853 if (global_flags)
1854 shader_addline(buffer, " | ");
1855 }
1856
1857 if (global_flags & WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL)
1858 {
1859 shader_addline(buffer, "forceEarlyDepthStencil");
1860 global_flags &= ~WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL;
1861 if (global_flags)
1862 shader_addline(buffer, " | ");
1863 }
1864
1866 {
1867 shader_addline(buffer, "enableRawAndStructuredBuffers");
1868 global_flags &= ~WINED3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS;
1869 }
1870
1871 if (global_flags)
1872 shader_addline(buffer, "unknown_flags(%#x)", global_flags);
1873}
@ WINED3DSGF_REFACTORING_ALLOWED
@ WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL
@ WINED3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS

Referenced by shader_trace_init().

◆ shader_dump_ins_modifiers()

static void shader_dump_ins_modifiers ( struct wined3d_string_buffer buffer,
const struct wined3d_shader_dst_param dst 
)
static

Definition at line 2613 of file shader.c.

2615{
2616 DWORD mmask = dst->modifiers;
2617
2618 switch (dst->shift)
2619 {
2620 case 0: break;
2621 case 13: shader_addline(buffer, "_d8"); break;
2622 case 14: shader_addline(buffer, "_d4"); break;
2623 case 15: shader_addline(buffer, "_d2"); break;
2624 case 1: shader_addline(buffer, "_x2"); break;
2625 case 2: shader_addline(buffer, "_x4"); break;
2626 case 3: shader_addline(buffer, "_x8"); break;
2627 default: shader_addline(buffer, "_unhandled_shift(%d)", dst->shift); break;
2628 }
2629
2630 if (mmask & WINED3DSPDM_SATURATE) shader_addline(buffer, "_sat");
2632 if (mmask & WINED3DSPDM_MSAMPCENTROID) shader_addline(buffer, "_centroid");
2633
2635 if (mmask) FIXME("Unrecognised modifier %#x.\n", mmask);
2636}
GLenum GLenum dst
Definition: glext.h:6340
@ WINED3DSPDM_MSAMPCENTROID
@ WINED3DSPDM_PARTIALPRECISION
@ WINED3DSPDM_SATURATE

Referenced by shader_trace_init().

◆ shader_dump_interpolation_mode()

static void shader_dump_interpolation_mode ( struct wined3d_string_buffer buffer,
enum wined3d_shader_interpolation_mode  interpolation_mode 
)
static

Definition at line 2685 of file shader.c.

2687{
2688 switch (interpolation_mode)
2689 {
2691 shader_addline(buffer, "constant");
2692 break;
2693 case WINED3DSIM_LINEAR:
2694 shader_addline(buffer, "linear");
2695 break;
2697 shader_addline(buffer, "linear centroid");
2698 break;
2700 shader_addline(buffer, "linear noperspective");
2701 break;
2703 shader_addline(buffer, "linear sample");
2704 break;
2706 shader_addline(buffer, "linear noperspective centroid");
2707 break;
2709 shader_addline(buffer, "linear noperspective sample");
2710 break;
2711 default:
2712 shader_addline(buffer, "<unrecognized_interpolation_mode %#x>", interpolation_mode);
2713 break;
2714 }
2715}
@ WINED3DSIM_LINEAR_CENTROID
@ WINED3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE
@ WINED3DSIM_LINEAR
@ WINED3DSIM_LINEAR_NOPERSPECTIVE
@ WINED3DSIM_LINEAR_NOPERSPECTIVE_CENTROID
@ WINED3DSIM_LINEAR_SAMPLE
@ WINED3DSIM_CONSTANT

Referenced by shader_trace_init().

◆ shader_dump_primitive_type()

static void shader_dump_primitive_type ( struct wined3d_string_buffer buffer,
const struct wined3d_shader_primitive_type primitive_type 
)
static

Definition at line 2638 of file shader.c.

2640{
2641 switch (primitive_type->type)
2642 {
2644 shader_addline(buffer, "undefined");
2645 break;
2647 shader_addline(buffer, "pointlist");
2648 break;
2650 shader_addline(buffer, "linelist");
2651 break;
2653 shader_addline(buffer, "linestrip");
2654 break;
2656 shader_addline(buffer, "trianglelist");
2657 break;
2659 shader_addline(buffer, "trianglestrip");
2660 break;
2662 shader_addline(buffer, "trianglefan");
2663 break;
2665 shader_addline(buffer, "linelist_adj");
2666 break;
2668 shader_addline(buffer, "linestrip_adj");
2669 break;
2671 shader_addline(buffer, "trianglelist_adj");
2672 break;
2674 shader_addline(buffer, "trianglestrip_adj");
2675 break;
2676 case WINED3D_PT_PATCH:
2677 shader_addline(buffer, "patch%u", primitive_type->patch_vertex_count);
2678 break;
2679 default:
2680 shader_addline(buffer, "<unrecognized_primitive_type %#x>", primitive_type->type);
2681 break;
2682 }
2683}
enum wined3d_primitive_type type
@ WINED3D_PT_LINESTRIP_ADJ
Definition: wined3d.h:79
@ WINED3D_PT_LINELIST
Definition: wined3d.h:73
@ WINED3D_PT_UNDEFINED
Definition: wined3d.h:71
@ WINED3D_PT_PATCH
Definition: wined3d.h:82
@ WINED3D_PT_POINTLIST
Definition: wined3d.h:72
@ WINED3D_PT_TRIANGLELIST_ADJ
Definition: wined3d.h:80
@ WINED3D_PT_LINELIST_ADJ
Definition: wined3d.h:78
@ WINED3D_PT_TRIANGLESTRIP_ADJ
Definition: wined3d.h:81
@ WINED3D_PT_TRIANGLESTRIP
Definition: wined3d.h:76
@ WINED3D_PT_LINESTRIP
Definition: wined3d.h:74
@ WINED3D_PT_TRIANGLELIST
Definition: wined3d.h:75
@ WINED3D_PT_TRIANGLEFAN
Definition: wined3d.h:77

Referenced by shader_trace_init().

◆ shader_dump_register()

static void shader_dump_register ( struct wined3d_string_buffer buffer,
const struct wined3d_shader_register reg,
const struct wined3d_shader_version shader_version 
)
static

Definition at line 2176 of file shader.c.

2178{
2179 static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"};
2180 static const char * const misctype_reg_names[] = {"vPos", "vFace"};
2181 UINT offset = reg->idx[0].offset;
2182
2183 switch (reg->type)
2184 {
2185 case WINED3DSPR_TEMP:
2186 shader_addline(buffer, "r");
2187 break;
2188
2189 case WINED3DSPR_INPUT:
2190 shader_addline(buffer, "v");
2191 break;
2192
2193 case WINED3DSPR_CONST:
2194 case WINED3DSPR_CONST2:
2195 case WINED3DSPR_CONST3:
2196 case WINED3DSPR_CONST4:
2197 shader_addline(buffer, "c");
2199 break;
2200
2201 case WINED3DSPR_TEXTURE: /* vs: case WINED3DSPR_ADDR */
2202 shader_addline(buffer, "%c", shader_version->type == WINED3D_SHADER_TYPE_PIXEL ? 't' : 'a');
2203 break;
2204
2205 case WINED3DSPR_RASTOUT:
2206 shader_addline(buffer, "%s", rastout_reg_names[offset]);
2207 break;
2208
2210 shader_addline(buffer, "oC");
2211 break;
2212
2214 shader_addline(buffer, "oDepth");
2215 break;
2216
2218 shader_addline(buffer, "oDepthGE");
2219 break;
2220
2222 shader_addline(buffer, "oDepthLE");
2223 break;
2224
2225 case WINED3DSPR_ATTROUT:
2226 shader_addline(buffer, "oD");
2227 break;
2228
2230 /* Vertex shaders >= 3.0 use general purpose output registers
2231 * (WINED3DSPR_OUTPUT), which can include an address token. */
2232 if (shader_version->major >= 3)
2233 shader_addline(buffer, "o");
2234 else
2235 shader_addline(buffer, "oT");
2236 break;
2237
2239 shader_addline(buffer, "i");
2240 break;
2241
2243 shader_addline(buffer, "b");
2244 break;
2245
2246 case WINED3DSPR_LABEL:
2247 shader_addline(buffer, "l");
2248 break;
2249
2250 case WINED3DSPR_LOOP:
2251 shader_addline(buffer, "aL");
2252 break;
2253
2254 case WINED3DSPR_SAMPLER:
2255 shader_addline(buffer, "s");
2256 break;
2257
2259 if (offset > 1)
2260 {
2261 FIXME("Unhandled misctype register %u.\n", offset);
2262 shader_addline(buffer, "<unhandled misctype %#x>", offset);
2263 }
2264 else
2265 {
2266 shader_addline(buffer, "%s", misctype_reg_names[offset]);
2267 }
2268 break;
2269
2271 shader_addline(buffer, "p");
2272 break;
2273
2275 shader_addline(buffer, "l");
2276 break;
2277
2279 shader_addline(buffer, "cb");
2280 break;
2281
2283 shader_addline(buffer, "icb");
2284 break;
2285
2286 case WINED3DSPR_PRIMID:
2287 shader_addline(buffer, "primID");
2288 break;
2289
2290 case WINED3DSPR_NULL:
2291 shader_addline(buffer, "null");
2292 break;
2293
2295 shader_addline(buffer, "t");
2296 break;
2297
2298 case WINED3DSPR_UAV:
2299 shader_addline(buffer, "u");
2300 break;
2301
2303 shader_addline(buffer, "vOutputControlPointID");
2304 break;
2305
2307 shader_addline(buffer, "vForkInstanceId");
2308 break;
2309
2311 shader_addline(buffer, "vJoinInstanceId");
2312 break;
2313
2315 shader_addline(buffer, "vicp");
2316 break;
2317
2319 shader_addline(buffer, "vocp");
2320 break;
2321
2323 shader_addline(buffer, "vpc");
2324 break;
2325
2327 shader_addline(buffer, "vDomainLocation");
2328 break;
2329
2331 shader_addline(buffer, "g");
2332 break;
2333
2335 shader_addline(buffer, "vThreadID");
2336 break;
2337
2339 shader_addline(buffer, "vThreadGroupID");
2340 break;
2341
2343 shader_addline(buffer, "vThreadIDInGroup");
2344 break;
2345
2347 shader_addline(buffer, "vThreadIDInGroupFlattened");
2348 break;
2349
2350 case WINED3DSPR_IDXTEMP:
2351 shader_addline(buffer, "x");
2352 break;
2353
2354 case WINED3DSPR_STREAM:
2355 shader_addline(buffer, "m");
2356 break;
2357
2359 shader_addline(buffer, "fb");
2360 break;
2361
2363 shader_addline(buffer, "fp");
2364 break;
2365
2367 shader_addline(buffer, "vCoverage");
2368 break;
2369
2371 shader_addline(buffer, "oMask");
2372 break;
2373
2375 shader_addline(buffer, "vGSInstanceID");
2376 break;
2377
2378 default:
2379 shader_addline(buffer, "<unhandled_rtype(%#x)>", reg->type);
2380 break;
2381 }
2382
2383 if (reg->type == WINED3DSPR_IMMCONST)
2384 {
2385 shader_addline(buffer, "(");
2386 switch (reg->immconst_type)
2387 {
2389 switch (reg->data_type)
2390 {
2391 case WINED3D_DATA_FLOAT:
2392 shader_addline(buffer, "%.8e", *(const float *)reg->u.immconst_data);
2393 break;
2394 case WINED3D_DATA_INT:
2395 shader_addline(buffer, "%d", reg->u.immconst_data[0]);
2396 break;
2399 case WINED3D_DATA_UINT:
2400 shader_addline(buffer, "%u", reg->u.immconst_data[0]);
2401 break;
2402 default:
2403 shader_addline(buffer, "<unhandled data type %#x>", reg->data_type);
2404 break;
2405 }
2406 break;
2407
2409 switch (reg->data_type)
2410 {
2411 case WINED3D_DATA_FLOAT:
2412 shader_addline(buffer, "%.8e, %.8e, %.8e, %.8e",
2413 *(const float *)&reg->u.immconst_data[0], *(const float *)&reg->u.immconst_data[1],
2414 *(const float *)&reg->u.immconst_data[2], *(const float *)&reg->u.immconst_data[3]);
2415 break;
2416 case WINED3D_DATA_INT:
2417 shader_addline(buffer, "%d, %d, %d, %d",
2418 reg->u.immconst_data[0], reg->u.immconst_data[1],
2419 reg->u.immconst_data[2], reg->u.immconst_data[3]);
2420 break;
2423 case WINED3D_DATA_UINT:
2424 shader_addline(buffer, "%u, %u, %u, %u",
2425 reg->u.immconst_data[0], reg->u.immconst_data[1],
2426 reg->u.immconst_data[2], reg->u.immconst_data[3]);
2427 break;
2428 default:
2429 shader_addline(buffer, "<unhandled data type %#x>", reg->data_type);
2430 break;
2431 }
2432 break;
2433
2434 default:
2435 shader_addline(buffer, "<unhandled immconst_type %#x>", reg->immconst_type);
2436 break;
2437 }
2438 shader_addline(buffer, ")");
2439 }
2440 else if (reg->type != WINED3DSPR_RASTOUT
2441 && reg->type != WINED3DSPR_MISCTYPE
2442 && reg->type != WINED3DSPR_NULL)
2443 {
2444 if (offset != ~0u)
2445 {
2446 shader_addline(buffer, "[");
2447 if (reg->idx[0].rel_addr)
2448 {
2449 shader_dump_src_param(buffer, reg->idx[0].rel_addr, shader_version);
2450 shader_addline(buffer, " + ");
2451 }
2452 shader_addline(buffer, "%u]", offset);
2453
2454 if (reg->idx[1].offset != ~0u)
2455 {
2456 shader_addline(buffer, "[");
2457 if (reg->idx[1].rel_addr)
2458 {
2459 shader_dump_src_param(buffer, reg->idx[1].rel_addr, shader_version);
2460 shader_addline(buffer, " + ");
2461 }
2462 shader_addline(buffer, "%u]", reg->idx[1].offset);
2463 }
2464 }
2465
2466 if (reg->type == WINED3DSPR_FUNCTIONPOINTER)
2467 shader_addline(buffer, "[%u]", reg->u.fp_body_idx);
2468 }
2469}
static unsigned int shader_get_float_offset(enum wined3d_shader_register_type register_type, UINT register_idx)
Definition: shader.c:569
static void shader_dump_src_param(struct wined3d_string_buffer *buffer, const struct wined3d_shader_src_param *param, const struct wined3d_shader_version *shader_version)
Definition: shader.c:2494
GLintptr offset
Definition: glext.h:5920
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
unsigned int UINT
Definition: ndis.h:50
@ WINED3D_DATA_SAMPLER
@ WINED3D_DATA_RESOURCE
@ WINED3DSPR_CONSTBOOL
@ WINED3DSPR_COLOROUT
@ WINED3DSPR_LOOP
@ WINED3DSPR_CONST
@ WINED3DSPR_PRIMID
@ WINED3DSPR_LOCALTHREADID
@ WINED3DSPR_FUNCTIONPOINTER
@ WINED3DSPR_CONST3
@ WINED3DSPR_IMMCONST
@ WINED3DSPR_OUTPOINTID
@ WINED3DSPR_OUTCONTROLPOINT
@ WINED3DSPR_INCONTROLPOINT
@ WINED3DSPR_TESSCOORD
@ WINED3DSPR_NULL
@ WINED3DSPR_CONSTINT
@ WINED3DSPR_GSINSTID
@ WINED3DSPR_ATTROUT
@ WINED3DSPR_CONST4
@ WINED3DSPR_THREADGROUPID
@ WINED3DSPR_LABEL
@ WINED3DSPR_JOININSTID
@ WINED3DSPR_DEPTHOUTGE
@ WINED3DSPR_CONSTBUFFER
@ WINED3DSPR_FUNCTIONBODY
@ WINED3DSPR_IDXTEMP
@ WINED3DSPR_RASTOUT
@ WINED3DSPR_CONST2
@ WINED3DSPR_STREAM
@ WINED3DSPR_PATCHCONST
@ WINED3DSPR_PREDICATE
@ WINED3DSPR_INPUT
@ WINED3DSPR_GROUPSHAREDMEM
@ WINED3DSPR_SAMPLEMASK
@ WINED3DSPR_TEMP
@ WINED3DSPR_DEPTHOUT
@ WINED3DSPR_TEXCRDOUT
@ WINED3DSPR_THREADID
@ WINED3DSPR_COVERAGE
@ WINED3DSPR_TEXTURE
@ WINED3DSPR_LOCALTHREADINDEX
@ WINED3DSPR_FORKINSTID
@ WINED3DSPR_DEPTHOUTLE
@ WINED3DSPR_MISCTYPE
@ WINED3DSPR_IMMCONSTBUFFER
@ WINED3D_IMMCONST_VEC4
@ WINED3D_IMMCONST_SCALAR

Referenced by shader_dump_dst_param(), and shader_dump_src_param().

◆ shader_dump_shader_input_sysval_semantic()

static void shader_dump_shader_input_sysval_semantic ( struct wined3d_string_buffer buffer,
enum wined3d_shader_input_sysval_semantic  semantic 
)
static

Definition at line 1975 of file shader.c.

1977{
1978 unsigned int i;
1979
1981 {
1983 {
1985 return;
1986 }
1987 }
1988
1989 shader_addline(buffer, "unknown_shader_input_sysval_semantic(%#x)", semantic);
1990}
const char * sysval_name
Definition: shader.c:303
static const struct @271 shader_input_sysval_semantic_names[]
enum wined3d_shader_input_sysval_semantic sysval_semantic
Definition: shader.c:302

Referenced by shader_trace_init().

◆ shader_dump_src_param()

static void shader_dump_src_param ( struct wined3d_string_buffer buffer,
const struct wined3d_shader_src_param param,
const struct wined3d_shader_version shader_version 
)
static

Definition at line 2494 of file shader.c.

2496{
2497 enum wined3d_shader_src_modifier src_modifier = param->modifiers;
2498 DWORD swizzle = param->swizzle;
2499
2500 if (src_modifier == WINED3DSPSM_NEG
2501 || src_modifier == WINED3DSPSM_BIASNEG
2502 || src_modifier == WINED3DSPSM_SIGNNEG
2503 || src_modifier == WINED3DSPSM_X2NEG
2504 || src_modifier == WINED3DSPSM_ABSNEG)
2505 shader_addline(buffer, "-");
2506 else if (src_modifier == WINED3DSPSM_COMP)
2507 shader_addline(buffer, "1-");
2508 else if (src_modifier == WINED3DSPSM_NOT)
2509 shader_addline(buffer, "!");
2510
2511 if (src_modifier == WINED3DSPSM_ABS || src_modifier == WINED3DSPSM_ABSNEG)
2512 shader_addline(buffer, "abs(");
2513
2514 shader_dump_register(buffer, &param->reg, shader_version);
2515
2516 switch (src_modifier)
2517 {
2518 case WINED3DSPSM_NONE: break;
2519 case WINED3DSPSM_NEG: break;
2520 case WINED3DSPSM_NOT: break;
2521 case WINED3DSPSM_BIAS: shader_addline(buffer, "_bias"); break;
2522 case WINED3DSPSM_BIASNEG: shader_addline(buffer, "_bias"); break;
2523 case WINED3DSPSM_SIGN: shader_addline(buffer, "_bx2"); break;
2524 case WINED3DSPSM_SIGNNEG: shader_addline(buffer, "_bx2"); break;
2525 case WINED3DSPSM_COMP: break;
2526 case WINED3DSPSM_X2: shader_addline(buffer, "_x2"); break;
2527 case WINED3DSPSM_X2NEG: shader_addline(buffer, "_x2"); break;
2528 case WINED3DSPSM_DZ: shader_addline(buffer, "_dz"); break;
2529 case WINED3DSPSM_DW: shader_addline(buffer, "_dw"); break;
2530 case WINED3DSPSM_ABSNEG: shader_addline(buffer, ")"); break;
2531 case WINED3DSPSM_ABS: shader_addline(buffer, ")"); break;
2532 default: shader_addline(buffer, "_unknown_modifier(%#x)", src_modifier);
2533 }
2534
2536 {
2537 static const char swizzle_chars[] = "xyzw";
2538 DWORD swizzle_x = swizzle & 0x03;
2539 DWORD swizzle_y = (swizzle >> 2) & 0x03;
2540 DWORD swizzle_z = (swizzle >> 4) & 0x03;
2541 DWORD swizzle_w = (swizzle >> 6) & 0x03;
2542
2543 if (swizzle_x == swizzle_y
2544 && swizzle_x == swizzle_z
2545 && swizzle_x == swizzle_w)
2546 {
2547 shader_addline(buffer, ".%c", swizzle_chars[swizzle_x]);
2548 }
2549 else
2550 {
2551 shader_addline(buffer, ".%c%c%c%c", swizzle_chars[swizzle_x], swizzle_chars[swizzle_y],
2552 swizzle_chars[swizzle_z], swizzle_chars[swizzle_w]);
2553 }
2554 }
2555}
GLuint GLenum swizzle
Definition: glext.h:9511
wined3d_shader_src_modifier
@ WINED3DSPSM_ABSNEG
@ WINED3DSPSM_X2NEG
@ WINED3DSPSM_BIAS
@ WINED3DSPSM_BIASNEG
@ WINED3DSPSM_COMP
@ WINED3DSPSM_ABS
@ WINED3DSPSM_NOT
@ WINED3DSPSM_SIGNNEG
@ WINED3DSPSM_DW
@ WINED3DSPSM_X2
@ WINED3DSPSM_SIGN
@ WINED3DSPSM_NONE
@ WINED3DSPSM_NEG
@ WINED3DSPSM_DZ
#define WINED3DSP_NOSWIZZLE

Referenced by shader_dump_register(), and shader_trace_init().

◆ shader_dump_sync_flags()

static void shader_dump_sync_flags ( struct wined3d_string_buffer buffer,
DWORD  sync_flags 
)
static

Definition at line 1875 of file shader.c.

1876{
1877 if (sync_flags & WINED3DSSF_GROUP_SHARED_MEMORY)
1878 {
1879 shader_addline(buffer, "_g");
1880 sync_flags &= ~WINED3DSSF_GROUP_SHARED_MEMORY;
1881 }
1882 if (sync_flags & WINED3DSSF_THREAD_GROUP)
1883 {
1884 shader_addline(buffer, "_t");
1885 sync_flags &= ~WINED3DSSF_THREAD_GROUP;
1886 }
1887
1888 if (sync_flags)
1889 shader_addline(buffer, "_unknown_flags(%#x)", sync_flags);
1890}
@ WINED3DSSF_THREAD_GROUP
@ WINED3DSSF_GROUP_SHARED_MEMORY

Referenced by shader_trace_init().

◆ shader_dump_tessellator_domain()

static void shader_dump_tessellator_domain ( struct wined3d_string_buffer buffer,
enum wined3d_tessellator_domain  domain 
)
static

Definition at line 1909 of file shader.c.

1911{
1912 switch (domain)
1913 {
1915 shader_addline(buffer, "line");
1916 break;
1918 shader_addline(buffer, "triangle");
1919 break;
1921 shader_addline(buffer, "quad");
1922 break;
1923 default:
1924 shader_addline(buffer, "unknown_tessellator_domain(%#x)", domain);
1925 break;
1926 }
1927}
Definition: cookie.c:42
@ WINED3D_TESSELLATOR_DOMAIN_TRIANGLE
@ WINED3D_TESSELLATOR_DOMAIN_QUAD
@ WINED3D_TESSELLATOR_DOMAIN_LINE

Referenced by shader_trace_init().

◆ shader_dump_tessellator_output_primitive()

static void shader_dump_tessellator_output_primitive ( struct wined3d_string_buffer buffer,
enum wined3d_tessellator_output_primitive  output_primitive 
)
static

Definition at line 1929 of file shader.c.

1931{
1932 switch (output_primitive)
1933 {
1935 shader_addline(buffer, "point");
1936 break;
1938 shader_addline(buffer, "line");
1939 break;
1941 shader_addline(buffer, "triangle_cw");
1942 break;
1944 shader_addline(buffer, "triangle_ccw");
1945 break;
1946 default:
1947 shader_addline(buffer, "unknown_tessellator_output_primitive(%#x)", output_primitive);
1948 break;
1949 }
1950}
@ WINED3D_TESSELLATOR_OUTPUT_POINT
@ WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CW
@ WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW
@ WINED3D_TESSELLATOR_OUTPUT_LINE

Referenced by shader_trace_init().

◆ shader_dump_tessellator_partitioning()

static void shader_dump_tessellator_partitioning ( struct wined3d_string_buffer buffer,
enum wined3d_tessellator_partitioning  partitioning 
)
static

Definition at line 1952 of file shader.c.

1954{
1955 switch (partitioning)
1956 {
1958 shader_addline(buffer, "integer");
1959 break;
1961 shader_addline(buffer, "pow2");
1962 break;
1964 shader_addline(buffer, "fractional_odd");
1965 break;
1967 shader_addline(buffer, "fractional_even");
1968 break;
1969 default:
1970 shader_addline(buffer, "unknown_tessellator_partitioning(%#x)", partitioning);
1971 break;
1972 }
1973}
@ WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD
@ WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN
@ WINED3D_TESSELLATOR_PARTITIONING_INTEGER
@ WINED3D_TESSELLATOR_PARTITIONING_POW2

Referenced by shader_trace_init().

◆ shader_dump_uav_flags()

static void shader_dump_uav_flags ( struct wined3d_string_buffer buffer,
DWORD  uav_flags 
)
static

Definition at line 1892 of file shader.c.

1893{
1894 if (uav_flags & WINED3DSUF_GLOBALLY_COHERENT)
1895 {
1896 shader_addline(buffer, "_glc");
1897 uav_flags &= ~WINED3DSUF_GLOBALLY_COHERENT;
1898 }
1900 {
1901 shader_addline(buffer, "_opc");
1902 uav_flags &= ~WINED3DSUF_ORDER_PRESERVING_COUNTER;
1903 }
1904
1905 if (uav_flags)
1906 shader_addline(buffer, "_unknown_flags(%#x)", uav_flags);
1907}
@ WINED3DSUF_ORDER_PRESERVING_COUNTER
@ WINED3DSUF_GLOBALLY_COHERENT

Referenced by shader_dump_decl_usage(), and shader_trace_init().

◆ shader_find_free_input_register()

unsigned int shader_find_free_input_register ( const struct wined3d_shader_reg_maps reg_maps,
unsigned int  max 
)

Definition at line 1838 of file shader.c.

1839{
1840 DWORD map = 1u << max;
1841 map |= map - 1;
1842 map &= reg_maps->shader_version.major < 3 ? ~reg_maps->texcoord : ~reg_maps->input_registers;
1843
1844 return wined3d_log2i(map);
1845}
Definition: _map.h:48
#define max(a, b)
Definition: svc.c:63
static unsigned int wined3d_log2i(unsigned int x)
Definition: wined3d.h:2759

Referenced by find_arb_pshader().

◆ shader_generate_code()

HRESULT shader_generate_code ( const struct wined3d_shader shader,
struct wined3d_string_buffer buffer,
const struct wined3d_shader_reg_maps reg_maps,
void backend_ctx,
const DWORD start,
const DWORD end 
)

Definition at line 2558 of file shader.c.

2561{
2562 struct wined3d_device *device = shader->device;
2563 const struct wined3d_shader_frontend *fe = shader->frontend;
2564 void *fe_data = shader->frontend_data;
2565 struct wined3d_shader_version shader_version;
2567 struct wined3d_shader_instruction ins;
2568 struct wined3d_shader_tex_mx tex_mx;
2570 const DWORD *ptr;
2571
2572 /* Initialize current parsing state. */
2573 tex_mx.current_row = 0;
2574 state.current_loop_depth = 0;
2575 state.current_loop_reg = 0;
2576 state.in_subroutine = FALSE;
2577
2578 ctx.shader = shader;
2579 ctx.gl_info = &device->adapter->gl_info;
2580 ctx.reg_maps = reg_maps;
2581 ctx.buffer = buffer;
2582 ctx.tex_mx = &tex_mx;
2583 ctx.state = &state;
2584 ctx.backend_data = backend_ctx;
2585 ins.ctx = &ctx;
2586
2587 fe->shader_read_header(fe_data, &ptr, &shader_version);
2588 if (start)
2589 ptr = start;
2590
2591 while (!fe->shader_is_end(fe_data, &ptr) && ptr != end)
2592 {
2593 /* Read opcode. */
2594 fe->shader_read_instruction(fe_data, &ptr, &ins);
2595
2596 /* Unknown opcode and its parameters. */
2597 if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
2598 {
2599 WARN("Encountered unrecognised or invalid instruction.\n");
2601 }
2602
2603 if (ins.predicate)
2604 FIXME("Predicates not implemented.\n");
2605
2606 /* Call appropriate function for output target */
2607 device->shader_backend->shader_handle_instruction(&ins);
2608 }
2609
2610 return WINED3D_OK;
2611}
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
static PVOID ptr
Definition: dispmode.c:27
const struct wined3d_shader_reg_maps * reg_maps
struct wined3d_shader_tex_mx * tex_mx
void(* shader_read_header)(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version)
BOOL(* shader_is_end)(void *data, const DWORD **ptr)
void(* shader_read_instruction)(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins)
@ WINED3DSIH_TABLE_SIZE

Referenced by shader_arb_generate_pshader(), shader_arb_generate_vshader(), shader_glsl_generate_compute_shader(), shader_glsl_generate_domain_shader(), shader_glsl_generate_geometry_shader(), shader_glsl_generate_hull_shader(), shader_glsl_generate_pshader(), shader_glsl_generate_shader_phase(), and shader_glsl_generate_vshader().

◆ shader_get_float_offset()

static unsigned int shader_get_float_offset ( enum wined3d_shader_register_type  register_type,
UINT  register_idx 
)
static

Definition at line 569 of file shader.c.

570{
571 switch (register_type)
572 {
573 case WINED3DSPR_CONST: return register_idx;
574 case WINED3DSPR_CONST2: return 2048 + register_idx;
575 case WINED3DSPR_CONST3: return 4096 + register_idx;
576 case WINED3DSPR_CONST4: return 6144 + register_idx;
577 default:
578 FIXME("Unsupported register type: %u.\n", register_type);
579 return register_idx;
580 }
581}

Referenced by shader_dump_register(), and shader_trace_init().

◆ shader_get_registers_used()

static HRESULT shader_get_registers_used ( struct wined3d_shader shader,
const struct wined3d_shader_frontend fe,
struct wined3d_shader_reg_maps reg_maps,
struct wined3d_shader_signature input_signature,
struct wined3d_shader_signature output_signature,
DWORD  constf_size 
)
static

Definition at line 987 of file shader.c.

990{
991 struct wined3d_shader_signature_element input_signature_elements[max(MAX_ATTRIBS, MAX_REG_INPUT)];
992 struct wined3d_shader_signature_element output_signature_elements[MAX_REG_OUTPUT];
993 unsigned int cur_loop_depth = 0, max_loop_depth = 0;
994 struct wined3d_shader_version shader_version;
995 struct wined3d_shader_phase *phase = NULL;
996 const DWORD *ptr, *prev_ins, *current_ins;
997 void *fe_data = shader->frontend_data;
998 unsigned int i;
999 HRESULT hr;
1000
1001 memset(reg_maps, 0, sizeof(*reg_maps));
1002 memset(input_signature_elements, 0, sizeof(input_signature_elements));
1003 memset(output_signature_elements, 0, sizeof(output_signature_elements));
1004 reg_maps->min_rel_offset = ~0U;
1005 list_init(&reg_maps->indexable_temps);
1006
1007 fe->shader_read_header(fe_data, &ptr, &shader_version);
1008 prev_ins = current_ins = ptr;
1009 reg_maps->shader_version = shader_version;
1010
1012
1013 if (!(reg_maps->constf = heap_calloc(((min(shader->limits->constant_float, constf_size) + 31) / 32),
1014 sizeof(*reg_maps->constf))))
1015 {
1016 ERR("Failed to allocate constant map memory.\n");
1017 return E_OUTOFMEMORY;
1018 }
1019
1020 while (!fe->shader_is_end(fe_data, &ptr))
1021 {
1022 struct wined3d_shader_instruction ins;
1023
1024 current_ins = ptr;
1025 /* Fetch opcode. */
1026 fe->shader_read_instruction(fe_data, &ptr, &ins);
1027
1028 /* Unhandled opcode, and its parameters. */
1029 if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
1030 {
1031 WARN("Encountered unrecognised or invalid instruction.\n");
1033 }
1034
1035 /* Handle declarations. */
1036 if (ins.handler_idx == WINED3DSIH_DCL
1037 || ins.handler_idx == WINED3DSIH_DCL_UAV_TYPED)
1038 {
1039 struct wined3d_shader_semantic *semantic = &ins.declaration.semantic;
1040 unsigned int reg_idx = semantic->reg.reg.idx[0].offset;
1041
1042 switch (semantic->reg.reg.type)
1043 {
1044 /* Mark input registers used. */
1045 case WINED3DSPR_INPUT:
1046 if (reg_idx >= MAX_REG_INPUT)
1047 {
1048 ERR("Invalid input register index %u.\n", reg_idx);
1049 break;
1050 }
1051 if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL && shader_version.major == 3
1052 && semantic->usage == WINED3D_DECL_USAGE_POSITION && !semantic->usage_idx)
1054 reg_maps->input_registers |= 1u << reg_idx;
1055 shader_signature_from_semantic(&input_signature_elements[reg_idx], semantic);
1056 break;
1057
1058 /* Vertex shader: mark 3.0 output registers used, save token. */
1059 case WINED3DSPR_OUTPUT:
1060 if (reg_idx >= MAX_REG_OUTPUT)
1061 {
1062 ERR("Invalid output register index %u.\n", reg_idx);
1063 break;
1064 }
1065 reg_maps->output_registers |= 1u << reg_idx;
1066 shader_signature_from_semantic(&output_signature_elements[reg_idx], semantic);
1067 if (semantic->usage == WINED3D_DECL_USAGE_FOG)
1068 reg_maps->fog = 1;
1069 if (semantic->usage == WINED3D_DECL_USAGE_PSIZE)
1070 reg_maps->point_size = 1;
1071 break;
1072
1073 case WINED3DSPR_SAMPLER:
1074 shader_record_sample(reg_maps, reg_idx, reg_idx, reg_idx);
1076 if (reg_idx >= ARRAY_SIZE(reg_maps->resource_info))
1077 {
1078 ERR("Invalid resource index %u.\n", reg_idx);
1079 break;
1080 }
1081 reg_maps->resource_info[reg_idx].type = semantic->resource_type;
1082 reg_maps->resource_info[reg_idx].data_type = semantic->resource_data_type;
1083 break;
1084
1085 case WINED3DSPR_UAV:
1086 if (reg_idx >= ARRAY_SIZE(reg_maps->uav_resource_info))
1087 {
1088 ERR("Invalid UAV resource index %u.\n", reg_idx);
1089 break;
1090 }
1091 reg_maps->uav_resource_info[reg_idx].type = semantic->resource_type;
1092 reg_maps->uav_resource_info[reg_idx].data_type = semantic->resource_data_type;
1093 if (ins.flags)
1094 FIXME("Ignoring typed UAV flags %#x.\n", ins.flags);
1095 break;
1096
1097 default:
1098 TRACE("Not recording DCL register type %#x.\n", semantic->reg.reg.type);
1099 break;
1100 }
1101 }
1102 else if (ins.handler_idx == WINED3DSIH_DCL_CONSTANT_BUFFER)
1103 {
1104 struct wined3d_shader_register *reg = &ins.declaration.src.reg;
1105 if (reg->idx[0].offset >= WINED3D_MAX_CBS)
1106 ERR("Invalid CB index %u.\n", reg->idx[0].offset);
1107 else
1108 reg_maps->cb_sizes[reg->idx[0].offset] = reg->idx[1].offset;
1109 }
1110 else if (ins.handler_idx == WINED3DSIH_DCL_GLOBAL_FLAGS)
1111 {
1113 {
1114 if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
1115 shader->u.ps.force_early_depth_stencil = TRUE;
1116 else
1117 FIXME("Invalid instruction %#x for shader type %#x.\n",
1118 ins.handler_idx, shader_version.type);
1119 }
1120 else
1121 {
1122 WARN("Ignoring global flags %#x.\n", ins.flags);
1123 }
1124 }
1125 else if (ins.handler_idx == WINED3DSIH_DCL_GS_INSTANCES)
1126 {
1127 if (shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY)
1128 shader->u.gs.instance_count = ins.declaration.count;
1129 else
1130 FIXME("Invalid instruction %#x for shader type %#x.\n",
1131 ins.handler_idx, shader_version.type);
1132 }
1133 else if (ins.handler_idx == WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT
1134 || ins.handler_idx == WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT)
1135 {
1136 if (phase)
1137 phase->instance_count = ins.declaration.count;
1138 else
1139 FIXME("Instruction %s outside of shader phase.\n",
1140 debug_d3dshaderinstructionhandler(ins.handler_idx));
1141 }
1142 else if (ins.handler_idx == WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER)
1143 {
1144 if (reg_maps->icb)
1145 FIXME("Multiple immediate constant buffers.\n");
1146 reg_maps->icb = ins.declaration.icb;
1147 }
1148 else if (ins.handler_idx == WINED3DSIH_DCL_INDEXABLE_TEMP)
1149 {
1150 if (phase)
1151 {
1152 FIXME("Indexable temporary registers not supported.\n");
1153 }
1154 else
1155 {
1157
1158 if (!(reg = heap_alloc(sizeof(*reg))))
1159 return E_OUTOFMEMORY;
1160
1161 *reg = ins.declaration.indexable_temp;
1162 list_add_tail(&reg_maps->indexable_temps, &reg->entry);
1163 }
1164 }
1165 else if (ins.handler_idx == WINED3DSIH_DCL_INPUT_PRIMITIVE)
1166 {
1167 if (shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY)
1168 shader->u.gs.input_type = ins.declaration.primitive_type.type;
1169 else
1170 FIXME("Invalid instruction %#x for shader type %#x.\n",
1171 ins.handler_idx, shader_version.type);
1172 }
1173 else if (ins.handler_idx == WINED3DSIH_DCL_INPUT_PS)
1174 {
1175 unsigned int reg_idx = ins.declaration.dst.reg.idx[0].offset;
1176 if (reg_idx >= MAX_REG_INPUT)
1177 {
1178 ERR("Invalid register index %u.\n", reg_idx);
1179 break;
1180 }
1181 if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
1182 wined3d_insert_interpolation_mode(shader->u.ps.interpolation_mode, reg_idx, ins.flags);
1183 else
1184 FIXME("Invalid instruction %#x for shader type %#x.\n",
1185 ins.handler_idx, shader_version.type);
1186 }
1187 else if (ins.handler_idx == WINED3DSIH_DCL_OUTPUT)
1188 {
1189 if (ins.declaration.dst.reg.type == WINED3DSPR_DEPTHOUT
1190 || ins.declaration.dst.reg.type == WINED3DSPR_DEPTHOUTGE
1191 || ins.declaration.dst.reg.type == WINED3DSPR_DEPTHOUTLE)
1192 {
1193 if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
1194 shader->u.ps.depth_output = ins.declaration.dst.reg.type;
1195 else
1196 FIXME("Invalid instruction %#x for shader type %#x.\n",
1197 ins.handler_idx, shader_version.type);
1198 }
1199 }
1200 else if (ins.handler_idx == WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT)
1201 {
1202 if (shader_version.type == WINED3D_SHADER_TYPE_HULL)
1203 shader->u.hs.output_vertex_count = ins.declaration.count;
1204 else
1205 FIXME("Invalid instruction %#x for shader type %#x.\n", ins.handler_idx, shader_version.type);
1206 }
1207 else if (ins.handler_idx == WINED3DSIH_DCL_OUTPUT_TOPOLOGY)
1208 {
1209 if (shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY)
1210 shader->u.gs.output_type = ins.declaration.primitive_type.type;
1211 else
1212 FIXME("Invalid instruction %#x for shader type %#x.\n",
1213 ins.handler_idx, shader_version.type);
1214 }
1215 else if (ins.handler_idx == WINED3DSIH_DCL_RESOURCE_RAW)
1216 {
1217 unsigned int reg_idx = ins.declaration.dst.reg.idx[0].offset;
1218 if (reg_idx >= ARRAY_SIZE(reg_maps->resource_info))
1219 {
1220 ERR("Invalid resource index %u.\n", reg_idx);
1221 break;
1222 }
1223 reg_maps->resource_info[reg_idx].type = WINED3D_SHADER_RESOURCE_BUFFER;
1224 reg_maps->resource_info[reg_idx].data_type = WINED3D_DATA_UINT;
1225 reg_maps->resource_info[reg_idx].flags = WINED3D_VIEW_BUFFER_RAW;
1226 }
1227 else if (ins.handler_idx == WINED3DSIH_DCL_RESOURCE_STRUCTURED)
1228 {
1229 unsigned int reg_idx = ins.declaration.structured_resource.reg.reg.idx[0].offset;
1230 if (reg_idx >= ARRAY_SIZE(reg_maps->resource_info))
1231 {
1232 ERR("Invalid resource index %u.\n", reg_idx);
1233 break;
1234 }
1235 reg_maps->resource_info[reg_idx].type = WINED3D_SHADER_RESOURCE_BUFFER;
1236 reg_maps->resource_info[reg_idx].data_type = WINED3D_DATA_UINT;
1237 reg_maps->resource_info[reg_idx].flags = 0;
1238 reg_maps->resource_info[reg_idx].stride = ins.declaration.structured_resource.byte_stride / 4;
1239 }
1240 else if (ins.handler_idx == WINED3DSIH_DCL_SAMPLER)
1241 {
1242 if (ins.flags & WINED3DSI_SAMPLER_COMPARISON_MODE)
1243 reg_maps->sampler_comparison_mode |= (1u << ins.declaration.dst.reg.idx[0].offset);
1244 }
1245 else if (ins.handler_idx == WINED3DSIH_DCL_TEMPS)
1246 {
1247 if (phase)
1248 phase->temporary_count = ins.declaration.count;
1249 else
1250 reg_maps->temporary_count = ins.declaration.count;
1251 }
1252 else if (ins.handler_idx == WINED3DSIH_DCL_TESSELLATOR_DOMAIN)
1253 {
1254 if (shader_version.type == WINED3D_SHADER_TYPE_DOMAIN)
1255 shader->u.ds.tessellator_domain = ins.declaration.tessellator_domain;
1256 else if (shader_version.type != WINED3D_SHADER_TYPE_HULL)
1257 FIXME("Invalid instruction %#x for shader type %#x.\n", ins.handler_idx, shader_version.type);
1258 }
1259 else if (ins.handler_idx == WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE)
1260 {
1261 if (shader_version.type == WINED3D_SHADER_TYPE_HULL)
1262 shader->u.hs.tessellator_output_primitive = ins.declaration.tessellator_output_primitive;
1263 else
1264 FIXME("Invalid instruction %#x for shader type %#x.\n", ins.handler_idx, shader_version.type);
1265 }
1266 else if (ins.handler_idx == WINED3DSIH_DCL_TESSELLATOR_PARTITIONING)
1267 {
1268 if (shader_version.type == WINED3D_SHADER_TYPE_HULL)
1269 shader->u.hs.tessellator_partitioning = ins.declaration.tessellator_partitioning;
1270 else
1271 FIXME("Invalid instruction %#x for shader type %#x.\n", ins.handler_idx, shader_version.type);
1272 }
1273 else if (ins.handler_idx == WINED3DSIH_DCL_TGSM_RAW)
1274 {
1275 if (FAILED(hr = shader_reg_maps_add_tgsm(reg_maps, ins.declaration.tgsm_raw.reg.reg.idx[0].offset,
1276 ins.declaration.tgsm_raw.byte_count / 4, 0)))
1277 return hr;
1278 }
1279 else if (ins.handler_idx == WINED3DSIH_DCL_TGSM_STRUCTURED)
1280 {
1281 unsigned int stride = ins.declaration.tgsm_structured.byte_stride / 4;
1282 unsigned int size = stride * ins.declaration.tgsm_structured.structure_count;
1283 if (FAILED(hr = shader_reg_maps_add_tgsm(reg_maps,
1284 ins.declaration.tgsm_structured.reg.reg.idx[0].offset, size, stride)))
1285 return hr;
1286 }
1287 else if (ins.handler_idx == WINED3DSIH_DCL_THREAD_GROUP)
1288 {
1289 if (shader_version.type == WINED3D_SHADER_TYPE_COMPUTE)
1290 {
1291 shader->u.cs.thread_group_size = ins.declaration.thread_group_size;
1292 }
1293 else
1294 {
1295 FIXME("Invalid instruction %#x for shader type %#x.\n",
1296 ins.handler_idx, shader_version.type);
1297 }
1298 }
1299 else if (ins.handler_idx == WINED3DSIH_DCL_UAV_RAW)
1300 {
1301 unsigned int reg_idx = ins.declaration.dst.reg.idx[0].offset;
1302 if (reg_idx >= ARRAY_SIZE(reg_maps->uav_resource_info))
1303 {
1304 ERR("Invalid UAV resource index %u.\n", reg_idx);
1305 break;
1306 }
1307 if (ins.flags)
1308 FIXME("Ignoring raw UAV flags %#x.\n", ins.flags);
1309 reg_maps->uav_resource_info[reg_idx].type = WINED3D_SHADER_RESOURCE_BUFFER;
1310 reg_maps->uav_resource_info[reg_idx].data_type = WINED3D_DATA_UINT;
1311 reg_maps->uav_resource_info[reg_idx].flags = WINED3D_VIEW_BUFFER_RAW;
1312 }
1313 else if (ins.handler_idx == WINED3DSIH_DCL_UAV_STRUCTURED)
1314 {
1315 unsigned int reg_idx = ins.declaration.structured_resource.reg.reg.idx[0].offset;
1316 if (reg_idx >= ARRAY_SIZE(reg_maps->uav_resource_info))
1317 {
1318 ERR("Invalid UAV resource index %u.\n", reg_idx);
1319 break;
1320 }
1321 if (ins.flags)
1322 FIXME("Ignoring structured UAV flags %#x.\n", ins.flags);
1323 reg_maps->uav_resource_info[reg_idx].type = WINED3D_SHADER_RESOURCE_BUFFER;
1324 reg_maps->uav_resource_info[reg_idx].data_type = WINED3D_DATA_UINT;
1325 reg_maps->uav_resource_info[reg_idx].flags = 0;
1326 reg_maps->uav_resource_info[reg_idx].stride = ins.declaration.structured_resource.byte_stride / 4;
1327 }
1328 else if (ins.handler_idx == WINED3DSIH_DCL_VERTICES_OUT)
1329 {
1330 if (shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY)
1331 shader->u.gs.vertices_out = ins.declaration.count;
1332 else
1333 FIXME("Invalid instruction %#x for shader type %#x.\n",
1334 ins.handler_idx, shader_version.type);
1335 }
1336 else if (ins.handler_idx == WINED3DSIH_DEF)
1337 {
1338 struct wined3d_shader_lconst *lconst;
1339 float *value;
1340
1341 if (!(lconst = heap_alloc(sizeof(*lconst))))
1342 return E_OUTOFMEMORY;
1343
1344 lconst->idx = ins.dst[0].reg.idx[0].offset;
1345 memcpy(lconst->value, ins.src[0].reg.u.immconst_data, 4 * sizeof(DWORD));
1346 value = (float *)lconst->value;
1347
1348 /* In pixel shader 1.X shaders, the constants are clamped between [-1;1] */
1349 if (shader_version.major == 1 && shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
1350 {
1351 if (value[0] < -1.0f) value[0] = -1.0f;
1352 else if (value[0] > 1.0f) value[0] = 1.0f;
1353 if (value[1] < -1.0f) value[1] = -1.0f;
1354 else if (value[1] > 1.0f) value[1] = 1.0f;
1355 if (value[2] < -1.0f) value[2] = -1.0f;
1356 else if (value[2] > 1.0f) value[2] = 1.0f;
1357 if (value[3] < -1.0f) value[3] = -1.0f;
1358 else if (value[3] > 1.0f) value[3] = 1.0f;
1359 }
1360
1361 list_add_head(&shader->constantsF, &lconst->entry);
1362
1363 if (isinf(value[0]) || isnan(value[0]) || isinf(value[1]) || isnan(value[1])
1364 || isinf(value[2]) || isnan(value[2]) || isinf(value[3]) || isnan(value[3]))
1365 {
1366 shader->lconst_inf_or_nan = TRUE;
1367 }
1368 }
1369 else if (ins.handler_idx == WINED3DSIH_DEFI)
1370 {
1371 struct wined3d_shader_lconst *lconst;
1372
1373 if (!(lconst = heap_alloc(sizeof(*lconst))))
1374 return E_OUTOFMEMORY;
1375
1376 lconst->idx = ins.dst[0].reg.idx[0].offset;
1377 memcpy(lconst->value, ins.src[0].reg.u.immconst_data, 4 * sizeof(DWORD));
1378
1379 list_add_head(&shader->constantsI, &lconst->entry);
1380 reg_maps->local_int_consts |= (1u << lconst->idx);
1381 }
1382 else if (ins.handler_idx == WINED3DSIH_DEFB)
1383 {
1384 struct wined3d_shader_lconst *lconst;
1385
1386 if (!(lconst = heap_alloc(sizeof(*lconst))))
1387 return E_OUTOFMEMORY;
1388
1389 lconst->idx = ins.dst[0].reg.idx[0].offset;
1390 memcpy(lconst->value, ins.src[0].reg.u.immconst_data, sizeof(DWORD));
1391
1392 list_add_head(&shader->constantsB, &lconst->entry);
1393 reg_maps->local_bool_consts |= (1u << lconst->idx);
1394 }
1395 /* Handle shader phases. */
1396 else if (ins.handler_idx == WINED3DSIH_HS_CONTROL_POINT_PHASE
1397 || ins.handler_idx == WINED3DSIH_HS_FORK_PHASE
1398 || ins.handler_idx == WINED3DSIH_HS_JOIN_PHASE)
1399 {
1400 if (FAILED(hr = shader_record_shader_phase(shader, &phase, &ins, current_ins, prev_ins)))
1401 return hr;
1402 }
1403 /* For subroutine prototypes. */
1404 else if (ins.handler_idx == WINED3DSIH_LABEL)
1405 {
1406 reg_maps->labels |= 1u << ins.src[0].reg.idx[0].offset;
1407 }
1408 /* Set texture, address, temporary registers. */
1409 else
1410 {
1411 BOOL color0_mov = FALSE;
1412 unsigned int i;
1413
1414 /* This will loop over all the registers and try to
1415 * make a bitmask of the ones we're interested in.
1416 *
1417 * Relative addressing tokens are ignored, but that's
1418 * okay, since we'll catch any address registers when
1419 * they are initialized (required by spec). */
1420 for (i = 0; i < ins.dst_count; ++i)
1421 {
1422 if (!shader_record_register_usage(shader, reg_maps, &ins.dst[i].reg,
1423 shader_version.type, constf_size))
1425
1426 if (shader_version.type == WINED3D_SHADER_TYPE_VERTEX)
1427 {
1428 UINT idx = ins.dst[i].reg.idx[0].offset;
1429
1430 switch (ins.dst[i].reg.type)
1431 {
1432 case WINED3DSPR_RASTOUT:
1433 if (shader_version.major >= 3)
1434 break;
1435 switch (idx)
1436 {
1437 case 0: /* oPos */
1438 reg_maps->output_registers |= 1u << 10;
1439 shader_signature_from_usage(&output_signature_elements[10],
1441 break;
1442
1443 case 1: /* oFog */
1444 reg_maps->output_registers |= 1u << 11;
1445 shader_signature_from_usage(&output_signature_elements[11],
1447 break;
1448
1449 case 2: /* oPts */
1450 reg_maps->output_registers |= 1u << 11;
1451 shader_signature_from_usage(&output_signature_elements[11],
1453 break;
1454 }
1455 break;
1456
1457 case WINED3DSPR_ATTROUT:
1458 if (shader_version.major >= 3)
1459 break;
1460 if (idx < 2)
1461 {
1462 idx += 8;
1463 if (reg_maps->output_registers & (1u << idx))
1464 {
1465 output_signature_elements[idx].mask |= ins.dst[i].write_mask;
1466 }
1467 else
1468 {
1469 reg_maps->output_registers |= 1u << idx;
1470 shader_signature_from_usage(&output_signature_elements[idx],
1471 WINED3D_DECL_USAGE_COLOR, idx - 8, idx, ins.dst[i].write_mask);
1472 }
1473 }
1474 break;
1475
1476 case WINED3DSPR_TEXCRDOUT: /* WINED3DSPR_OUTPUT */
1477 if (shader_version.major >= 3)
1478 {
1479 if (idx >= ARRAY_SIZE(reg_maps->u.output_registers_mask))
1480 {
1481 WARN("Invalid output register index %u.\n", idx);
1482 break;
1483 }
1484 reg_maps->u.output_registers_mask[idx] |= ins.dst[i].write_mask;
1485 break;
1486 }
1487 if (idx >= ARRAY_SIZE(reg_maps->u.texcoord_mask))
1488 {
1489 WARN("Invalid texcoord index %u.\n", idx);
1490 break;
1491 }
1492 reg_maps->u.texcoord_mask[idx] |= ins.dst[i].write_mask;
1493 if (reg_maps->output_registers & (1u << idx))
1494 {
1495 output_signature_elements[idx].mask |= ins.dst[i].write_mask;
1496 }
1497 else
1498 {
1499 reg_maps->output_registers |= 1u << idx;
1500 shader_signature_from_usage(&output_signature_elements[idx],
1501 WINED3D_DECL_USAGE_TEXCOORD, idx, idx, ins.dst[i].write_mask);
1502 }
1503 break;
1504
1505 default:
1506 break;
1507 }
1508 }
1509
1510 if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
1511 {
1512 if (ins.dst[i].reg.type == WINED3DSPR_COLOROUT && !ins.dst[i].reg.idx[0].offset)
1513 {
1514 /* Many 2.0 and 3.0 pixel shaders end with a MOV from a temp register to
1515 * COLOROUT 0. If we know this in advance, the ARB shader backend can skip
1516 * the mov and perform the sRGB write correction from the source register.
1517 *
1518 * However, if the mov is only partial, we can't do this, and if the write
1519 * comes from an instruction other than MOV it is hard to do as well. If
1520 * COLOROUT 0 is overwritten partially later, the marker is dropped again. */
1521 shader->u.ps.color0_mov = FALSE;
1522 if (ins.handler_idx == WINED3DSIH_MOV
1523 && ins.dst[i].write_mask == WINED3DSP_WRITEMASK_ALL)
1524 {
1525 /* Used later when the source register is read. */
1526 color0_mov = TRUE;
1527 }
1528 }
1529 /* Also drop the MOV marker if the source register is overwritten prior to the shader
1530 * end
1531 */
1532 else if (ins.dst[i].reg.type == WINED3DSPR_TEMP
1533 && ins.dst[i].reg.idx[0].offset == shader->u.ps.color0_reg)
1534 {
1535 shader->u.ps.color0_mov = FALSE;
1536 }
1537 }
1538
1539 /* Declare 1.x samplers implicitly, based on the destination reg. number. */
1540 if (shader_version.major == 1
1541 && (ins.handler_idx == WINED3DSIH_TEX
1542 || ins.handler_idx == WINED3DSIH_TEXBEM
1543 || ins.handler_idx == WINED3DSIH_TEXBEML
1544 || ins.handler_idx == WINED3DSIH_TEXDP3TEX
1545 || ins.handler_idx == WINED3DSIH_TEXM3x2TEX
1546 || ins.handler_idx == WINED3DSIH_TEXM3x3SPEC
1547 || ins.handler_idx == WINED3DSIH_TEXM3x3TEX
1548 || ins.handler_idx == WINED3DSIH_TEXM3x3VSPEC
1549 || ins.handler_idx == WINED3DSIH_TEXREG2AR
1550 || ins.handler_idx == WINED3DSIH_TEXREG2GB
1551 || ins.handler_idx == WINED3DSIH_TEXREG2RGB))
1552 {
1553 unsigned int reg_idx = ins.dst[i].reg.idx[0].offset;
1554
1555 if (reg_idx >= ARRAY_SIZE(reg_maps->resource_info))
1556 {
1557 WARN("Invalid 1.x sampler index %u.\n", reg_idx);
1558 continue;
1559 }
1560
1561 TRACE("Setting fake 2D resource for 1.x pixelshader.\n");
1562 reg_maps->resource_info[reg_idx].type = WINED3D_SHADER_RESOURCE_TEXTURE_2D;
1563 reg_maps->resource_info[reg_idx].data_type = WINED3D_DATA_FLOAT;
1564 shader_record_sample(reg_maps, reg_idx, reg_idx, reg_idx);
1565
1566 /* texbem is only valid with < 1.4 pixel shaders */
1567 if (ins.handler_idx == WINED3DSIH_TEXBEM
1568 || ins.handler_idx == WINED3DSIH_TEXBEML)
1569 {
1570 reg_maps->bumpmat |= 1u << reg_idx;
1571 if (ins.handler_idx == WINED3DSIH_TEXBEML)
1572 {
1573 reg_maps->luminanceparams |= 1u << reg_idx;
1574 }
1575 }
1576 }
1577 else if (ins.handler_idx == WINED3DSIH_BEM)
1578 {
1579 reg_maps->bumpmat |= 1u << ins.dst[i].reg.idx[0].offset;
1580 }
1581 }
1582
1583 if (ins.handler_idx == WINED3DSIH_IMM_ATOMIC_ALLOC || ins.handler_idx == WINED3DSIH_IMM_ATOMIC_CONSUME)
1584 {
1585 unsigned int reg_idx = ins.src[0].reg.idx[0].offset;
1586 if (reg_idx >= MAX_UNORDERED_ACCESS_VIEWS)
1587 {
1588 ERR("Invalid UAV index %u.\n", reg_idx);
1589 break;
1590 }
1591 reg_maps->uav_counter_mask |= (1u << reg_idx);
1592 }
1593 else if ((WINED3DSIH_ATOMIC_AND <= ins.handler_idx && ins.handler_idx <= WINED3DSIH_ATOMIC_XOR)
1594 || (WINED3DSIH_IMM_ATOMIC_AND <= ins.handler_idx && ins.handler_idx <= WINED3DSIH_IMM_ATOMIC_XOR)
1595 || (ins.handler_idx == WINED3DSIH_BUFINFO && ins.src[0].reg.type == WINED3DSPR_UAV)
1596 || ins.handler_idx == WINED3DSIH_LD_UAV_TYPED
1597 || (ins.handler_idx == WINED3DSIH_LD_RAW && ins.src[1].reg.type == WINED3DSPR_UAV)
1598 || (ins.handler_idx == WINED3DSIH_LD_STRUCTURED && ins.src[2].reg.type == WINED3DSPR_UAV))
1599 {
1600 unsigned int reg_idx;
1601 if (ins.handler_idx == WINED3DSIH_LD_UAV_TYPED || ins.handler_idx == WINED3DSIH_LD_RAW)
1602 reg_idx = ins.src[1].reg.idx[0].offset;
1603 else if (ins.handler_idx == WINED3DSIH_LD_STRUCTURED)
1604 reg_idx = ins.src[2].reg.idx[0].offset;
1605 else if (WINED3DSIH_ATOMIC_AND <= ins.handler_idx && ins.handler_idx <= WINED3DSIH_ATOMIC_XOR)
1606 reg_idx = ins.dst[0].reg.idx[0].offset;
1607 else if (ins.handler_idx == WINED3DSIH_BUFINFO)
1608 reg_idx = ins.src[0].reg.idx[0].offset;
1609 else
1610 reg_idx = ins.dst[1].reg.idx[0].offset;
1611 if (reg_idx >= MAX_UNORDERED_ACCESS_VIEWS)
1612 {
1613 ERR("Invalid UAV index %u.\n", reg_idx);
1614 break;
1615 }
1616 reg_maps->uav_read_mask |= (1u << reg_idx);
1617 }
1618 else if (ins.handler_idx == WINED3DSIH_NRM)
1619 {
1620 reg_maps->usesnrm = 1;
1621 }
1622 else if (ins.handler_idx == WINED3DSIH_DSY
1623 || ins.handler_idx == WINED3DSIH_DSY_COARSE
1624 || ins.handler_idx == WINED3DSIH_DSY_FINE)
1625 {
1626 reg_maps->usesdsy = 1;
1627 }
1628 else if (ins.handler_idx == WINED3DSIH_DSX
1629 || ins.handler_idx == WINED3DSIH_DSX_COARSE
1630 || ins.handler_idx == WINED3DSIH_DSX_FINE)
1631 {
1632 reg_maps->usesdsx = 1;
1633 }
1634 else if (ins.handler_idx == WINED3DSIH_TEXLDD) reg_maps->usestexldd = 1;
1635 else if (ins.handler_idx == WINED3DSIH_TEXLDL) reg_maps->usestexldl = 1;
1636 else if (ins.handler_idx == WINED3DSIH_MOVA) reg_maps->usesmova = 1;
1637 else if (ins.handler_idx == WINED3DSIH_IFC) reg_maps->usesifc = 1;
1638 else if (ins.handler_idx == WINED3DSIH_CALL) reg_maps->usescall = 1;
1639 else if (ins.handler_idx == WINED3DSIH_POW) reg_maps->usespow = 1;
1640 else if (ins.handler_idx == WINED3DSIH_LOOP
1641 || ins.handler_idx == WINED3DSIH_REP)
1642 {
1643 ++cur_loop_depth;
1644 if (cur_loop_depth > max_loop_depth)
1645 max_loop_depth = cur_loop_depth;
1646 }
1647 else if (ins.handler_idx == WINED3DSIH_ENDLOOP
1648 || ins.handler_idx == WINED3DSIH_ENDREP)
1649 {
1650 --cur_loop_depth;
1651 }
1652 else if (ins.handler_idx == WINED3DSIH_GATHER4
1653 || ins.handler_idx == WINED3DSIH_GATHER4_C
1654 || ins.handler_idx == WINED3DSIH_SAMPLE
1655 || ins.handler_idx == WINED3DSIH_SAMPLE_B
1656 || ins.handler_idx == WINED3DSIH_SAMPLE_C
1657 || ins.handler_idx == WINED3DSIH_SAMPLE_C_LZ
1658 || ins.handler_idx == WINED3DSIH_SAMPLE_GRAD
1659 || ins.handler_idx == WINED3DSIH_SAMPLE_LOD)
1660 {
1661 shader_record_sample(reg_maps, ins.src[1].reg.idx[0].offset,
1662 ins.src[2].reg.idx[0].offset, reg_maps->sampler_map.count);
1663 }
1664 else if (ins.handler_idx == WINED3DSIH_GATHER4_PO
1665 || ins.handler_idx == WINED3DSIH_GATHER4_PO_C)
1666 {
1667 shader_record_sample(reg_maps, ins.src[2].reg.idx[0].offset,
1668 ins.src[3].reg.idx[0].offset, reg_maps->sampler_map.count);
1669 }
1670 else if (ins.handler_idx == WINED3DSIH_BUFINFO && ins.src[0].reg.type == WINED3DSPR_RESOURCE)
1671 {
1672 shader_record_sample(reg_maps, ins.src[0].reg.idx[0].offset,
1673 WINED3D_SAMPLER_DEFAULT, reg_maps->sampler_map.count);
1674 }
1675 else if (ins.handler_idx == WINED3DSIH_LD
1676 || ins.handler_idx == WINED3DSIH_LD2DMS
1677 || (ins.handler_idx == WINED3DSIH_LD_RAW && ins.src[1].reg.type == WINED3DSPR_RESOURCE)
1678 || (ins.handler_idx == WINED3DSIH_RESINFO && ins.src[1].reg.type == WINED3DSPR_RESOURCE))
1679 {
1680 shader_record_sample(reg_maps, ins.src[1].reg.idx[0].offset,
1681 WINED3D_SAMPLER_DEFAULT, reg_maps->sampler_map.count);
1682 }
1683 else if (ins.handler_idx == WINED3DSIH_LD_STRUCTURED
1684 && ins.src[2].reg.type == WINED3DSPR_RESOURCE)
1685 {
1686 shader_record_sample(reg_maps, ins.src[2].reg.idx[0].offset,
1687 WINED3D_SAMPLER_DEFAULT, reg_maps->sampler_map.count);
1688 }
1689
1690 if (ins.predicate)
1691 if (!shader_record_register_usage(shader, reg_maps, &ins.predicate->reg,
1692 shader_version.type, constf_size))
1694
1695 for (i = 0; i < ins.src_count; ++i)
1696 {
1697 unsigned int count = get_instr_extra_regcount(ins.handler_idx, i);
1698 struct wined3d_shader_register reg = ins.src[i].reg;
1699
1700 if (!shader_record_register_usage(shader, reg_maps, &ins.src[i].reg,
1701 shader_version.type, constf_size))
1703 while (count)
1704 {
1705 ++reg.idx[0].offset;
1706 if (!shader_record_register_usage(shader, reg_maps, &reg,
1707 shader_version.type, constf_size))
1709 --count;
1710 }
1711
1712 if (color0_mov)
1713 {
1714 if (ins.src[i].reg.type == WINED3DSPR_TEMP
1715 && ins.src[i].swizzle == WINED3DSP_NOSWIZZLE)
1716 {
1717 shader->u.ps.color0_mov = TRUE;
1718 shader->u.ps.color0_reg = ins.src[i].reg.idx[0].offset;
1719 }
1720 }
1721 }
1722 }
1723
1724 prev_ins = current_ins;
1725 }
1726 reg_maps->loop_depth = max_loop_depth;
1727
1728 if (phase)
1729 {
1730 phase->end = prev_ins;
1731 phase = NULL;
1732 }
1733
1734 /* PS before 2.0 don't have explicit color outputs. Instead the value of
1735 * R0 is written to the render target. */
1736 if (shader_version.major < 2 && shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
1737 reg_maps->rt_mask |= (1u << 0);
1738
1739 if (input_signature->elements)
1740 {
1741 for (i = 0; i < input_signature->element_count; ++i)
1742 {
1743 if (shader_version.type == WINED3D_SHADER_TYPE_VERTEX)
1744 {
1745 if (input_signature->elements[i].register_idx >= ARRAY_SIZE(shader->u.vs.attributes))
1746 {
1747 WARN("Invalid input signature register index %u.\n", input_signature->elements[i].register_idx);
1749 }
1750 }
1751 else if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
1752 {
1753 if (input_signature->elements[i].sysval_semantic == WINED3D_SV_POSITION)
1754 reg_maps->vpos = 1;
1755 else if (input_signature->elements[i].sysval_semantic == WINED3D_SV_IS_FRONT_FACE)
1756 reg_maps->usesfacing = 1;
1757 }
1758 reg_maps->input_registers |= 1u << input_signature->elements[i].register_idx;
1759 }
1760 }
1761 else if (!input_signature->elements && reg_maps->input_registers)
1762 {
1763 unsigned int count = wined3d_popcount(reg_maps->input_registers);
1765 unsigned int i;
1766
1767 if (!(input_signature->elements = heap_calloc(count, sizeof(*input_signature->elements))))
1768 return E_OUTOFMEMORY;
1769 input_signature->element_count = count;
1770
1771 e = input_signature->elements;
1772 for (i = 0; i < ARRAY_SIZE(input_signature_elements); ++i)
1773 {
1774 if (!(reg_maps->input_registers & (1u << i)))
1775 continue;
1776 input_signature_elements[i].register_idx = i;
1777 *e++ = input_signature_elements[i];
1778 }
1779 }
1780
1781 if (output_signature->elements)
1782 {
1783 for (i = 0; i < output_signature->element_count; ++i)
1784 {
1785 const struct wined3d_shader_signature_element *e = &output_signature->elements[i];
1786 unsigned int mask;
1787
1788 reg_maps->output_registers |= 1u << e->register_idx;
1789 if (e->sysval_semantic == WINED3D_SV_CLIP_DISTANCE)
1790 {
1792 return hr;
1793 reg_maps->clip_distance_mask |= mask;
1794 }
1795 else if (e->sysval_semantic == WINED3D_SV_CULL_DISTANCE)
1796 {
1798 return hr;
1799 reg_maps->cull_distance_mask |= mask;
1800 }
1801 }
1802 }
1803 else if (reg_maps->output_registers)
1804 {
1805 unsigned int count = wined3d_popcount(reg_maps->output_registers);
1807
1808 if (!(output_signature->elements = heap_calloc(count, sizeof(*output_signature->elements))))
1809 return E_OUTOFMEMORY;
1810 output_signature->element_count = count;
1811
1812 e = output_signature->elements;
1813 for (i = 0; i < ARRAY_SIZE(output_signature_elements); ++i)
1814 {
1815 if (!(reg_maps->output_registers & (1u << i)))
1816 continue;
1817 *e++ = output_signature_elements[i];
1818 }
1819 }
1820
1821 return WINED3D_OK;
1822}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
#define ERR(fmt,...)
Definition: precomp.h:57
static HRESULT shader_calculate_clip_or_cull_distance_mask(const struct wined3d_shader_signature_element *e, unsigned int *mask)
Definition: shader.c:959
static void shader_signature_from_usage(struct wined3d_shader_signature_element *e, enum wined3d_decl_usage usage, UINT usage_idx, UINT reg_idx, DWORD write_mask)
Definition: shader.c:394
static void shader_set_limits(struct wined3d_shader *shader)
Definition: shader.c:592
static unsigned int get_instr_extra_regcount(enum WINED3D_SHADER_INSTRUCTION_HANDLER instr, unsigned int param)
Definition: shader.c:857
static void shader_signature_from_semantic(struct wined3d_shader_signature_element *e, const struct wined3d_shader_semantic *s)
Definition: shader.c:382
static HRESULT shader_reg_maps_add_tgsm(struct wined3d_shader_reg_maps *reg_maps, unsigned int register_idx, unsigned int size, unsigned int stride)
Definition: shader.c:877
static HRESULT shader_record_shader_phase(struct wined3d_shader *shader, struct wined3d_shader_phase **current_phase, const struct wined3d_shader_instruction *ins, const DWORD *current_instruction_ptr, const DWORD *previous_instruction_ptr)
Definition: shader.c:904
static void shader_record_sample(struct wined3d_shader_reg_maps *reg_maps, unsigned int resource_idx, unsigned int sampler_idx, unsigned int bind_idx)
Definition: shader.c:812
const char * debug_d3dshaderinstructionhandler(enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx)
Definition: shader.c:334
static BOOL shader_record_register_usage(struct wined3d_shader *shader, struct wined3d_shader_reg_maps *reg_maps, const struct wined3d_shader_register *reg, enum wined3d_shader_type shader_type, unsigned int constf_size)
Definition: shader.c:696
static void wined3d_insert_interpolation_mode(DWORD *packed_interpolation_mode, unsigned int register_idx, enum wined3d_shader_interpolation_mode mode)
Definition: shader.c:976
unsigned int idx
Definition: utils.c:41
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLsizei stride
Definition: glext.h:5848
if(dx< 0)
Definition: linetemp.h:194
#define isinf(x)
Definition: mingw_math.h:94
#define isnan(x)
Definition: mingw_math.h:133
#define min(a, b)
Definition: monoChain.cc:55
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int instance_count
unsigned int temporary_count
UINT cb_sizes[WINED3D_MAX_CBS]
DWORD texcoord_mask[MAX_REG_TEXCRD]
const struct wined3d_shader_immediate_constant_buffer * icb
union wined3d_shader_reg_maps::@273 u
BYTE output_registers_mask[MAX_REG_OUTPUT]
struct wined3d_shader_resource_info uav_resource_info[MAX_UNORDERED_ACCESS_VIEWS]
struct wined3d_shader_signature_element * elements
Definition: wined3d.h:2046
Definition: pdh_main.c:94
@ WINED3D_SV_CULL_DISTANCE
Definition: wined3d.h:806
@ WINED3D_SV_CLIP_DISTANCE
Definition: wined3d.h:805
@ WINED3D_SV_IS_FRONT_FACE
Definition: wined3d.h:812
@ WINED3D_SV_POSITION
Definition: wined3d.h:804
#define WINED3D_VIEW_BUFFER_RAW
Definition: wined3d.h:1573
#define MAX_REG_OUTPUT
@ WINED3DSIH_DSX_COARSE
@ WINED3DSIH_DCL_TESSELLATOR_PARTITIONING
@ WINED3DSIH_DCL_TEMPS
@ WINED3DSIH_GATHER4_PO_C
@ WINED3DSIH_ATOMIC_XOR
@ WINED3DSIH_DSX_FINE
@ WINED3DSIH_DCL_OUTPUT
@ WINED3DSIH_IMM_ATOMIC_XOR
@ WINED3DSIH_TEXREG2RGB
@ WINED3DSIH_TEXLDL
@ WINED3DSIH_DEFI
@ WINED3DSIH_SAMPLE_B
@ WINED3DSIH_DCL_CONSTANT_BUFFER
@ WINED3DSIH_TEXREG2AR
@ WINED3DSIH_TEXREG2GB
@ WINED3DSIH_LOOP
@ WINED3DSIH_DSY_COARSE
@ WINED3DSIH_SAMPLE_LOD
@ WINED3DSIH_LD
@ WINED3DSIH_TEXM3x3TEX
@ WINED3DSIH_SAMPLE_GRAD
@ WINED3DSIH_ATOMIC_AND
@ WINED3DSIH_TEXM3x3VSPEC
@ WINED3DSIH_LD2DMS
@ WINED3DSIH_SAMPLE
@ WINED3DSIH_MOV
@ WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER
@ WINED3DSIH_NRM
@ WINED3DSIH_DCL_THREAD_GROUP
@ WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE
@ WINED3DSIH_LD_RAW
@ WINED3DSIH_GATHER4
@ WINED3DSIH_HS_CONTROL_POINT_PHASE
@ WINED3DSIH_DEFB
@ WINED3DSIH_LD_STRUCTURED
@ WINED3DSIH_IMM_ATOMIC_AND
@ WINED3DSIH_TEXM3x2TEX
@ WINED3DSIH_IMM_ATOMIC_CONSUME
@ WINED3DSIH_HS_FORK_PHASE
@ WINED3DSIH_DSX
@ WINED3DSIH_DCL
@ WINED3DSIH_DCL_VERTICES_OUT
@ WINED3DSIH_CALL
@ WINED3DSIH_HS_JOIN_PHASE
@ WINED3DSIH_ENDREP
@ WINED3DSIH_BEM
@ WINED3DSIH_TEXDP3TEX
@ WINED3DSIH_TEXBEML
@ WINED3DSIH_DCL_OUTPUT_TOPOLOGY
@ WINED3DSIH_TEXM3x3SPEC
@ WINED3DSIH_DCL_SAMPLER
@ WINED3DSIH_TEXBEM
@ WINED3DSIH_DCL_GS_INSTANCES
@ WINED3DSIH_DCL_TGSM_RAW
@ WINED3DSIH_DCL_UAV_TYPED
@ WINED3DSIH_TEXLDD
@ WINED3DSIH_REP
@ WINED3DSIH_IFC
@ WINED3DSIH_SAMPLE_C_LZ
@ WINED3DSIH_ENDLOOP
@ WINED3DSIH_DSY
@ WINED3DSIH_MOVA
@ WINED3DSIH_DCL_INPUT_PS
@ WINED3DSIH_GATHER4_C
@ WINED3DSIH_LD_UAV_TYPED
@ WINED3DSIH_DEF
@ WINED3DSIH_GATHER4_PO
@ WINED3DSIH_DCL_UAV_STRUCTURED
@ WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT
@ WINED3DSIH_DCL_GLOBAL_FLAGS
@ WINED3DSIH_POW
@ WINED3DSIH_BUFINFO
@ WINED3DSIH_IMM_ATOMIC_ALLOC
@ WINED3DSIH_TEX
@ WINED3DSIH_DCL_TESSELLATOR_DOMAIN
@ WINED3DSIH_LABEL
@ WINED3DSIH_RESINFO
@ WINED3DSIH_DCL_TGSM_STRUCTURED
@ WINED3DSIH_SAMPLE_C
@ WINED3DSIH_DCL_UAV_RAW
@ WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT
@ WINED3DSIH_DCL_INDEXABLE_TEMP
@ WINED3DSIH_DCL_RESOURCE_RAW
@ WINED3DSIH_DCL_INPUT_PRIMITIVE
@ WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT
@ WINED3DSIH_DSY_FINE
@ WINED3DSIH_DCL_RESOURCE_STRUCTURED
#define WINED3D_MAX_CBS
#define WINED3DSI_SAMPLER_COMPARISON_MODE
#define MAX_UNORDERED_ACCESS_VIEWS
#define WINED3D_SAMPLER_DEFAULT
@ WINED3DSPR_OUTPUT
@ WINED3D_SHADER_TYPE_DOMAIN
@ WINED3D_SHADER_TYPE_COMPUTE
#define MAX_ATTRIBS
static unsigned int wined3d_popcount(unsigned int x)

Referenced by shader_set_function().

◆ shader_init()

static HRESULT shader_init ( struct wined3d_shader shader,
struct wined3d_device device,
const struct wined3d_shader_desc desc,
DWORD  float_const_count,
enum wined3d_shader_type  type,
void parent,
const struct wined3d_parent_ops parent_ops 
)
static

Definition at line 3582 of file shader.c.

3585{
3586 size_t byte_code_size;
3587 SIZE_T total;
3588 HRESULT hr;
3589 char *ptr;
3590
3591 TRACE("byte_code %p, byte_code_size %#lx, format %#x, max_version %#x.\n",
3592 desc->byte_code, (long)desc->byte_code_size, desc->format, desc->max_version);
3593
3594 if (!desc->byte_code)
3596
3597 if (!(shader->frontend = shader_select_frontend(desc->format)))
3598 {
3599 FIXME("Unable to find frontend for shader.\n");
3601 }
3602
3603 shader->ref = 1;
3604 shader->device = device;
3605 shader->parent = parent;
3606 shader->parent_ops = parent_ops;
3607
3608 total = 0;
3609 if (FAILED(hr = shader_signature_calculate_strings_length(&desc->input_signature, &total)))
3610 return hr;
3611 if (FAILED(hr = shader_signature_calculate_strings_length(&desc->output_signature, &total)))
3612 return hr;
3613 if (FAILED(hr = shader_signature_calculate_strings_length(&desc->patch_constant_signature, &total)))
3614 return hr;
3615 if (total && !(shader->signature_strings = heap_alloc(total)))
3616 return E_OUTOFMEMORY;
3617 ptr = shader->signature_strings;
3618
3619 if (FAILED(hr = shader_signature_copy(&shader->input_signature, &desc->input_signature, &ptr)))
3620 {
3621 heap_free(shader->signature_strings);
3622 return hr;
3623 }
3624 if (FAILED(hr = shader_signature_copy(&shader->output_signature, &desc->output_signature, &ptr)))
3625 {
3626 heap_free(shader->input_signature.elements);
3627 heap_free(shader->signature_strings);
3628 return hr;
3629 }
3630 if (FAILED(hr = shader_signature_copy(&shader->patch_constant_signature, &desc->patch_constant_signature, &ptr)))
3631 {
3632 heap_free(shader->output_signature.elements);
3633 heap_free(shader->input_signature.elements);
3634 heap_free(shader->signature_strings);
3635 return hr;
3636 }
3637
3638 list_init(&shader->linked_programs);
3639 list_init(&shader->constantsF);
3640 list_init(&shader->constantsB);
3641 list_init(&shader->constantsI);
3642 shader->lconst_inf_or_nan = FALSE;
3643 list_init(&shader->reg_maps.indexable_temps);
3644 list_init(&shader->shader_list_entry);
3645
3646 byte_code_size = desc->byte_code_size;
3647 if (byte_code_size == ~(size_t)0)
3648 {
3649 const struct wined3d_shader_frontend *fe = shader->frontend;
3650 struct wined3d_shader_version shader_version;
3651 struct wined3d_shader_instruction ins;
3652 const DWORD *ptr;
3653 void *fe_data;
3654
3655 if (!(fe_data = fe->shader_init(desc->byte_code, byte_code_size, &shader->output_signature)))
3656 {
3657 WARN("Failed to initialise frontend data.\n");
3660 }
3661
3662 fe->shader_read_header(fe_data, &ptr, &shader_version);
3663 while (!fe->shader_is_end(fe_data, &ptr))
3664 fe->shader_read_instruction(fe_data, &ptr, &ins);
3665
3666 fe->shader_free(fe_data);
3667
3668 byte_code_size = (ptr - desc->byte_code) * sizeof(*ptr);
3669 }
3670
3671 if (!(shader->function = heap_alloc(byte_code_size)))
3672 {
3674 return E_OUTOFMEMORY;
3675 }
3676 memcpy(shader->function, desc->byte_code, byte_code_size);
3677 shader->functionLength = byte_code_size;
3678
3679 if (FAILED(hr = shader_set_function(shader, float_const_count, type, desc->max_version)))
3680 {
3681 WARN("Failed to set function, hr %#x.\n", hr);
3683 return hr;
3684 }
3685
3686 shader->load_local_constsF = shader->lconst_inf_or_nan;
3687
3689
3690 return hr;
3691}
void wined3d_cs_init_object(struct wined3d_cs *cs, void(*callback)(void *object), void *object)
Definition: cs.c:1890
static HRESULT shader_signature_calculate_strings_length(const struct wined3d_shader_signature *signature, SIZE_T *total)
Definition: shader.c:3530
static HRESULT shader_signature_copy(struct wined3d_shader_signature *dst, const struct wined3d_shader_signature *src, char **signature_strings)
Definition: shader.c:3549
static const struct wined3d_shader_frontend * shader_select_frontend(enum wined3d_shader_byte_code_format format)
Definition: shader.c:406
static HRESULT shader_set_function(struct wined3d_shader *shader, DWORD float_const_count, enum wined3d_shader_type type, unsigned int max_version)
Definition: shader.c:3266
static void shader_cleanup(struct wined3d_shader *shader)
Definition: shader.c:3088
static void wined3d_shader_init_object(void *object)
Definition: shader.c:3348
size_t total
void *(* shader_init)(const DWORD *byte_code, size_t byte_code_size, const struct wined3d_shader_signature *output_signature)
void(* shader_free)(void *data)
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by geometry_shader_init(), pixel_shader_init(), vertex_shader_init(), wined3d_shader_create_cs(), wined3d_shader_create_ds(), and wined3d_shader_create_hs().

◆ shader_match_semantic()

BOOL shader_match_semantic ( const char semantic_name,
enum wined3d_decl_usage  usage 
)

Definition at line 377 of file shader.c.

378{
379 return !strcmp(semantic_name, shader_semantic_name_from_usage(usage));
380}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static const char * shader_semantic_name_from_usage(enum wined3d_decl_usage usage)
Definition: shader.c:342
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919

Referenced by glsl_is_color_reg_read(), init_output_registers(), init_ps_input(), shader_glsl_generate_vs3_rasterizer_input_setup(), shader_glsl_input_pack(), and shader_glsl_setup_sm3_rasterizer_input().

◆ shader_none_alloc()

static HRESULT shader_none_alloc ( struct wined3d_device device,
const struct wined3d_vertex_pipe_ops vertex_pipe,
const struct fragment_pipeline fragment_pipe 
)
static

Definition at line 3164 of file shader.c.

3166{
3168 void *vertex_priv, *fragment_priv;
3169 struct shader_none_priv *priv;
3170
3171 if (!(priv = heap_alloc(sizeof(*priv))))
3172 return E_OUTOFMEMORY;
3173
3174 if (!(vertex_priv = vertex_pipe->vp_alloc(&none_shader_backend, priv)))
3175 {
3176 ERR("Failed to initialize vertex pipe.\n");
3177 heap_free(priv);
3178 return E_FAIL;
3179 }
3180
3181 if (!(fragment_priv = fragment_pipe->alloc_private(&none_shader_backend, priv)))
3182 {
3183 ERR("Failed to initialize fragment pipe.\n");
3184 vertex_pipe->vp_free(device);
3185 heap_free(priv);
3186 return E_FAIL;
3187 }
3188
3189 priv->vertex_pipe = vertex_pipe;
3191 fragment_pipe->get_caps(&device->adapter->gl_info, &fragment_caps);
3193
3194 device->vertex_priv = vertex_priv;
3195 device->fragment_priv = fragment_priv;
3196 device->shader_priv = priv;
3197
3198 return WINED3D_OK;
3199}
#define E_FAIL
Definition: ddrawi.h:102
const struct wined3d_shader_backend_ops none_shader_backend
Definition: shader.c:3245
const struct fragment_pipeline * fragment_pipe
Definition: shader.c:3120
const struct wined3d_vertex_pipe_ops * vertex_pipe
Definition: shader.c:3119
BOOL ffp_proj_control
Definition: shader.c:3121
#define WINED3D_FRAGMENT_CAP_PROJ_CONTROL

◆ shader_none_allocate_context_data()

static BOOL shader_none_allocate_context_data ( struct wined3d_context context)
static

Definition at line 3210 of file shader.c.

3211{
3212 return TRUE;
3213}

◆ shader_none_color_fixup_supported()

static BOOL shader_none_color_fixup_supported ( struct color_fixup_desc  fixup)
static

Definition at line 3231 of file shader.c.

3232{
3233 /* We "support" every possible fixup, since we don't support any shader
3234 * model, and will never have to actually sample a texture. */
3235 return TRUE;
3236}

◆ shader_none_destroy()

static void shader_none_destroy ( struct wined3d_shader shader)
static

Definition at line 3132 of file shader.c.

3132{}

◆ shader_none_disable()

static void shader_none_disable ( void shader_priv,
struct wined3d_context context 
)
static

Definition at line 3148 of file shader.c.

3149{
3150 struct shader_none_priv *priv = shader_priv;
3151 const struct wined3d_gl_info *gl_info = context->gl_info;
3152
3153 priv->vertex_pipe->vp_enable(gl_info, FALSE);
3154 priv->fragment_pipe->enable_extension(gl_info, FALSE);
3155
3156 context->shader_update_mask = (1u << WINED3D_SHADER_TYPE_PIXEL)
3159 | (1u << WINED3D_SHADER_TYPE_HULL)
3162}

◆ shader_none_free()

static void shader_none_free ( struct wined3d_device device)
static

Definition at line 3201 of file shader.c.

3202{
3203 struct shader_none_priv *priv = device->shader_priv;
3204
3205 priv->fragment_pipe->free_private(device);
3206 priv->vertex_pipe->vp_free(device);
3207 heap_free(priv);
3208}

◆ shader_none_free_context_data()

static void shader_none_free_context_data ( struct wined3d_context context)
static

Definition at line 3133 of file shader.c.

3133{}

◆ shader_none_get_caps()

static void shader_none_get_caps ( const struct wined3d_gl_info gl_info,
struct shader_caps caps 
)
static

Definition at line 3215 of file shader.c.

3216{
3217 /* Set the shader caps to 0 for the none shader backend */
3218 caps->vs_version = 0;
3219 caps->hs_version = 0;
3220 caps->ds_version = 0;
3221 caps->gs_version = 0;
3222 caps->ps_version = 0;
3223 caps->cs_version = 0;
3224 caps->vs_uniform_count = 0;
3225 caps->ps_uniform_count = 0;
3226 caps->ps_1x_max_value = 0.0f;
3227 caps->varying_count = 0;
3228 caps->wined3d_caps = 0;
3229}
unsigned int vs_version
unsigned int cs_version
DWORD vs_uniform_count
DWORD ps_uniform_count
unsigned int hs_version
unsigned int gs_version
unsigned int ps_version
unsigned int ds_version

◆ shader_none_handle_instruction()

static void shader_none_handle_instruction ( const struct wined3d_shader_instruction ins)
static

Definition at line 3124 of file shader.c.

3124{}

◆ shader_none_has_ffp_proj_control()

static BOOL shader_none_has_ffp_proj_control ( void shader_priv)
static

Definition at line 3238 of file shader.c.

3239{
3240 struct shader_none_priv *priv = shader_priv;
3241
3242 return priv->ffp_proj_control;
3243}

◆ shader_none_init_context_state()

static void shader_none_init_context_state ( struct wined3d_context context)
static

Definition at line 3134 of file shader.c.

3134{}

◆ shader_none_load_constants()

static void shader_none_load_constants ( void shader_priv,
struct wined3d_context context,
const struct wined3d_state state 
)
static

Definition at line 3130 of file shader.c.

3131 {}

◆ shader_none_precompile()

static void shader_none_precompile ( void shader_priv,
struct wined3d_shader shader 
)
static

Definition at line 3125 of file shader.c.

3125{}

◆ shader_none_select()

static void shader_none_select ( void shader_priv,
struct wined3d_context context,
const struct wined3d_state state 
)
static

Definition at line 3137 of file shader.c.

3139{
3140 const struct wined3d_gl_info *gl_info = context->gl_info;
3141 struct shader_none_priv *priv = shader_priv;
3142
3143 priv->vertex_pipe->vp_enable(gl_info, !use_vs(state));
3144 priv->fragment_pipe->enable_extension(gl_info, !use_ps(state));
3145}
static BOOL use_ps(const struct wined3d_state *state)

◆ shader_none_select_compute()

static void shader_none_select_compute ( void shader_priv,
struct wined3d_context context,
const struct wined3d_state state 
)
static

Definition at line 3126 of file shader.c.

3127 {}

◆ shader_none_update_float_pixel_constants()

static void shader_none_update_float_pixel_constants ( struct wined3d_device device,
UINT  start,
UINT  count 
)
static

Definition at line 3129 of file shader.c.

3129{}

◆ shader_none_update_float_vertex_constants()

static void shader_none_update_float_vertex_constants ( struct wined3d_device device,
UINT  start,
UINT  count 
)
static

Definition at line 3128 of file shader.c.

3128{}

◆ shader_record_register_usage()

static BOOL shader_record_register_usage ( struct wined3d_shader shader,
struct wined3d_shader_reg_maps reg_maps,
const struct wined3d_shader_register reg,
enum wined3d_shader_type  shader_type,
unsigned int  constf_size 
)
static

Definition at line 696 of file shader.c.

698{
699 switch (re