ReactOS  0.4.13-dev-247-g0f29b3f
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)
 
static enum wined3d_shader_type shader_get_shader_type (const struct wined3d_shader_desc *desc)
 
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_scan_output_signature (struct wined3d_shader *shader)
 
static HRESULT shader_get_registers_used (struct wined3d_shader *shader, 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_precise_flags (struct wined3d_string_buffer *buffer, DWORD 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 }
static const char *const shader_opcode_names[]
Definition: shader.c:40
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
#define ARRAY_SIZE(a)
Definition: main.h:24

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 3836 of file shader.c.

3838 {
3839  const struct wined3d_shader *geometry_shader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY];
3840  const struct wined3d_shader *pixel_shader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
3841  const struct wined3d_shader *hull_shader = state->shader[WINED3D_SHADER_TYPE_HULL];
3842  const struct wined3d_gl_info *gl_info = context->gl_info;
3843 
3844  args->tessellator_output_primitive = hull_shader->u.hs.tessellator_output_primitive;
3845  args->tessellator_partitioning = hull_shader->u.hs.tessellator_partitioning;
3846 
3847  args->output_count = geometry_shader ? geometry_shader->limits->packed_input
3848  : pixel_shader ? pixel_shader->limits->packed_input : shader->limits->packed_output;
3849  args->next_shader_type = geometry_shader ? WINED3D_SHADER_TYPE_GEOMETRY : WINED3D_SHADER_TYPE_PIXEL;
3850 
3851  args->render_offscreen = context->render_offscreen;
3852 
3853  init_interpolation_compile_args(args->interpolation_mode,
3854  args->next_shader_type == WINED3D_SHADER_TYPE_PIXEL ? pixel_shader : NULL, gl_info);
3855 
3856  args->padding = 0;
3857 }
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:3506
const struct wined3d_shader_limits * limits
Definition: http.c:6587
union wined3d_shader::@273 u
Definition: match.c:390
smooth NULL
Definition: ftsmooth.c:416
GLuint shader
Definition: glext.h:6030
static int state
Definition: maze.c:121
struct wined3d_hull_shader hs

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 3859 of file shader.c.

3861 {
3862  const struct wined3d_shader *pixel_shader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
3863  const struct wined3d_gl_info *gl_info = context->gl_info;
3864 
3865  args->output_count = pixel_shader ? pixel_shader->limits->packed_input : shader->limits->packed_output;
3866 
3867  if (!(args->primitive_type = shader->u.gs.input_type))
3868  args->primitive_type = d3d_primitive_type_from_gl(state->gl_primitive_type);
3869 
3870  init_interpolation_compile_args(args->interpolation_mode, pixel_shader, gl_info);
3871 }
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:3506
const struct wined3d_shader_limits * limits
Definition: http.c:6587
Definition: match.c:390
enum wined3d_primitive_type d3d_primitive_type_from_gl(GLenum primitive_type)
Definition: device.c:102
GLuint shader
Definition: glext.h:6030
static int state
Definition: maze.c:121

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 3873 of file shader.c.

3875 {
3876  const struct wined3d_d3d_info *d3d_info = context->d3d_info;
3877  const struct wined3d_gl_info *gl_info = context->gl_info;
3878  const struct wined3d_texture *texture;
3879  unsigned int i;
3880 
3881  memset(args, 0, sizeof(*args)); /* FIXME: Make sure all bits are set. */
3883  {
3884  static unsigned int warned = 0;
3885 
3886  args->srgb_correction = 1;
3887  if (state->render_states[WINED3D_RS_ALPHABLENDENABLE] && !warned++)
3888  WARN("Blending into a sRGB render target with no GL_ARB_framebuffer_sRGB "
3889  "support, expect rendering artifacts.\n");
3890  }
3891 
3892  if (shader->reg_maps.shader_version.major == 1
3893  && shader->reg_maps.shader_version.minor <= 3)
3894  {
3895  for (i = 0; i < shader->limits->sampler; ++i)
3896  {
3898 
3900  {
3901  DWORD tex_transform = flags & ~WINED3D_TTFF_PROJECTED;
3902 
3903  if (!state->shader[WINED3D_SHADER_TYPE_VERTEX])
3904  {
3905  enum wined3d_shader_resource_type resource_type = shader->reg_maps.resource_info[i].type;
3906  unsigned int j;
3907  unsigned int index = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX];
3908  DWORD max_valid = WINED3D_TTFF_COUNT4;
3909 
3910  for (j = 0; j < state->vertex_declaration->element_count; ++j)
3911  {
3913  &state->vertex_declaration->elements[j];
3914 
3915  if (element->usage == WINED3D_DECL_USAGE_TEXCOORD
3916  && element->usage_idx == index)
3917  {
3918  max_valid = element->format->component_count;
3919  break;
3920  }
3921  }
3922  if (!tex_transform || tex_transform > max_valid)
3923  {
3924  WARN("Fixing up projected texture transform flags from %#x to %#x.\n",
3925  tex_transform, max_valid);
3926  tex_transform = max_valid;
3927  }
3928  if ((resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_1D && tex_transform > WINED3D_TTFF_COUNT1)
3929  || (resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_2D
3930  && tex_transform > WINED3D_TTFF_COUNT2)
3931  || (resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_3D
3932  && tex_transform > WINED3D_TTFF_COUNT3))
3933  tex_transform |= WINED3D_PSARGS_PROJECTED;
3934  else
3935  {
3936  WARN("Application requested projected texture with unsuitable texture coordinates.\n");
3937  WARN("(texture unit %u, transform flags %#x, sampler type %u).\n",
3938  i, tex_transform, resource_type);
3939  }
3940  }
3941  else
3943 
3944  args->tex_transform |= tex_transform << i * WINED3D_PSARGS_TEXTRANSFORM_SHIFT;
3945  }
3946  }
3947  }
3948  if (shader->reg_maps.shader_version.major == 1
3949  && shader->reg_maps.shader_version.minor <= 4)
3950  {
3951  for (i = 0; i < shader->limits->sampler; ++i)
3952  {
3953  const struct wined3d_texture *texture = state->textures[i];
3954 
3955  if (!shader->reg_maps.resource_info[i].type)
3956  continue;
3957 
3958  /* Treat unbound textures as 2D. The dummy texture will provide
3959  * the proper sample value. The tex_types bitmap defaults to
3960  * 2D because of the memset. */
3961  if (!texture)
3962  continue;
3963 
3964  switch (texture->target)
3965  {
3966  /* RECT textures are distinguished from 2D textures via np2_fixup */
3967  default:
3968  break;
3969 
3970  case GL_TEXTURE_3D:
3972  break;
3973 
3976  break;
3977  }
3978  }
3979  }
3980 
3981  if (shader->reg_maps.shader_version.major >= 4)
3982  {
3983  /* In SM4+ we use dcl_sampler in order to determine if we should use shadow sampler. */
3984  args->shadow = 0;
3985  for (i = 0 ; i < MAX_FRAGMENT_SAMPLERS; ++i)
3986  args->color_fixup[i] = COLOR_FIXUP_IDENTITY;
3987  args->np2_fixup = 0;
3988  }
3989  else
3990  {
3991  for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
3992  {
3993  if (!shader->reg_maps.resource_info[i].type)
3994  continue;
3995 
3996  texture = state->textures[i];
3997  if (!texture)
3998  {
3999  args->color_fixup[i] = COLOR_FIXUP_IDENTITY;
4000  continue;
4001  }
4002  if (can_use_texture_swizzle(gl_info, texture->resource.format))
4003  args->color_fixup[i] = COLOR_FIXUP_IDENTITY;
4004  else
4005  args->color_fixup[i] = texture->resource.format->color_fixup;
4006 
4007  if (texture->resource.format_flags & WINED3DFMT_FLAG_SHADOW)
4008  args->shadow |= 1u << i;
4009 
4010  /* Flag samplers that need NP2 texcoord fixup. */
4011  if (!(texture->flags & WINED3D_TEXTURE_POW2_MAT_IDENT))
4012  args->np2_fixup |= (1u << i);
4013  }
4014  }
4015 
4016  if (shader->reg_maps.shader_version.major >= 3)
4017  {
4018  if (position_transformed)
4019  args->vp_mode = WINED3D_VP_MODE_NONE;
4020  else if (use_vs(state))
4021  args->vp_mode = WINED3D_VP_MODE_SHADER;
4022  else
4023  args->vp_mode = WINED3D_VP_MODE_FF;
4025  }
4026  else
4027  {
4028  args->vp_mode = WINED3D_VP_MODE_SHADER;
4029  if (state->render_states[WINED3D_RS_FOGENABLE])
4030  {
4031  switch (state->render_states[WINED3D_RS_FOGTABLEMODE])
4032  {
4033  case WINED3D_FOG_NONE:
4034  if (position_transformed || use_vs(state))
4035  {
4037  break;
4038  }
4039 
4040  switch (state->render_states[WINED3D_RS_FOGVERTEXMODE])
4041  {
4042  case WINED3D_FOG_NONE: /* Fall through. */
4044  case WINED3D_FOG_EXP: args->fog = WINED3D_FFP_PS_FOG_EXP; break;
4045  case WINED3D_FOG_EXP2: args->fog = WINED3D_FFP_PS_FOG_EXP2; break;
4046  }
4047  break;
4048 
4050  case WINED3D_FOG_EXP: args->fog = WINED3D_FFP_PS_FOG_EXP; break;
4051  case WINED3D_FOG_EXP2: args->fog = WINED3D_FFP_PS_FOG_EXP2; break;
4052  }
4053  }
4054  else
4055  {
4057  }
4058  }
4059 
4060  if (context->d3d_info->limits.varying_count < wined3d_max_compat_varyings(context->gl_info))
4061  {
4062  const struct wined3d_shader *vs = state->shader[WINED3D_SHADER_TYPE_VERTEX];
4063 
4064  args->texcoords_initialized = 0;
4065  for (i = 0; i < MAX_TEXTURES; ++i)
4066  {
4067  if (vs)
4068  {
4069  if (state->shader[WINED3D_SHADER_TYPE_VERTEX]->reg_maps.output_registers & (1u << i))
4070  args->texcoords_initialized |= 1u << i;
4071  }
4072  else
4073  {
4074  const struct wined3d_stream_info *si = &context->stream_info;
4075  unsigned int coord_idx = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX];
4076 
4077  if ((state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX] >> WINED3D_FFP_TCI_SHIFT)
4079  || (coord_idx < MAX_TEXTURES && (si->use_map & (1u << (WINED3D_FFP_TEXCOORD0 + coord_idx)))))
4080  args->texcoords_initialized |= 1u << i;
4081  }
4082  }
4083  }
4084  else
4085  {
4086  args->texcoords_initialized = (1u << MAX_TEXTURES) - 1;
4087  }
4088 
4089  args->pointsprite = state->render_states[WINED3D_RS_POINTSPRITEENABLE]
4090  && state->gl_primitive_type == GL_POINTS;
4091 
4092  if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
4093  args->alpha_test_func = WINED3D_CMP_ALWAYS - 1;
4094  else
4095  args->alpha_test_func = (state->render_states[WINED3D_RS_ALPHATESTENABLE]
4097  : WINED3D_CMP_ALWAYS) - 1;
4098 
4099  if (d3d_info->emulated_flatshading)
4100  args->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT;
4101 
4102  args->render_offscreen = shader->reg_maps.vpos && gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS]
4103  ? context->render_offscreen : 0;
4104 
4105  args->dual_source_blend = wined3d_dualblend_enabled(state, gl_info);
4106 }
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
#define MAX_TEXTURES
#define GL_POINTS
Definition: gl.h:190
Definition: http.c:6587
#define WINED3D_TEXTURE_POW2_MAT_IDENT
static BOOL can_use_texture_swizzle(const struct wined3d_gl_info *gl_info, const struct wined3d_format *format)
#define WARN(fmt,...)
Definition: debug.h:111
static enum wined3d_cmp_func wined3d_sanitize_cmp_func(enum wined3d_cmp_func func)
#define WINED3D_FFP_TCI_MASK
Definition: match.c:390
#define WINED3D_PSARGS_TEXTYPE_SHIFT
#define GL_TEXTURE_CUBE_MAP_ARB
Definition: glext.h:1230
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
#define WINED3D_PSARGS_TEXTRANSFORM_SHIFT
BOOL supported[WINED3D_GL_EXT_COUNT]
#define GL_TEXTURE_3D
Definition: gl.h:1515
struct wined3d_vertex_shader vs
GLuint index
Definition: glext.h:6031
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 BOOL wined3d_dualblend_enabled(const struct wined3d_state *state, const struct wined3d_gl_info *gl_info)
wined3d_shader_resource_type
GLuint shader
Definition: glext.h:6030
GLenum GLuint texture
Definition: glext.h:6295
#define MAX_FRAGMENT_SAMPLERS
unsigned long DWORD
Definition: ntddk_ex.h:95
static const struct color_fixup_desc COLOR_FIXUP_IDENTITY
GLbitfield flags
Definition: glext.h:7161
static int state
Definition: maze.c:121
#define WINED3D_FFP_TCI_SHIFT
unsigned int wined3d_max_compat_varyings(const struct wined3d_gl_info *gl_info)
Definition: utils.c:5686
#define WINED3D_PSARGS_PROJECTED
static BOOL use_vs(const struct wined3d_state *state)
#define WINED3DFMT_FLAG_SHADOW
#define memset(x, y, z)
Definition: compat.h:39
static BOOL needs_srgb_write(const struct wined3d_context *context, const struct wined3d_state *state, const struct wined3d_fb_state *fb)

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 3520 of file shader.c.

3522 {
3523  const struct wined3d_shader *geometry_shader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY];
3524  const struct wined3d_shader *pixel_shader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
3525  const struct wined3d_shader *hull_shader = state->shader[WINED3D_SHADER_TYPE_HULL];
3526  const struct wined3d_d3d_info *d3d_info = context->d3d_info;
3527  const struct wined3d_gl_info *gl_info = context->gl_info;
3528 
3529  args->fog_src = state->render_states[WINED3D_RS_FOGTABLEMODE]
3531  args->clip_enabled = state->render_states[WINED3D_RS_CLIPPING]
3532  && state->render_states[WINED3D_RS_CLIPPLANEENABLE];
3533  args->point_size = state->gl_primitive_type == GL_POINTS;
3534  args->per_vertex_point_size = shader->reg_maps.point_size;
3535  args->next_shader_type = hull_shader? WINED3D_SHADER_TYPE_HULL
3537  if (shader->reg_maps.shader_version.major >= 4)
3538  args->next_shader_input_count = hull_shader ? hull_shader->limits->packed_input
3539  : geometry_shader ? geometry_shader->limits->packed_input
3540  : pixel_shader ? pixel_shader->limits->packed_input : 0;
3541  else
3542  args->next_shader_input_count = 0;
3543  args->swizzle_map = swizzle_map;
3544  if (d3d_info->emulated_flatshading)
3545  args->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT;
3546  else
3547  args->flatshading = 0;
3548 
3549  init_interpolation_compile_args(args->interpolation_mode,
3550  args->next_shader_type == WINED3D_SHADER_TYPE_PIXEL ? pixel_shader : NULL, gl_info);
3551 }
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:3506
#define GL_POINTS
Definition: gl.h:190
const struct wined3d_shader_limits * limits
Definition: http.c:6587
Definition: match.c:390
smooth NULL
Definition: ftsmooth.c:416
GLuint shader
Definition: glext.h:6030
static int state
Definition: maze.c:121

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 3790 of file shader.c.

3793 {
3794  struct wined3d_shader_desc shader_desc = *desc;
3795  struct wined3d_stream_output_element *elements;
3797  HRESULT hr;
3798 
3799  if (so_desc)
3800  {
3802  switch (shader_type)
3803  {
3805  shader_desc.byte_code = NULL;
3806  shader_desc.byte_code_size = 0;
3807  break;
3809  FIXME("Stream output not supported for %s.\n", debug_shader_type(shader_type));
3810  return E_NOTIMPL;
3811  default:
3812  break;
3813  }
3814  }
3815 
3816  if (FAILED(hr = shader_init(shader, device, &shader_desc, 0,
3817  WINED3D_SHADER_TYPE_GEOMETRY, parent, parent_ops)))
3818  return hr;
3819 
3820  if (so_desc)
3821  {
3822  if (!(elements = heap_calloc(so_desc->element_count, sizeof(*elements))))
3823  {
3825  return E_OUTOFMEMORY;
3826  }
3827 
3828  shader->u.gs.so_desc = *so_desc;
3829  shader->u.gs.so_desc.elements = elements;
3830  memcpy(elements, so_desc->elements, so_desc->element_count * sizeof(*elements));
3831  }
3832 
3833  return WINED3D_OK;
3834 }
unsigned int element_count
Definition: wined3d.h:2073
HRESULT hr
Definition: shlfolder.c:183
const DWORD * byte_code
Definition: wined3d.h:2052
static void * heap_calloc(SIZE_T count, SIZE_T size)
Definition: heap.h:49
size_t byte_code_size
Definition: wined3d.h:2053
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
Definition: devices.h:37
#define FIXME(fmt,...)
Definition: debug.h:110
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
smooth NULL
Definition: ftsmooth.c:416
GLuint shader
Definition: glext.h:6030
r parent
Definition: btrfs.c:2677
LONG HRESULT
Definition: typedefs.h:77
#define WINED3D_OK
Definition: wined3d.h:37
static void shader_cleanup(struct wined3d_shader *shader)
Definition: shader.c:3146
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
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:3639
struct wined3d_stream_output_element * elements
Definition: wined3d.h:2072
#define E_NOTIMPL
Definition: ddrawi.h:99
static enum wined3d_shader_type shader_get_shader_type(const struct wined3d_shader_desc *desc)
Definition: shader.c:422
const char * debug_shader_type(enum wined3d_shader_type type)
Definition: utils.c:4599
wined3d_shader_type

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 870 of file shader.c.

871 {
872  switch (instr)
873  {
874  case WINED3DSIH_M4x4:
875  case WINED3DSIH_M3x4:
876  return param == 1 ? 3 : 0;
877 
878  case WINED3DSIH_M4x3:
879  case WINED3DSIH_M3x3:
880  return param == 1 ? 2 : 0;
881 
882  case WINED3DSIH_M3x2:
883  return param == 1 ? 1 : 0;
884 
885  default:
886  return 0;
887  }
888 }
GLfloat param
Definition: glext.h:5796

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 3506 of file shader.c.

3508 {
3510  || !pixel_shader || pixel_shader->reg_maps.shader_version.major < 4)
3511  {
3512  memset(interpolation_args, 0, sizeof(pixel_shader->u.ps.interpolation_mode));
3513  return;
3514  }
3515 
3516  memcpy(interpolation_args, pixel_shader->u.ps.interpolation_mode,
3517  sizeof(pixel_shader->u.ps.interpolation_mode));
3518 }
struct wined3d_pixel_shader ps
struct wined3d_shader_reg_maps reg_maps
union wined3d_shader::@273 u
static BOOL needs_interpolation_qualifiers_for_shader_outputs(const struct wined3d_gl_info *gl_info)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define memset(x, y, z)
Definition: compat.h:39

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 3553 of file shader.c.

3554 {
3555  if (usage_idx1 != usage_idx2)
3556  return FALSE;
3557  if (usage1 == usage2)
3558  return TRUE;
3559  if (usage1 == WINED3D_DECL_USAGE_POSITION && usage2 == WINED3D_DECL_USAGE_POSITIONT)
3560  return TRUE;
3561  if (usage2 == WINED3D_DECL_USAGE_POSITION && usage1 == WINED3D_DECL_USAGE_POSITIONT)
3562  return TRUE;
3563 
3564  return FALSE;
3565 }
#define TRUE
Definition: types.h:120

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 4108 of file shader.c.

4110 {
4111  const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
4112  unsigned int i, highest_reg_used = 0, num_regs_used = 0;
4113  HRESULT hr;
4114 
4115  if (FAILED(hr = shader_init(shader, device, desc, device->adapter->d3d_info.limits.ps_uniform_count,
4116  WINED3D_SHADER_TYPE_PIXEL, parent, parent_ops)))
4117  return hr;
4118 
4119  for (i = 0; i < MAX_REG_INPUT; ++i)
4120  {
4121  if (shader->u.ps.input_reg_used & (1u << i))
4122  {
4123  ++num_regs_used;
4124  highest_reg_used = i;
4125  }
4126  }
4127 
4128  /* Don't do any register mapping magic if it is not needed, or if we can't
4129  * achieve anything anyway */
4130  if (highest_reg_used < (gl_info->limits.glsl_varyings / 4)
4131  || num_regs_used > (gl_info->limits.glsl_varyings / 4)
4132  || shader->reg_maps.shader_version.major >= 4)
4133  {
4134  if (num_regs_used > (gl_info->limits.glsl_varyings / 4))
4135  {
4136  /* This happens with relative addressing. The input mapper function
4137  * warns about this if the higher registers are declared too, so
4138  * don't write a FIXME here */
4139  WARN("More varying registers used than supported\n");
4140  }
4141 
4142  for (i = 0; i < MAX_REG_INPUT; ++i)
4143  {
4144  shader->u.ps.input_reg_map[i] = i;
4145  }
4146 
4147  shader->u.ps.declared_in_count = highest_reg_used + 1;
4148  }
4149  else
4150  {
4151  shader->u.ps.declared_in_count = 0;
4152  for (i = 0; i < MAX_REG_INPUT; ++i)
4153  {
4154  if (shader->u.ps.input_reg_used & (1u << i))
4155  shader->u.ps.input_reg_map[i] = shader->u.ps.declared_in_count++;
4156  else shader->u.ps.input_reg_map[i] = ~0U;
4157  }
4158  }
4159 
4160  return WINED3D_OK;
4161 }
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
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:111
#define U(x)
Definition: wordpad.c:44
#define MAX_REG_INPUT
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
Definition: devices.h:37
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
GLuint shader
Definition: glext.h:6030
r parent
Definition: btrfs.c:2677
LONG HRESULT
Definition: typedefs.h:77
#define WINED3D_OK
Definition: wined3d.h:37
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:3639
struct wined3d_gl_limits limits

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 4163 of file shader.c.

4164 {
4165  struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
4166  struct wined3d_shader_resource_info *resource_info = reg_maps->resource_info;
4167  unsigned int i;
4168 
4169  if (reg_maps->shader_version.major != 1) return;
4170 
4171  for (i = 0; i < shader->limits->sampler; ++i)
4172  {
4173  /* We don't sample from this sampler. */
4174  if (!resource_info[i].type)
4175  continue;
4176 
4177  switch ((tex_types >> i * WINED3D_PSARGS_TEXTYPE_SHIFT) & WINED3D_PSARGS_TEXTYPE_MASK)
4178  {
4179  case WINED3D_SHADER_TEX_2D:
4180  resource_info[i].type = WINED3D_SHADER_RESOURCE_TEXTURE_2D;
4181  break;
4182 
4183  case WINED3D_SHADER_TEX_3D:
4184  resource_info[i].type = WINED3D_SHADER_RESOURCE_TEXTURE_3D;
4185  break;
4186 
4188  resource_info[i].type = WINED3D_SHADER_RESOURCE_TEXTURE_CUBE;
4189  break;
4190  }
4191  }
4192 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
struct wined3d_shader_resource_info resource_info[MAX_SHADER_RESOURCE_VIEWS]
#define WINED3D_PSARGS_TEXTYPE_SHIFT
#define WINED3D_PSARGS_TEXTYPE_MASK
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
GLuint shader
Definition: glext.h:6030
enum wined3d_shader_resource_type type
struct wined3d_shader_version shader_version

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 487 of file shader.c.

488 {
489  va_list args;
490  int ret;
491 
492  for (;;)
493  {
494  va_start(args, format);
496  va_end(args);
497  if (!ret)
498  return ret;
500  return -1;
501  }
502 }
int shader_vaddline(struct wined3d_string_buffer *buffer, const char *format, va_list args)
Definition: shader.c:473
GLuint buffer
Definition: glext.h:5915
Definition: match.c:390
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
BOOL string_buffer_resize(struct wined3d_string_buffer *buffer, int rc)
Definition: shader.c:455
int ret
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define args
Definition: format.c:66

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_packed_yuv_read(), gen_yuv_shader(), gen_yv12_read(), get_argreg(), glsl_blitter_generate_p8_shader(), glsl_blitter_generate_plain_shader(), glsl_blitter_generate_program(), glsl_blitter_generate_yuv_shader(), 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_precise_flags(), 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_sample_info(), 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 972 of file shader.c.

974 {
975  /* Clip and cull distances are packed in 4 component registers. 0 and 1 are
976  * the only allowed semantic indices.
977  */
978  if (e->semantic_idx >= MAX_CLIP_DISTANCES / 4)
979  {
980  *mask = 0;
981  WARN("Invalid clip/cull distance index %u.\n", e->semantic_idx);
982  return WINED3DERR_INVALIDCALL;
983  }
984 
985  *mask = (e->mask & WINED3DSP_WRITEMASK_ALL) << (4 * e->semantic_idx);
986  return WINED3D_OK;
987 }
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
#define WARN(fmt,...)
Definition: debug.h:111
GLenum GLint GLuint mask
Definition: glext.h:6028
#define e
Definition: ke_i.h:82
#define WINED3D_OK
Definition: wined3d.h:37
#define MAX_CLIP_DISTANCES
#define WINED3DSP_WRITEMASK_ALL

Referenced by shader_scan_output_signature().

◆ shader_cleanup()

static void shader_cleanup ( struct wined3d_shader shader)
static

Definition at line 3146 of file shader.c.

3147 {
3148  if (shader->reg_maps.shader_version.type == WINED3D_SHADER_TYPE_HULL)
3149  {
3150  heap_free(shader->u.hs.phases.control_point);
3151  heap_free(shader->u.hs.phases.fork);
3152  heap_free(shader->u.hs.phases.join);
3153  }
3154  else if (shader->reg_maps.shader_version.type == WINED3D_SHADER_TYPE_GEOMETRY)
3155  {
3156  heap_free(shader->u.gs.so_desc.elements);
3157  }
3158 
3159  heap_free(shader->patch_constant_signature.elements);
3160  heap_free(shader->output_signature.elements);
3161  heap_free(shader->input_signature.elements);
3162  heap_free(shader->signature_strings);
3163  shader->device->shader_backend->shader_destroy(shader);
3164  shader_cleanup_reg_maps(&shader->reg_maps);
3165  heap_free(shader->function);
3166  shader_delete_constant_list(&shader->constantsF);
3167  shader_delete_constant_list(&shader->constantsB);
3168  shader_delete_constant_list(&shader->constantsI);
3169  list_remove(&shader->shader_list_entry);
3170 
3171  if (shader->frontend && shader->frontend_data)
3172  shader->frontend->shader_free(shader->frontend_data);
3173 }
static void shader_delete_constant_list(struct list *clist)
Definition: shader.c:592
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
GLuint shader
Definition: glext.h:6030
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
static void shader_cleanup_reg_maps(struct wined3d_shader_reg_maps *reg_maps)
Definition: shader.c:1857

Referenced by geometry_shader_init(), 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 1857 of file shader.c.

1858 {
1859  struct wined3d_shader_indexable_temp *reg, *reg_next;
1860 
1861  heap_free(reg_maps->constf);
1862  heap_free(reg_maps->sampler_map.entries);
1863 
1865  heap_free(reg);
1866  list_init(&reg_maps->indexable_temps);
1867 
1868  heap_free(reg_maps->tgsm);
1869 }
struct wined3d_shader_tgsm * tgsm
uint32_t entry
Definition: isohybrid.c:63
struct wined3d_shader_sampler_map sampler_map
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
static int reg
Definition: i386-dis.c:1275
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by shader_cleanup().

◆ shader_delete_constant_list()

static void shader_delete_constant_list ( struct list clist)
static

Definition at line 592 of file shader.c.

593 {
594  struct wined3d_shader_lconst *constant, *constant_next;
595 
596  LIST_FOR_EACH_ENTRY_SAFE(constant, constant_next, clist, struct wined3d_shader_lconst, entry)
598  list_init(clist);
599 }
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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 2042 of file shader.c.

2045 {
2046  shader_addline(buffer, "dcl");
2047 
2048  if (semantic->reg.reg.type == WINED3DSPR_SAMPLER)
2049  {
2050  switch (semantic->resource_type)
2051  {
2053  shader_addline(buffer, "_2d");
2054  break;
2055 
2057  shader_addline(buffer, "_3d");
2058  break;
2059 
2061  shader_addline(buffer, "_cube");
2062  break;
2063 
2064  default:
2065  shader_addline(buffer, "_unknown_resource_type(%#x)", semantic->resource_type);
2066  break;
2067  }
2068  }
2069  else if (semantic->reg.reg.type == WINED3DSPR_RESOURCE || semantic->reg.reg.type == WINED3DSPR_UAV)
2070  {
2071  if (semantic->reg.reg.type == WINED3DSPR_RESOURCE)
2072  shader_addline(buffer, "_resource_");
2073  else
2074  shader_addline(buffer, "_uav_");
2075  switch (semantic->resource_type)
2076  {
2078  shader_addline(buffer, "buffer");
2079  break;
2080 
2082  shader_addline(buffer, "texture1d");
2083  break;
2084 
2086  shader_addline(buffer, "texture2d");
2087  break;
2088 
2090  shader_addline(buffer, "texture2dms");
2091  break;
2092 
2094  shader_addline(buffer, "texture3d");
2095  break;
2096 
2098  shader_addline(buffer, "texturecube");
2099  break;
2100 
2102  shader_addline(buffer, "texture1darray");
2103  break;
2104 
2106  shader_addline(buffer, "texture2darray");
2107  break;
2108 
2110  shader_addline(buffer, "texture2dmsarray");
2111  break;
2112 
2114  shader_addline(buffer, "texturecubearray");
2115  break;
2116 
2117  default:
2118  shader_addline(buffer, "unknown");
2119  break;
2120  }
2121  if (semantic->reg.reg.type == WINED3DSPR_UAV)
2123  switch (semantic->resource_data_type)
2124  {
2125  case WINED3D_DATA_FLOAT:
2126  shader_addline(buffer, " (float)");
2127  break;
2128 
2129  case WINED3D_DATA_INT:
2130  shader_addline(buffer, " (int)");
2131  break;
2132 
2133  case WINED3D_DATA_UINT:
2134  shader_addline(buffer, " (uint)");
2135  break;
2136 
2137  case WINED3D_DATA_UNORM:
2138  shader_addline(buffer, " (unorm)");
2139  break;
2140 
2141  case WINED3D_DATA_SNORM:
2142  shader_addline(buffer, " (snorm)");
2143  break;
2144 
2145  default:
2146  shader_addline(buffer, " (unknown)");
2147  break;
2148  }
2149  }
2150  else
2151  {
2152  /* Pixel shaders 3.0 don't have usage semantics. */
2153  if (shader_version->major < 3 && shader_version->type == WINED3D_SHADER_TYPE_PIXEL)
2154  return;
2155  else
2156  shader_addline(buffer, "_");
2157 
2158  switch (semantic->usage)
2159  {
2161  shader_addline(buffer, "position%u", semantic->usage_idx);
2162  break;
2163 
2165  shader_addline(buffer, "blend");
2166  break;
2167 
2169  shader_addline(buffer, "weight");
2170  break;
2171 
2173  shader_addline(buffer, "normal%u", semantic->usage_idx);
2174  break;
2175 
2177  shader_addline(buffer, "psize");
2178  break;
2179 
2181  if (!semantic->usage_idx)
2182  shader_addline(buffer, "color");
2183  else
2184  shader_addline(buffer, "specular%u", (semantic->usage_idx - 1));
2185  break;
2186 
2188  shader_addline(buffer, "texture%u", semantic->usage_idx);
2189  break;
2190 
2192  shader_addline(buffer, "tangent");
2193  break;
2194 
2196  shader_addline(buffer, "binormal");
2197  break;
2198 
2200  shader_addline(buffer, "tessfactor");
2201  break;
2202 
2204  shader_addline(buffer, "positionT%u", semantic->usage_idx);
2205  break;
2206 
2208  shader_addline(buffer, "fog");
2209  break;
2210 
2212  shader_addline(buffer, "depth");
2213  break;
2214 
2216  shader_addline(buffer, "sample");
2217  break;
2218 
2219  default:
2220  shader_addline(buffer, "<unknown_semantic(%#x)>", semantic->usage);
2221  FIXME("Unrecognised semantic usage %#x.\n", semantic->usage);
2222  }
2223  }
2224 }
enum wined3d_shader_type type
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
GLuint buffer
Definition: glext.h:5915
static void shader_dump_uav_flags(struct wined3d_string_buffer *buffer, DWORD uav_flags)
Definition: shader.c:1942
enum wined3d_decl_usage usage
#define FIXME(fmt,...)
Definition: debug.h:110
enum wined3d_shader_resource_type resource_type
GLbitfield flags
Definition: glext.h:7161
enum wined3d_data_type resource_data_type
struct wined3d_shader_dst_param reg

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 2525 of file shader.c.

2527 {
2528  DWORD write_mask = param->write_mask;
2529 
2530  shader_dump_register(buffer, &param->reg, shader_version);
2531 
2532  if (write_mask && write_mask != WINED3DSP_WRITEMASK_ALL)
2533  {
2534  static const char write_mask_chars[] = "xyzw";
2535 
2536  shader_addline(buffer, ".");
2537  if (write_mask & WINED3DSP_WRITEMASK_0)
2538  shader_addline(buffer, "%c", write_mask_chars[0]);
2539  if (write_mask & WINED3DSP_WRITEMASK_1)
2540  shader_addline(buffer, "%c", write_mask_chars[1]);
2541  if (write_mask & WINED3DSP_WRITEMASK_2)
2542  shader_addline(buffer, "%c", write_mask_chars[2]);
2543  if (write_mask & WINED3DSP_WRITEMASK_3)
2544  shader_addline(buffer, "%c", write_mask_chars[3]);
2545  }
2546 }
#define WINED3DSP_WRITEMASK_0
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
GLuint buffer
Definition: glext.h:5915
GLfloat param
Definition: glext.h:5796
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WINED3DSP_WRITEMASK_1
#define WINED3DSP_WRITEMASK_2
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:2226
#define WINED3DSP_WRITEMASK_ALL
#define WINED3DSP_WRITEMASK_3

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 1880 of file shader.c.

1881 {
1882  if (global_flags & WINED3DSGF_REFACTORING_ALLOWED)
1883  {
1884  shader_addline(buffer, "refactoringAllowed");
1885  global_flags &= ~WINED3DSGF_REFACTORING_ALLOWED;
1886  if (global_flags)
1887  shader_addline(buffer, " | ");
1888  }
1889 
1890  if (global_flags & WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL)
1891  {
1892  shader_addline(buffer, "forceEarlyDepthStencil");
1893  global_flags &= ~WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL;
1894  if (global_flags)
1895  shader_addline(buffer, " | ");
1896  }
1897 
1899  {
1900  shader_addline(buffer, "enableRawAndStructuredBuffers");
1902  }
1903 
1904  if (global_flags)
1905  shader_addline(buffer, "unknown_flags(%#x)", global_flags);
1906 }
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
GLuint buffer
Definition: glext.h:5915

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 2667 of file shader.c.

2669 {
2670  DWORD mmask = dst->modifiers;
2671 
2672  switch (dst->shift)
2673  {
2674  case 0: break;
2675  case 13: shader_addline(buffer, "_d8"); break;
2676  case 14: shader_addline(buffer, "_d4"); break;
2677  case 15: shader_addline(buffer, "_d2"); break;
2678  case 1: shader_addline(buffer, "_x2"); break;
2679  case 2: shader_addline(buffer, "_x4"); break;
2680  case 3: shader_addline(buffer, "_x8"); break;
2681  default: shader_addline(buffer, "_unhandled_shift(%d)", dst->shift); break;
2682  }
2683 
2684  if (mmask & WINED3DSPDM_SATURATE) shader_addline(buffer, "_sat");
2685  if (mmask & WINED3DSPDM_PARTIALPRECISION) shader_addline(buffer, "_pp");
2686  if (mmask & WINED3DSPDM_MSAMPCENTROID) shader_addline(buffer, "_centroid");
2687 
2689  if (mmask) FIXME("Unrecognised modifier %#x.\n", mmask);
2690 }
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
GLuint buffer
Definition: glext.h:5915
#define FIXME(fmt,...)
Definition: debug.h:110
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLenum dst
Definition: glext.h:6340

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 2739 of file shader.c.

2741 {
2742  switch (interpolation_mode)
2743  {
2744  case WINED3DSIM_CONSTANT:
2745  shader_addline(buffer, "constant");
2746  break;
2747  case WINED3DSIM_LINEAR:
2748  shader_addline(buffer, "linear");
2749  break;
2751  shader_addline(buffer, "linear centroid");
2752  break;
2754  shader_addline(buffer, "linear noperspective");
2755  break;
2757  shader_addline(buffer, "linear sample");
2758  break;
2760  shader_addline(buffer, "linear noperspective centroid");
2761  break;
2763  shader_addline(buffer, "linear noperspective sample");
2764  break;
2765  default:
2766  shader_addline(buffer, "<unrecognized_interpolation_mode %#x>", interpolation_mode);
2767  break;
2768  }
2769 }
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
GLuint buffer
Definition: glext.h:5915

Referenced by shader_trace_init().

◆ shader_dump_precise_flags()

static void shader_dump_precise_flags ( struct wined3d_string_buffer buffer,
DWORD  flags 
)
static

Definition at line 1925 of file shader.c.

1926 {
1927  if (!(flags & WINED3DSI_PRECISE_XYZW))
1928  return;
1929 
1930  shader_addline(buffer, " [precise");
1932  {
1933  shader_addline(buffer, "(%s%s%s%s)",
1934  flags & WINED3DSI_PRECISE_X ? "x" : "",
1935  flags & WINED3DSI_PRECISE_Y ? "y" : "",
1936  flags & WINED3DSI_PRECISE_Z ? "z" : "",
1937  flags & WINED3DSI_PRECISE_W ? "w" : "");
1938  }
1939  shader_addline(buffer, "]");
1940 }
#define WINED3DSI_PRECISE_X
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
#define WINED3DSI_PRECISE_Y
#define WINED3DSI_PRECISE_XYZW
GLuint buffer
Definition: glext.h:5915
#define WINED3DSI_PRECISE_W
GLbitfield flags
Definition: glext.h:7161
#define WINED3DSI_PRECISE_Z

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 2692 of file shader.c.

2694 {
2695  switch (primitive_type->type)
2696  {
2697  case WINED3D_PT_UNDEFINED:
2698  shader_addline(buffer, "undefined");
2699  break;
2700  case WINED3D_PT_POINTLIST:
2701  shader_addline(buffer, "pointlist");
2702  break;
2703  case WINED3D_PT_LINELIST:
2704  shader_addline(buffer, "linelist");
2705  break;
2706  case WINED3D_PT_LINESTRIP:
2707  shader_addline(buffer, "linestrip");
2708  break;
2710  shader_addline(buffer, "trianglelist");
2711  break;
2713  shader_addline(buffer, "trianglestrip");
2714  break;
2716  shader_addline(buffer, "trianglefan");
2717  break;
2719  shader_addline(buffer, "linelist_adj");
2720  break;
2722  shader_addline(buffer, "linestrip_adj");
2723  break;
2725  shader_addline(buffer, "trianglelist_adj");
2726  break;
2728  shader_addline(buffer, "trianglestrip_adj");
2729  break;
2730  case WINED3D_PT_PATCH:
2731  shader_addline(buffer, "patch%u", primitive_type->patch_vertex_count);
2732  break;
2733  default:
2734  shader_addline(buffer, "<unrecognized_primitive_type %#x>", primitive_type->type);
2735  break;
2736  }
2737 }
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
enum wined3d_primitive_type type
GLuint buffer
Definition: glext.h:5915

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 2226 of file shader.c.

2228 {
2229  static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"};
2230  static const char * const misctype_reg_names[] = {"vPos", "vFace"};
2231  UINT offset = reg->idx[0].offset;
2232 
2233  switch (reg->type)
2234  {
2235  case WINED3DSPR_TEMP:
2236  shader_addline(buffer, "r");
2237  break;
2238 
2239  case WINED3DSPR_INPUT:
2240  shader_addline(buffer, "v");
2241  break;
2242 
2243  case WINED3DSPR_CONST:
2244  case WINED3DSPR_CONST2:
2245  case WINED3DSPR_CONST3:
2246  case WINED3DSPR_CONST4:
2247  shader_addline(buffer, "c");
2249  break;
2250 
2251  case WINED3DSPR_TEXTURE: /* vs: case WINED3DSPR_ADDR */
2252  shader_addline(buffer, "%c", shader_version->type == WINED3D_SHADER_TYPE_PIXEL ? 't' : 'a');
2253  break;
2254 
2255  case WINED3DSPR_RASTOUT:
2256  shader_addline(buffer, "%s", rastout_reg_names[offset]);
2257  break;
2258 
2259  case WINED3DSPR_COLOROUT:
2260  shader_addline(buffer, "oC");
2261  break;
2262 
2263  case WINED3DSPR_DEPTHOUT:
2264  shader_addline(buffer, "oDepth");
2265  break;
2266 
2267  case WINED3DSPR_DEPTHOUTGE:
2268  shader_addline(buffer, "oDepthGE");
2269  break;
2270 
2271  case WINED3DSPR_DEPTHOUTLE:
2272  shader_addline(buffer, "oDepthLE");
2273  break;
2274 
2275  case WINED3DSPR_ATTROUT:
2276  shader_addline(buffer, "oD");
2277  break;
2278 
2279  case WINED3DSPR_TEXCRDOUT:
2280  /* Vertex shaders >= 3.0 use general purpose output registers
2281  * (WINED3DSPR_OUTPUT), which can include an address token. */
2282  if (shader_version->major >= 3)
2283  shader_addline(buffer, "o");
2284  else
2285  shader_addline(buffer, "oT");
2286  break;
2287 
2288  case WINED3DSPR_CONSTINT:
2289  shader_addline(buffer, "i");
2290  break;
2291 
2292  case WINED3DSPR_CONSTBOOL:
2293  shader_addline(buffer, "b");
2294  break;
2295 
2296  case WINED3DSPR_LABEL:
2297  shader_addline(buffer, "l");
2298  break;
2299 
2300  case WINED3DSPR_LOOP:
2301  shader_addline(buffer, "aL");
2302  break;
2303 
2304  case WINED3DSPR_SAMPLER:
2305  shader_addline(buffer, "s");
2306  break;
2307 
2308  case WINED3DSPR_MISCTYPE:
2309  if (offset > 1)
2310  {
2311  FIXME("Unhandled misctype register %u.\n", offset);
2312  shader_addline(buffer, "<unhandled misctype %#x>", offset);
2313  }
2314  else
2315  {
2316  shader_addline(buffer, "%s", misctype_reg_names[offset]);
2317  }
2318  break;
2319 
2320  case WINED3DSPR_PREDICATE:
2321  shader_addline(buffer, "p");
2322  break;
2323 
2324  case WINED3DSPR_IMMCONST:
2325  shader_addline(buffer, "l");
2326  break;
2327 
2329  shader_addline(buffer, "cb");
2330  break;
2331 
2333  shader_addline(buffer, "icb");
2334  break;
2335 
2336  case WINED3DSPR_PRIMID:
2337  shader_addline(buffer, "primID");
2338  break;
2339 
2340  case WINED3DSPR_NULL:
2341  shader_addline(buffer, "null");
2342  break;
2343 
2344  case WINED3DSPR_RASTERIZER:
2345  shader_addline(buffer, "rasterizer");
2346  break;
2347 
2348  case WINED3DSPR_RESOURCE:
2349  shader_addline(buffer, "t");
2350  break;
2351 
2352  case WINED3DSPR_UAV:
2353  shader_addline(buffer, "u");
2354  break;
2355 
2356  case WINED3DSPR_OUTPOINTID:
2357  shader_addline(buffer, "vOutputControlPointID");
2358  break;
2359 
2360  case WINED3DSPR_FORKINSTID:
2361  shader_addline(buffer, "vForkInstanceId");
2362  break;
2363 
2364  case WINED3DSPR_JOININSTID:
2365  shader_addline(buffer, "vJoinInstanceId");
2366  break;
2367 
2369  shader_addline(buffer, "vicp");
2370  break;
2371 
2373  shader_addline(buffer, "vocp");
2374  break;
2375 
2376  case WINED3DSPR_PATCHCONST:
2377  shader_addline(buffer, "vpc");
2378  break;
2379 
2380  case WINED3DSPR_TESSCOORD:
2381  shader_addline(buffer, "vDomainLocation");
2382  break;
2383 
2385  shader_addline(buffer, "g");
2386  break;
2387 
2388  case WINED3DSPR_THREADID:
2389  shader_addline(buffer, "vThreadID");
2390  break;
2391 
2393  shader_addline(buffer, "vThreadGroupID");
2394  break;
2395 
2397  shader_addline(buffer, "vThreadIDInGroup");
2398  break;
2399 
2401  shader_addline(buffer, "vThreadIDInGroupFlattened");
2402  break;
2403 
2404  case WINED3DSPR_IDXTEMP:
2405  shader_addline(buffer, "x");
2406  break;
2407 
2408  case WINED3DSPR_STREAM:
2409  shader_addline(buffer, "m");
2410  break;
2411 
2413  shader_addline(buffer, "fb");
2414  break;
2415 
2417  shader_addline(buffer, "fp");
2418  break;
2419 
2420  case WINED3DSPR_COVERAGE:
2421  shader_addline(buffer, "vCoverage");
2422  break;
2423 
2424  case WINED3DSPR_SAMPLEMASK:
2425  shader_addline(buffer, "oMask");
2426  break;
2427 
2428  case WINED3DSPR_GSINSTID:
2429  shader_addline(buffer, "vGSInstanceID");
2430  break;
2431 
2432  default:
2433  shader_addline(buffer, "<unhandled_rtype(%#x)>", reg->type);
2434  break;
2435  }
2436 
2437  if (reg->type == WINED3DSPR_IMMCONST)
2438  {
2439  shader_addline(buffer, "(");
2440  switch (reg->immconst_type)
2441  {
2443  switch (reg->data_type)
2444  {
2445  case WINED3D_DATA_FLOAT:
2446  shader_addline(buffer, "%.8e", *(const float *)reg->u.immconst_data);
2447  break;
2448  case WINED3D_DATA_INT:
2449  shader_addline(buffer, "%d", reg->u.immconst_data[0]);
2450  break;
2451  case WINED3D_DATA_RESOURCE:
2452  case WINED3D_DATA_SAMPLER:
2453  case WINED3D_DATA_UINT:
2454  shader_addline(buffer, "%u", reg->u.immconst_data[0]);
2455  break;
2456  default:
2457  shader_addline(buffer, "<unhandled data type %#x>", reg->data_type);
2458  break;
2459  }
2460  break;
2461 
2462  case WINED3D_IMMCONST_VEC4:
2463  switch (reg->data_type)
2464  {
2465  case WINED3D_DATA_FLOAT:
2466  shader_addline(buffer, "%.8e, %.8e, %.8e, %.8e",
2467  *(const float *)&reg->u.immconst_data[0], *(const float *)&reg->u.immconst_data[1],
2468  *(const float *)&reg->u.immconst_data[2], *(const float *)&reg->u.immconst_data[3]);
2469  break;
2470  case WINED3D_DATA_INT:
2471  shader_addline(buffer, "%d, %d, %d, %d",
2472  reg->u.immconst_data[0], reg->u.immconst_data[1],
2473  reg->u.immconst_data[2], reg->u.immconst_data[3]);
2474  break;
2475  case WINED3D_DATA_RESOURCE:
2476  case WINED3D_DATA_SAMPLER:
2477  case WINED3D_DATA_UINT:
2478  shader_addline(buffer, "%u, %u, %u, %u",
2479  reg->u.immconst_data[0], reg->u.immconst_data[1],
2480  reg->u.immconst_data[2], reg->u.immconst_data[3]);
2481  break;
2482  default:
2483  shader_addline(buffer, "<unhandled data type %#x>", reg->data_type);
2484  break;
2485  }
2486  break;
2487 
2488  default:
2489  shader_addline(buffer, "<unhandled immconst_type %#x>", reg->immconst_type);
2490  break;
2491  }
2492  shader_addline(buffer, ")");
2493  }
2494  else if (reg->type != WINED3DSPR_RASTOUT
2495  && reg->type != WINED3DSPR_MISCTYPE
2496  && reg->type != WINED3DSPR_NULL)
2497  {
2498  if (offset != ~0u)
2499  {
2500  shader_addline(buffer, "[");
2501  if (reg->idx[0].rel_addr)
2502  {
2503  shader_dump_src_param(buffer, reg->idx[0].rel_addr, shader_version);
2504  shader_addline(buffer, " + ");
2505  }
2506  shader_addline(buffer, "%u]", offset);
2507 
2508  if (reg->idx[1].offset != ~0u)
2509  {
2510  shader_addline(buffer, "[");
2511  if (reg->idx[1].rel_addr)
2512  {
2513  shader_dump_src_param(buffer, reg->idx[1].rel_addr, shader_version);
2514  shader_addline(buffer, " + ");
2515  }
2516  shader_addline(buffer, "%u]", reg->idx[1].offset);
2517  }
2518  }
2519 
2520  if (reg->type == WINED3DSPR_FUNCTIONPOINTER)
2521  shader_addline(buffer, "[%u]", reg->u.fp_body_idx);
2522  }
2523 }
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
enum wined3d_shader_type type
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
GLintptr offset
Definition: glext.h:5920
GLuint buffer
Definition: glext.h:5915
#define FIXME(fmt,...)
Definition: debug.h:110
static unsigned int shader_get_float_offset(enum wined3d_shader_register_type register_type, UINT register_idx)
Definition: shader.c:578
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:2548
unsigned int UINT
Definition: ndis.h:50
static int reg
Definition: i386-dis.c:1275

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 2025 of file shader.c.

2027 {
2028  unsigned int i;
2029 
2031  {
2033  {
2035  return;
2036  }
2037  }
2038 
2039  shader_addline(buffer, "unknown_shader_input_sysval_semantic(%#x)", semantic);
2040 }
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
enum wined3d_shader_input_sysval_semantic sysval_semantic
Definition: shader.c:302
GLuint buffer
Definition: glext.h:5915
static const struct @262 shader_input_sysval_semantic_names[]
const char * sysval_name
Definition: shader.c:303
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
#define ARRAY_SIZE(a)
Definition: main.h:24

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 2548 of file shader.c.

2550 {
2551  enum wined3d_shader_src_modifier src_modifier = param->modifiers;
2552  DWORD swizzle = param->swizzle;
2553 
2554  if (src_modifier == WINED3DSPSM_NEG
2555  || src_modifier == WINED3DSPSM_BIASNEG
2556  || src_modifier == WINED3DSPSM_SIGNNEG
2557  || src_modifier == WINED3DSPSM_X2NEG
2558  || src_modifier == WINED3DSPSM_ABSNEG)
2559  shader_addline(buffer, "-");
2560  else if (src_modifier == WINED3DSPSM_COMP)
2561  shader_addline(buffer, "1-");
2562  else if (src_modifier == WINED3DSPSM_NOT)
2563  shader_addline(buffer, "!");
2564 
2565  if (src_modifier == WINED3DSPSM_ABS || src_modifier == WINED3DSPSM_ABSNEG)
2566  shader_addline(buffer, "abs(");
2567 
2568  shader_dump_register(buffer, &param->reg, shader_version);
2569 
2570  switch (src_modifier)
2571  {
2572  case WINED3DSPSM_NONE: break;
2573  case WINED3DSPSM_NEG: break;
2574  case WINED3DSPSM_NOT: break;
2575  case WINED3DSPSM_BIAS: shader_addline(buffer, "_bias"); break;
2576  case WINED3DSPSM_BIASNEG: shader_addline(buffer, "_bias"); break;
2577  case WINED3DSPSM_SIGN: shader_addline(buffer, "_bx2"); break;
2578  case WINED3DSPSM_SIGNNEG: shader_addline(buffer, "_bx2"); break;
2579  case WINED3DSPSM_COMP: break;
2580  case WINED3DSPSM_X2: shader_addline(buffer, "_x2"); break;
2581  case WINED3DSPSM_X2NEG: shader_addline(buffer, "_x2"); break;
2582  case WINED3DSPSM_DZ: shader_addline(buffer, "_dz"); break;
2583  case WINED3DSPSM_DW: shader_addline(buffer, "_dw"); break;
2584  case WINED3DSPSM_ABSNEG: shader_addline(buffer, ")"); break;
2585  case WINED3DSPSM_ABS: shader_addline(buffer, ")"); break;
2586  default: shader_addline(buffer, "_unknown_modifier(%#x)", src_modifier);
2587  }
2588 
2590  {
2591  static const char swizzle_chars[] = "xyzw";
2592  DWORD swizzle_x = swizzle & 0x03;
2593  DWORD swizzle_y = (swizzle >> 2) & 0x03;
2594  DWORD swizzle_z = (swizzle >> 4) & 0x03;
2595  DWORD swizzle_w = (swizzle >> 6) & 0x03;
2596 
2597  if (swizzle_x == swizzle_y
2598  && swizzle_x == swizzle_z
2599  && swizzle_x == swizzle_w)
2600  {
2601  shader_addline(buffer, ".%c", swizzle_chars[swizzle_x]);
2602  }
2603  else
2604  {
2605  shader_addline(buffer, ".%c%c%c%c", swizzle_chars[swizzle_x], swizzle_chars[swizzle_y],
2606  swizzle_chars[swizzle_z], swizzle_chars[swizzle_w]);
2607  }
2608  }
2609 }
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
GLuint buffer
Definition: glext.h:5915
#define WINED3DSP_NOSWIZZLE
GLfloat param
Definition: glext.h:5796
unsigned long DWORD
Definition: ntddk_ex.h:95
wined3d_shader_src_modifier
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:2226
GLuint GLenum swizzle
Definition: glext.h:9511

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 1908 of file shader.c.

1909 {
1910  if (sync_flags & WINED3DSSF_GROUP_SHARED_MEMORY)
1911  {
1912  shader_addline(buffer, "_g");
1913  sync_flags &= ~WINED3DSSF_GROUP_SHARED_MEMORY;
1914  }
1915  if (sync_flags & WINED3DSSF_THREAD_GROUP)
1916  {
1917  shader_addline(buffer, "_t");
1918  sync_flags &= ~WINED3DSSF_THREAD_GROUP;
1919  }
1920 
1921  if (sync_flags)
1922  shader_addline(buffer, "_unknown_flags(%#x)", sync_flags);
1923 }
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
GLuint buffer
Definition: glext.h:5915

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 1959 of file shader.c.

1961 {
1962  switch (domain)
1963  {
1965  shader_addline(buffer, "line");
1966  break;
1968  shader_addline(buffer, "triangle");
1969  break;
1971  shader_addline(buffer, "quad");
1972  break;
1973  default:
1974  shader_addline(buffer, "unknown_tessellator_domain(%#x)", domain);
1975  break;
1976  }
1977 }
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
GLuint buffer
Definition: glext.h:5915

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 1979 of file shader.c.

1981 {
1982  switch (output_primitive)
1983  {
1985  shader_addline(buffer, "point");
1986  break;
1988  shader_addline(buffer, "line");
1989  break;
1991  shader_addline(buffer, "triangle_cw");
1992  break;
1994  shader_addline(buffer, "triangle_ccw");
1995  break;
1996  default:
1997  shader_addline(buffer, "unknown_tessellator_output_primitive(%#x)", output_primitive);
1998  break;
1999  }
2000 }
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
GLuint buffer
Definition: glext.h:5915

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 2002 of file shader.c.

2004 {
2005  switch (partitioning)
2006  {
2008  shader_addline(buffer, "integer");
2009  break;
2011  shader_addline(buffer, "pow2");
2012  break;
2014  shader_addline(buffer, "fractional_odd");
2015  break;
2017  shader_addline(buffer, "fractional_even");
2018  break;
2019  default:
2020  shader_addline(buffer, "unknown_tessellator_partitioning(%#x)", partitioning);
2021  break;
2022  }
2023 }
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
GLuint buffer
Definition: glext.h:5915

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 1942 of file shader.c.

1943 {
1944  if (uav_flags & WINED3DSUF_GLOBALLY_COHERENT)
1945  {
1946  shader_addline(buffer, "_glc");
1947  uav_flags &= ~WINED3DSUF_GLOBALLY_COHERENT;
1948  }
1949  if (uav_flags & WINED3DSUF_ORDER_PRESERVING_COUNTER)
1950  {
1951  shader_addline(buffer, "_opc");
1953  }
1954 
1955  if (uav_flags)
1956  shader_addline(buffer, "_unknown_flags(%#x)", uav_flags);
1957 }
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
GLuint buffer
Definition: glext.h:5915

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 1871 of file shader.c.

1872 {
1873  DWORD map = 1u << max;
1874  map |= map - 1;
1875  map &= reg_maps->shader_version.major < 3 ? ~reg_maps->texcoord : ~reg_maps->input_registers;
1876 
1877  return wined3d_log2i(map);
1878 }
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
#define max(a, b)
Definition: svc.c:63
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: _map.h:44
struct wined3d_shader_version shader_version
static unsigned int wined3d_log2i(unsigned int x)
Definition: wined3d.h:2763

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 2612 of file shader.c.

2615 {
2616  struct wined3d_device *device = shader->device;
2617  const struct wined3d_shader_frontend *fe = shader->frontend;
2618  void *fe_data = shader->frontend_data;
2619  struct wined3d_shader_version shader_version;
2621  struct wined3d_shader_instruction ins;
2622  struct wined3d_shader_tex_mx tex_mx;
2623  struct wined3d_shader_context ctx;
2624  const DWORD *ptr;
2625 
2626  /* Initialize current parsing state. */
2627  tex_mx.current_row = 0;
2628  state.current_loop_depth = 0;
2629  state.current_loop_reg = 0;
2630  state.in_subroutine = FALSE;
2631 
2632  ctx.shader = shader;
2633  ctx.gl_info = &device->adapter->gl_info;
2634  ctx.reg_maps = reg_maps;
2635  ctx.buffer = buffer;
2636  ctx.tex_mx = &tex_mx;
2637  ctx.state = &state;
2638  ctx.backend_data = backend_ctx;
2639  ins.ctx = &ctx;
2640 
2641  fe->shader_read_header(fe_data, &ptr, &shader_version);
2642  if (start)
2643  ptr = start;
2644 
2645  while (!fe->shader_is_end(fe_data, &ptr) && ptr != end)
2646  {
2647  /* Read opcode. */
2648  fe->shader_read_instruction(fe_data, &ptr, &ins);
2649 
2650  /* Unknown opcode and its parameters. */
2651  if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
2652  {
2653  WARN("Encountered unrecognised or invalid instruction.\n");
2654  return WINED3DERR_INVALIDCALL;
2655  }
2656 
2657  if (ins.predicate)
2658  FIXME("Predicates not implemented.\n");
2659 
2660  /* Call appropriate function for output target */
2661  device->shader_backend->shader_handle_instruction(&ins);
2662  }
2663 
2664  return WINED3D_OK;
2665 }
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
#define WARN(fmt,...)
Definition: debug.h:111
struct wined3d_shader_tex_mx * tex_mx
GLuint buffer
Definition: glext.h:5915
GLuint GLuint end
Definition: gl.h:1545
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)
Definition: devices.h:37
#define FIXME(fmt,...)
Definition: debug.h:110
static PVOID ptr
Definition: dispmode.c:27
GLuint shader
Definition: glext.h:6030
#define WINED3D_OK
Definition: wined3d.h:37
unsigned long DWORD
Definition: ntddk_ex.h:95
static int state
Definition: maze.c:121
GLuint start
Definition: gl.h:1545
const struct wined3d_shader_reg_maps * reg_maps

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 578 of file shader.c.

579 {
580  switch (register_type)
581  {
582  case WINED3DSPR_CONST: return register_idx;
583  case WINED3DSPR_CONST2: return 2048 + register_idx;
584  case WINED3DSPR_CONST3: return 4096 + register_idx;
585  case WINED3DSPR_CONST4: return 6144 + register_idx;
586  default:
587  FIXME("Unsupported register type: %u.\n", register_type);
588  return register_idx;
589  }
590 }
#define FIXME(fmt,...)
Definition: debug.h:110

Referenced by shader_dump_register(), and shader_trace_init().

◆ shader_get_registers_used()

static HRESULT shader_get_registers_used ( struct wined3d_shader shader,
DWORD  constf_size 
)
static

Definition at line 1034 of file shader.c.

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