ReactOS  0.4.13-dev-249-gcba1a2f
arb_program_shader.c File Reference
#include "config.h"
#include "wine/port.h"
#include <stdio.h>
#include "wined3d_private.h"
Include dependency graph for arb_program_shader.c:

Go to the source code of this file.

Classes

struct  control_frame
 
struct  arb_ps_np2fixup_info
 
struct  arb_ps_compile_args
 
struct  stb_const_desc
 
struct  arb_ps_compiled_shader
 
struct  arb_vs_compile_args
 
struct  arb_vs_compiled_shader
 
struct  recorded_instruction
 
struct  shader_arb_ctx_priv
 
struct  ps_signature
 
struct  arb_pshader_private
 
struct  arb_vshader_private
 
struct  shader_arb_priv
 
struct  color_fixup_masks
 
struct  arbfp_ffp_desc
 
struct  arbfp_blit_type
 
struct  arbfp_blit_desc
 
struct  wined3d_arbfp_blitter
 

Macros

#define TEX_PROJ   0x1
 
#define TEX_BIAS   0x2
 
#define TEX_LOD   0x4
 
#define TEX_DERIV   0x10
 
#define ARB_FFP_CONST_TFACTOR   0
 
#define ARB_FFP_CONST_COLOR_KEY_LOW   ((ARB_FFP_CONST_TFACTOR) + 1)
 
#define ARB_FFP_CONST_COLOR_KEY_HIGH   ((ARB_FFP_CONST_COLOR_KEY_LOW) + 1)
 
#define ARB_FFP_CONST_SPECULAR_ENABLE   ((ARB_FFP_CONST_COLOR_KEY_HIGH) + 1)
 
#define ARB_FFP_CONST_CONSTANT(i)   ((ARB_FFP_CONST_SPECULAR_ENABLE) + 1 + i)
 
#define ARB_FFP_CONST_BUMPMAT(i)   ((ARB_FFP_CONST_CONSTANT(7)) + 1 + i)
 
#define ARB_FFP_CONST_LUMINANCE(i)   ((ARB_FFP_CONST_BUMPMAT(7)) + 1 + i)
 
#define ARBFP_BLIT_PARAM_SIZE   0
 
#define ARBFP_BLIT_PARAM_COLOR_KEY_LOW   1
 
#define ARBFP_BLIT_PARAM_COLOR_KEY_HIGH   2
 

Enumerations

enum  arb_helper_value {
  ARB_ZERO, ARB_ONE, ARB_TWO, ARB_0001,
  ARB_EPS, ARB_VS_REL_OFFSET
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d_shader)
 
 WINE_DECLARE_DEBUG_CHANNEL (d3d_constants)
 
 WINE_DECLARE_DEBUG_CHANNEL (d3d)
 
 WINE_DECLARE_DEBUG_CHANNEL (d3d_perf)
 
static BOOL shader_is_pshader_version (enum wined3d_shader_type type)
 
static BOOL shader_is_vshader_version (enum wined3d_shader_type type)
 
static const charget_line (const char **ptr)
 
static const chararb_get_helper_value (enum wined3d_shader_type shader, enum arb_helper_value value)
 
static BOOL ffp_clip_emul (const struct wined3d_context *context)
 
static BOOL need_rel_addr_const (const struct arb_vshader_private *shader_data, const struct wined3d_shader_reg_maps *reg_maps, const struct wined3d_gl_info *gl_info)
 
static BOOL use_nv_clip (const struct wined3d_gl_info *gl_info)
 
static BOOL need_helper_const (const struct arb_vshader_private *shader_data, const struct wined3d_shader_reg_maps *reg_maps, const struct wined3d_gl_info *gl_info)
 
static unsigned int reserved_vs_const (const struct arb_vshader_private *shader_data, const struct wined3d_shader_reg_maps *reg_maps, const struct wined3d_gl_info *gl_info)
 
static unsigned int shader_arb_load_constants_f (const struct wined3d_shader *shader, const struct wined3d_gl_info *gl_info, GLuint target_type, unsigned int max_constants, const struct wined3d_vec4 *constants, char *dirty_consts)
 
static void shader_arb_load_np2fixup_constants (const struct arb_ps_np2fixup_info *fixup, const struct wined3d_gl_info *gl_info, const struct wined3d_state *state)
 
static void shader_arb_ps_local_constants (const struct arb_ps_compiled_shader *gl_shader, const struct wined3d_context *context, const struct wined3d_state *state, UINT rt_height)
 
static void shader_arb_vs_local_constants (const struct arb_vs_compiled_shader *gl_shader, const struct wined3d_context *context, const struct wined3d_state *state)
 
static void shader_arb_select (void *shader_priv, struct wined3d_context *context, const struct wined3d_state *state)
 
static void shader_arb_load_constants_internal (struct shader_arb_priv *priv, struct wined3d_context *context, const struct wined3d_state *state, BOOL usePixelShader, BOOL useVertexShader, BOOL from_shader_select)
 
static void shader_arb_load_constants (void *shader_priv, struct wined3d_context *context, const struct wined3d_state *state)
 
static void shader_arb_update_float_vertex_constants (struct wined3d_device *device, UINT start, UINT count)
 
static void shader_arb_update_float_pixel_constants (struct wined3d_device *device, UINT start, UINT count)
 
static void shader_arb_append_imm_vec4 (struct wined3d_string_buffer *buffer, const float *values)
 
static void shader_generate_arb_declarations (const struct wined3d_shader *shader, const struct wined3d_shader_reg_maps *reg_maps, struct wined3d_string_buffer *buffer, const struct wined3d_gl_info *gl_info, DWORD *num_clipplanes, const struct shader_arb_ctx_priv *ctx)
 
static void shader_arb_get_write_mask (const struct wined3d_shader_instruction *ins, const struct wined3d_shader_dst_param *dst, char *write_mask)
 
static void shader_arb_get_swizzle (const struct wined3d_shader_src_param *param, BOOL fixup, char *swizzle_str)
 
static void shader_arb_request_a0 (const struct wined3d_shader_instruction *ins, const char *src)
 
static void shader_arb_get_src_param (const struct wined3d_shader_instruction *ins, const struct wined3d_shader_src_param *src, unsigned int tmpreg, char *outregstr)
 
static void shader_arb_get_register_name (const struct wined3d_shader_instruction *ins, const struct wined3d_shader_register *reg, char *register_name, BOOL *is_color)
 
static void shader_arb_get_dst_param (const struct wined3d_shader_instruction *ins, const struct wined3d_shader_dst_param *wined3d_dst, char *str)
 
static const charshader_arb_get_fixup_swizzle (enum fixup_channel_source channel_source)
 
static struct color_fixup_masks calc_color_correction (struct color_fixup_desc fixup, DWORD dst_mask)
 
static void gen_color_correction (struct wined3d_string_buffer *buffer, const char *dst, const char *src, const char *one, const char *two, struct color_fixup_desc fixup, struct color_fixup_masks masks)
 
static const charshader_arb_get_modifier (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_sample (const struct wined3d_shader_instruction *ins, DWORD sampler_idx, const char *dst_str, const char *coord_reg, WORD flags, const char *dsx, const char *dsy)
 
static void pshader_hw_bem (const struct wined3d_shader_instruction *ins)
 
static DWORD negate_modifiers (DWORD mod, char *extra_char)
 
static void pshader_hw_cnd (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_cmp (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_dp2add (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_map2gl (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_nop (const struct wined3d_shader_instruction *ins)
 
static DWORD shader_arb_select_component (DWORD swizzle, DWORD component)
 
static void shader_hw_mov (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_texkill (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_tex (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_texcoord (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_texreg2ar (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_texreg2gb (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_texreg2rgb (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_texbem (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_texm3x2pad (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_texm3x2tex (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_texm3x3pad (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_texm3x3tex (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_texm3x3vspec (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_texm3x3spec (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_texdepth (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_texdp3tex (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_texdp3 (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_texm3x3 (const struct wined3d_shader_instruction *ins)
 
static void pshader_hw_texm3x2depth (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_mnxn (const struct wined3d_shader_instruction *ins)
 
static DWORD abs_modifier (DWORD mod, BOOL *need_abs)
 
static void shader_hw_scalar_op (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_nrm (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_lrp (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_sincos (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_sgn (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_dsy (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_pow (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_loop (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_rep (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_endloop (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_endrep (const struct wined3d_shader_instruction *ins)
 
static const struct control_framefind_last_loop (const struct shader_arb_ctx_priv *priv)
 
static void shader_hw_break (const struct wined3d_shader_instruction *ins)
 
static const charget_compare (enum wined3d_shader_rel_op op)
 
static enum wined3d_shader_rel_op invert_compare (enum wined3d_shader_rel_op op)
 
static void shader_hw_breakc (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_ifc (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_else (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_endif (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_texldd (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_texldl (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_label (const struct wined3d_shader_instruction *ins)
 
static void vshader_add_footer (struct shader_arb_ctx_priv *priv_ctx, const struct arb_vshader_private *shader_data, const struct arb_vs_compile_args *args, const struct wined3d_shader_reg_maps *reg_maps, const struct wined3d_gl_info *gl_info, struct wined3d_string_buffer *buffer)
 
static void shader_hw_ret (const struct wined3d_shader_instruction *ins)
 
static void shader_hw_call (const struct wined3d_shader_instruction *ins)
 
static BOOL shader_arb_compile (const struct wined3d_gl_info *gl_info, GLenum target, const char *src)
 
static void arbfp_add_sRGB_correction (struct wined3d_string_buffer *buffer, const char *fragcolor, const char *tmp1, const char *tmp2, const char *tmp3, const char *tmp4, BOOL condcode)
 
static const DWORDfind_loop_control_values (const struct wined3d_shader *shader, DWORD idx)
 
static void init_ps_input (const struct wined3d_shader *shader, const struct arb_ps_compile_args *args, struct shader_arb_ctx_priv *priv)
 
static void arbfp_add_linear_fog (struct wined3d_string_buffer *buffer, const char *fragcolor, const char *tmp)
 
static GLuint shader_arb_generate_pshader (const struct wined3d_shader *shader, const struct wined3d_gl_info *gl_info, struct wined3d_string_buffer *buffer, const struct arb_ps_compile_args *args, struct arb_ps_compiled_shader *compiled)
 
static int compare_sig (const struct wined3d_shader_signature *sig1, const struct wined3d_shader_signature *sig2)
 
static void clone_sig (struct wined3d_shader_signature *new, const struct wined3d_shader_signature *sig)
 
static DWORD find_input_signature (struct shader_arb_priv *priv, const struct wined3d_shader_signature *sig)
 
static void init_output_registers (const struct wined3d_shader *shader, const struct wined3d_shader_signature *ps_input_sig, struct shader_arb_ctx_priv *priv_ctx, struct arb_vs_compiled_shader *compiled)
 
static GLuint shader_arb_generate_vshader (const struct wined3d_shader *shader, const struct wined3d_gl_info *gl_info, struct wined3d_string_buffer *buffer, const struct arb_vs_compile_args *args, struct arb_vs_compiled_shader *compiled, const struct wined3d_shader_signature *ps_input_sig)
 
static struct arb_ps_compiled_shaderfind_arb_pshader (struct wined3d_shader *shader, const struct arb_ps_compile_args *args)
 
static BOOL vs_args_equal (const struct arb_vs_compile_args *stored, const struct arb_vs_compile_args *new, const DWORD use_map, BOOL skip_int)
 
static struct arb_vs_compiled_shaderfind_arb_vshader (struct wined3d_shader *shader, const struct wined3d_gl_info *gl_info, DWORD use_map, const struct arb_vs_compile_args *args, const struct wined3d_shader_signature *ps_input_sig)
 
static void find_arb_ps_compile_args (const struct wined3d_state *state, const struct wined3d_context *context, const struct wined3d_shader *shader, struct arb_ps_compile_args *args)
 
static void find_arb_vs_compile_args (const struct wined3d_state *state, const struct wined3d_context *context, const struct wined3d_shader *shader, struct arb_vs_compile_args *args)
 
static void shader_arb_select_compute (void *shader_priv, struct wined3d_context *context, const struct wined3d_state *state)
 
static void shader_arb_disable (void *shader_priv, struct wined3d_context *context)
 
static void shader_arb_destroy (struct wined3d_shader *shader)
 
static int sig_tree_compare (const void *key, const struct wine_rb_entry *entry)
 
static HRESULT shader_arb_alloc (struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe, const struct fragment_pipeline *fragment_pipe)
 
static void release_signature (struct wine_rb_entry *entry, void *context)
 
static void shader_arb_free (struct wined3d_device *device)
 
static BOOL shader_arb_allocate_context_data (struct wined3d_context *context)
 
static void shader_arb_free_context_data (struct wined3d_context *context)
 
static void shader_arb_init_context_state (struct wined3d_context *context)
 
static void shader_arb_get_caps (const struct wined3d_gl_info *gl_info, struct shader_caps *caps)
 
static BOOL shader_arb_color_fixup_supported (struct color_fixup_desc fixup)
 
static void shader_arb_add_instruction_modifiers (const struct wined3d_shader_instruction *ins)
 
static BOOL get_bool_const (const struct wined3d_shader_instruction *ins, const struct wined3d_shader *shader, DWORD idx)
 
static void get_loop_control_const (const struct wined3d_shader_instruction *ins, const struct wined3d_shader *shader, UINT idx, struct wined3d_shader_loop_control *loop_control)
 
static void record_instruction (struct list *list, const struct wined3d_shader_instruction *ins)
 
static void free_recorded_instruction (struct list *list)
 
static void pop_control_frame (const struct wined3d_shader_instruction *ins)
 
static void shader_arb_handle_instruction (const struct wined3d_shader_instruction *ins)
 
static BOOL shader_arb_has_ffp_proj_control (void *shader_priv)
 
static void shader_arb_precompile (void *shader_priv, struct wined3d_shader *shader)
 
static void arbfp_enable (const struct wined3d_gl_info *gl_info, BOOL enable)
 
static voidarbfp_alloc (const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv)
 
static void arbfp_free_ffpshader (struct wine_rb_entry *entry, void *context)
 
static void arbfp_free (struct wined3d_device *device)
 
static void arbfp_get_caps (const struct wined3d_gl_info *gl_info, struct fragment_caps *caps)
 
static DWORD arbfp_get_emul_mask (const struct wined3d_gl_info *gl_info)
 
static void state_texfactor_arbfp (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_tss_constant_arbfp (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_arb_specularenable (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void set_bumpmat_arbfp (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void tex_bumpenvlum_arbfp (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void alpha_test_arbfp (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void color_key_arbfp (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static const charget_argreg (struct wined3d_string_buffer *buffer, DWORD argnum, unsigned int stage, DWORD arg)
 
static void gen_ffp_instr (struct wined3d_string_buffer *buffer, unsigned int stage, BOOL color, BOOL alpha, BOOL tmp_dst, DWORD op, DWORD dw_arg0, DWORD dw_arg1, DWORD dw_arg2)
 
static const chararbfp_texture_target (enum wined3d_gl_resource_type type)
 
static GLuint gen_arbfp_ffp_shader (const struct ffp_frag_settings *settings, const struct wined3d_gl_info *gl_info)
 
static void fragment_prog_arbfp (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_arbfp_fog (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void textransform (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static BOOL arbfp_alloc_context_data (struct wined3d_context *context)
 
static void arbfp_free_context_data (struct wined3d_context *context)
 
static int arbfp_blit_type_compare (const void *key, const struct wine_rb_entry *entry)
 
static void arbfp_free_blit_shader (struct wine_rb_entry *entry, void *ctx)
 
static void arbfp_blitter_destroy (struct wined3d_blitter *blitter, struct wined3d_context *context)
 
static void gen_packed_yuv_read (struct wined3d_string_buffer *buffer, const struct arbfp_blit_type *type, char *luminance)
 
static void gen_yv12_read (struct wined3d_string_buffer *buffer, const struct arbfp_blit_type *type, char *luminance)
 
static void gen_nv12_read (struct wined3d_string_buffer *buffer, const struct arbfp_blit_type *type, char *luminance)
 
static GLuint gen_p8_shader (const struct wined3d_gl_info *gl_info, const struct arbfp_blit_type *type)
 
static void upload_palette (struct wined3d_arbfp_blitter *blitter, const struct wined3d_texture *texture, struct wined3d_context *context)
 
static GLuint gen_yuv_shader (const struct wined3d_gl_info *gl_info, const struct arbfp_blit_type *type)
 
static GLuint arbfp_gen_plain_shader (const struct wined3d_gl_info *gl_info, const struct arbfp_blit_type *type)
 
static HRESULT arbfp_blit_set (struct wined3d_arbfp_blitter *blitter, struct wined3d_context *context, const struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_color_key *color_key)
 
static void arbfp_blit_unset (const struct wined3d_gl_info *gl_info)
 
static BOOL arbfp_blit_supported (enum wined3d_blit_op blit_op, const struct wined3d_context *context, const struct wined3d_resource *src_resource, DWORD src_location, const struct wined3d_resource *dst_resource, DWORD dst_location)
 
static DWORD arbfp_blitter_blit (struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, DWORD src_location, const RECT *src_rect, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, DWORD dst_location, const RECT *dst_rect, const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter)
 
static void arbfp_blitter_clear (struct wined3d_blitter *blitter, struct wined3d_device *device, unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects, const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil)
 
void wined3d_arbfp_blitter_create (struct wined3d_blitter **next, const struct wined3d_device *device)
 

Variables

static const char *const shift_tab []
 
static const SHADER_HANDLER shader_arb_instruction_handler_table [WINED3DSIH_TABLE_SIZE]
 
const struct wined3d_shader_backend_ops arb_program_shader_backend
 
static const struct StateEntryTemplate arbfp_fragmentstate_template []
 
const struct fragment_pipeline arbfp_fragment_pipeline
 
static const struct wined3d_blitter_ops arbfp_blitter_ops
 

Macro Definition Documentation

◆ ARB_FFP_CONST_BUMPMAT

#define ARB_FFP_CONST_BUMPMAT (   i)    ((ARB_FFP_CONST_CONSTANT(7)) + 1 + i)

Definition at line 5682 of file arb_program_shader.c.

◆ ARB_FFP_CONST_COLOR_KEY_HIGH

#define ARB_FFP_CONST_COLOR_KEY_HIGH   ((ARB_FFP_CONST_COLOR_KEY_LOW) + 1)

Definition at line 5679 of file arb_program_shader.c.

◆ ARB_FFP_CONST_COLOR_KEY_LOW

#define ARB_FFP_CONST_COLOR_KEY_LOW   ((ARB_FFP_CONST_TFACTOR) + 1)

Definition at line 5678 of file arb_program_shader.c.

◆ ARB_FFP_CONST_CONSTANT

#define ARB_FFP_CONST_CONSTANT (   i)    ((ARB_FFP_CONST_SPECULAR_ENABLE) + 1 + i)

Definition at line 5681 of file arb_program_shader.c.

◆ ARB_FFP_CONST_LUMINANCE

#define ARB_FFP_CONST_LUMINANCE (   i)    ((ARB_FFP_CONST_BUMPMAT(7)) + 1 + i)

Definition at line 5683 of file arb_program_shader.c.

◆ ARB_FFP_CONST_SPECULAR_ENABLE

#define ARB_FFP_CONST_SPECULAR_ENABLE   ((ARB_FFP_CONST_COLOR_KEY_HIGH) + 1)

Definition at line 5680 of file arb_program_shader.c.

◆ ARB_FFP_CONST_TFACTOR

#define ARB_FFP_CONST_TFACTOR   0

Definition at line 5677 of file arb_program_shader.c.

◆ ARBFP_BLIT_PARAM_COLOR_KEY_HIGH

#define ARBFP_BLIT_PARAM_COLOR_KEY_HIGH   2

Definition at line 6886 of file arb_program_shader.c.

◆ ARBFP_BLIT_PARAM_COLOR_KEY_LOW

#define ARBFP_BLIT_PARAM_COLOR_KEY_LOW   1

Definition at line 6885 of file arb_program_shader.c.

◆ ARBFP_BLIT_PARAM_SIZE

#define ARBFP_BLIT_PARAM_SIZE   0

Definition at line 6884 of file arb_program_shader.c.

◆ TEX_BIAS

#define TEX_BIAS   0x2

Definition at line 1405 of file arb_program_shader.c.

◆ TEX_DERIV

#define TEX_DERIV   0x10

Definition at line 1407 of file arb_program_shader.c.

◆ TEX_LOD

#define TEX_LOD   0x4

Definition at line 1406 of file arb_program_shader.c.

◆ TEX_PROJ

#define TEX_PROJ   0x1

Definition at line 1404 of file arb_program_shader.c.

Enumeration Type Documentation

◆ arb_helper_value

Enumerator
ARB_ZERO 
ARB_ONE 
ARB_TWO 
ARB_0001 
ARB_EPS 
ARB_VS_REL_OFFSET 

Definition at line 68 of file arb_program_shader.c.

Function Documentation

◆ abs_modifier()

static DWORD abs_modifier ( DWORD  mod,
BOOL need_abs 
)
static

Definition at line 2504 of file arb_program_shader.c.

2505 {
2506  *need_abs = FALSE;
2507 
2508  switch(mod)
2509  {
2510  case WINED3DSPSM_NONE: return WINED3DSPSM_ABS;
2511  case WINED3DSPSM_NEG: return WINED3DSPSM_ABS;
2512  case WINED3DSPSM_BIAS: *need_abs = TRUE; return WINED3DSPSM_BIAS;
2513  case WINED3DSPSM_BIASNEG: *need_abs = TRUE; return WINED3DSPSM_BIASNEG;
2514  case WINED3DSPSM_SIGN: *need_abs = TRUE; return WINED3DSPSM_SIGN;
2515  case WINED3DSPSM_SIGNNEG: *need_abs = TRUE; return WINED3DSPSM_SIGNNEG;
2516  case WINED3DSPSM_COMP: *need_abs = TRUE; return WINED3DSPSM_COMP;
2517  case WINED3DSPSM_X2: *need_abs = TRUE; return WINED3DSPSM_X2;
2518  case WINED3DSPSM_X2NEG: *need_abs = TRUE; return WINED3DSPSM_X2NEG;
2519  case WINED3DSPSM_DZ: *need_abs = TRUE; return WINED3DSPSM_DZ;
2520  case WINED3DSPSM_DW: *need_abs = TRUE; return WINED3DSPSM_DW;
2521  case WINED3DSPSM_ABS: return WINED3DSPSM_ABS;
2522  case WINED3DSPSM_ABSNEG: return WINED3DSPSM_ABS;
2523  }
2524  FIXME("Unknown modifier %u\n", mod);
2525  return mod;
2526 }
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:110
static int mod
Definition: i386-dis.c:1273

Referenced by shader_hw_pow(), and shader_hw_scalar_op().

◆ alpha_test_arbfp()

static void alpha_test_arbfp ( struct wined3d_context context,
const struct wined3d_state state,
DWORD  state_id 
)
static

Definition at line 5941 of file arb_program_shader.c.

5942 {
5943  const struct wined3d_gl_info *gl_info = context->gl_info;
5944  int glParm;
5945  float ref;
5946 
5947  TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id);
5948 
5949  if (state->render_states[WINED3D_RS_ALPHATESTENABLE])
5950  {
5951  gl_info->gl_ops.gl.p_glEnable(GL_ALPHA_TEST);
5952  checkGLcall("glEnable GL_ALPHA_TEST");
5953  }
5954  else
5955  {
5956  gl_info->gl_ops.gl.p_glDisable(GL_ALPHA_TEST);
5957  checkGLcall("glDisable GL_ALPHA_TEST");
5958  return;
5959  }
5960 
5961  ref = ((float)state->render_states[WINED3D_RS_ALPHAREF]) / 255.0f;
5962  glParm = wined3d_gl_compare_func(state->render_states[WINED3D_RS_ALPHAFUNC]);
5963 
5964  if (glParm)
5965  {
5966  gl_info->gl_ops.gl.p_glAlphaFunc(glParm, ref);
5967  checkGLcall("glAlphaFunc");
5968  }
5969 }
struct opengl_funcs gl_ops
Definition: http.c:6587
Definition: send.c:47
GLenum wined3d_gl_compare_func(enum wined3d_cmp_func f)
Definition: state.c:344
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
static int state
Definition: maze.c:121
#define checkGLcall(A)
#define GL_ALPHA_TEST
Definition: gl.h:366

◆ arb_get_helper_value()

static const char* arb_get_helper_value ( enum wined3d_shader_type  shader,
enum arb_helper_value  value 
)
static

Definition at line 79 of file arb_program_shader.c.

80 {
82  {
83  ERR("Unsupported shader type '%s'.\n", debug_shader_type(shader));
84  return "bad";
85  }
86 
88  {
89  switch (value)
90  {
91  case ARB_ZERO: return "ps_helper_const.x";
92  case ARB_ONE: return "ps_helper_const.y";
93  case ARB_TWO: return "coefmul.x";
94  case ARB_0001: return "ps_helper_const.xxxy";
95  case ARB_EPS: return "ps_helper_const.z";
96  default: break;
97  }
98  }
99  else
100  {
101  switch (value)
102  {
103  case ARB_ZERO: return "helper_const.x";
104  case ARB_ONE: return "helper_const.y";
105  case ARB_TWO: return "helper_const.z";
106  case ARB_EPS: return "helper_const.w";
107  case ARB_0001: return "helper_const.xxxy";
108  case ARB_VS_REL_OFFSET: return "rel_addr_const.y";
109  }
110  }
111  FIXME("Unmanaged %s shader helper constant requested: %u.\n",
112  shader == WINED3D_SHADER_TYPE_PIXEL ? "pixel" : "vertex", value);
113  switch (value)
114  {
115  case ARB_ZERO: return "0.0";
116  case ARB_ONE: return "1.0";
117  case ARB_TWO: return "2.0";
118  case ARB_0001: return "{0.0, 0.0, 0.0, 1.0}";
119  case ARB_EPS: return "1e-8";
120  default: return "bad";
121  }
122 }
#define FIXME(fmt,...)
Definition: debug.h:110
GLuint shader
Definition: glext.h:6030
#define ERR(fmt,...)
Definition: debug.h:109
const char * debug_shader_type(enum wined3d_shader_type type)
Definition: utils.c:4599

Referenced by pshader_hw_texdepth(), pshader_hw_texm3x2depth(), shader_arb_generate_vshader(), shader_arb_get_src_param(), shader_hw_mov(), shader_hw_nrm(), shader_hw_pow(), shader_hw_sample(), and vshader_add_footer().

◆ arbfp_add_linear_fog()

static void arbfp_add_linear_fog ( struct wined3d_string_buffer buffer,
const char fragcolor,
const char tmp 
)
static

Definition at line 3483 of file arb_program_shader.c.

3485 {
3486  shader_addline(buffer, "SUB %s.x, state.fog.params.z, fragment.fogcoord.x;\n", tmp);
3487  shader_addline(buffer, "MUL_SAT %s.x, %s.x, state.fog.params.w;\n", tmp, tmp);
3488  shader_addline(buffer, "LRP %s.rgb, %s.x, %s, state.fog.color;\n", fragcolor, tmp, fragcolor);
3489 }
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
GLuint buffer
Definition: glext.h:5915

Referenced by gen_arbfp_ffp_shader(), and shader_arb_generate_pshader().

◆ arbfp_add_sRGB_correction()

static void arbfp_add_sRGB_correction ( struct wined3d_string_buffer buffer,
const char fragcolor,
const char tmp1,
const char tmp2,
const char tmp3,
const char tmp4,
BOOL  condcode 
)
static

Definition at line 3347 of file arb_program_shader.c.

3349 {
3350  /* Perform sRGB write correction. See GLX_EXT_framebuffer_sRGB */
3351 
3352  if(condcode)
3353  {
3354  /* Sigh. MOVC CC doesn't work, so use one of the temps as dummy dest */
3355  shader_addline(buffer, "SUBC %s, %s.x, srgb_consts1.x;\n", tmp1, fragcolor);
3356  /* Calculate the > 0.0031308 case */
3357  shader_addline(buffer, "POW %s.x (GE), %s.x, srgb_consts0.x;\n", fragcolor, fragcolor);
3358  shader_addline(buffer, "POW %s.y (GE), %s.y, srgb_consts0.x;\n", fragcolor, fragcolor);
3359  shader_addline(buffer, "POW %s.z (GE), %s.z, srgb_consts0.x;\n", fragcolor, fragcolor);
3360  shader_addline(buffer, "MUL %s.xyz (GE), %s, srgb_consts0.y;\n", fragcolor, fragcolor);
3361  shader_addline(buffer, "SUB %s.xyz (GE), %s, srgb_consts0.z;\n", fragcolor, fragcolor);
3362  /* Calculate the < case */
3363  shader_addline(buffer, "MUL %s.xyz (LT), srgb_consts0.w, %s;\n", fragcolor, fragcolor);
3364  }
3365  else
3366  {
3367  /* Calculate the > 0.0031308 case */
3368  shader_addline(buffer, "POW %s.x, %s.x, srgb_consts0.x;\n", tmp1, fragcolor);
3369  shader_addline(buffer, "POW %s.y, %s.y, srgb_consts0.x;\n", tmp1, fragcolor);
3370  shader_addline(buffer, "POW %s.z, %s.z, srgb_consts0.x;\n", tmp1, fragcolor);
3371  shader_addline(buffer, "MUL %s, %s, srgb_consts0.y;\n", tmp1, tmp1);
3372  shader_addline(buffer, "SUB %s, %s, srgb_consts0.z;\n", tmp1, tmp1);
3373  /* Calculate the < case */
3374  shader_addline(buffer, "MUL %s, srgb_consts0.w, %s;\n", tmp2, fragcolor);
3375  /* Get 1.0 / 0.0 masks for > 0.0031308 and < 0.0031308 */
3376  shader_addline(buffer, "SLT %s, srgb_consts1.x, %s;\n", tmp3, fragcolor);
3377  shader_addline(buffer, "SGE %s, srgb_consts1.x, %s;\n", tmp4, fragcolor);
3378  /* Store the components > 0.0031308 in the destination */
3379  shader_addline(buffer, "MUL %s.xyz, %s, %s;\n", fragcolor, tmp1, tmp3);
3380  /* Add the components that are < 0.0031308 */
3381  shader_addline(buffer, "MAD %s.xyz, %s, %s, %s;\n", fragcolor, tmp2, tmp4, fragcolor);
3382  /* Move everything into result.color at once. Nvidia hardware cannot handle partial
3383  * result.color writes(.rgb first, then .a), or handle overwriting already written
3384  * components. The assembler uses a temporary register in this case, which is usually
3385  * not allocated from one of our registers that were used earlier.
3386  */
3387  }
3388  /* [0.0;1.0] clamping. Not needed, this is done implicitly */
3389 }
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
GLuint buffer
Definition: glext.h:5915

Referenced by gen_arbfp_ffp_shader(), and shader_arb_generate_pshader().

◆ arbfp_alloc()

static void* arbfp_alloc ( const struct wined3d_shader_backend_ops shader_backend,
void shader_priv 
)
static

Definition at line 5706 of file arb_program_shader.c.

5707 {
5708  struct shader_arb_priv *priv;
5709 
5710  /* Share private data between the shader backend and the pipeline
5711  * replacement, if both are the arb implementation. This is needed to
5712  * figure out whether ARBfp should be disabled if no pixel shader is bound
5713  * or not. */
5714  if (shader_backend == &arb_program_shader_backend)
5715  priv = shader_priv;
5716  else if (!(priv = heap_alloc_zero(sizeof(*priv))))
5717  return NULL;
5718 
5720  priv->use_arbfp_fixed_func = TRUE;
5721 
5722  return priv;
5723 }
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416
struct wine_rb_tree fragment_shaders
static void wine_rb_init(struct wine_rb_tree *tree, wine_rb_compare_func_t compare)
Definition: rbtree.h:179
int wined3d_ffp_frag_program_key_compare(const void *key, const struct wine_rb_entry *entry)
Definition: utils.c:6140
const struct wined3d_shader_backend_ops arb_program_shader_backend

◆ arbfp_alloc_context_data()

static BOOL arbfp_alloc_context_data ( struct wined3d_context context)
static

Definition at line 6848 of file arb_program_shader.c.

6849 {
6850  return TRUE;
6851 }
#define TRUE
Definition: types.h:120

◆ arbfp_blit_set()

static HRESULT arbfp_blit_set ( struct wined3d_arbfp_blitter blitter,
struct wined3d_context context,
const struct wined3d_texture texture,
unsigned int  sub_resource_idx,
const struct wined3d_color_key color_key 
)
static

Definition at line 7557 of file arb_program_shader.c.

7560 {
7561  enum complex_fixup fixup;
7562  const struct wined3d_gl_info *gl_info = context->gl_info;
7563  struct wine_rb_entry *entry;
7564  struct arbfp_blit_type type;
7565  struct arbfp_blit_desc *desc;
7566  struct wined3d_color float_color_key[2];
7567  struct wined3d_vec4 size;
7568  unsigned int level;
7569  GLuint shader;
7570 
7571  level = sub_resource_idx % texture->level_count;
7574  size.z = 1.0f;
7575  size.w = 1.0f;
7576 
7577  if (is_complex_fixup(texture->resource.format->color_fixup))
7578  fixup = get_complex_fixup(texture->resource.format->color_fixup);
7579  else
7580  fixup = COMPLEX_FIXUP_NONE;
7581 
7582  switch (texture->target)
7583  {
7584  case GL_TEXTURE_1D:
7585  type.res_type = WINED3D_GL_RES_TYPE_TEX_1D;
7586  break;
7587 
7588  case GL_TEXTURE_2D:
7589  type.res_type = WINED3D_GL_RES_TYPE_TEX_2D;
7590  break;
7591 
7592  case GL_TEXTURE_3D:
7593  type.res_type = WINED3D_GL_RES_TYPE_TEX_3D;
7594  break;
7595 
7598  break;
7599 
7602  break;
7603 
7604  default:
7605  ERR("Unexpected GL texture type %#x.\n", texture->target);
7606  type.res_type = WINED3D_GL_RES_TYPE_TEX_2D;
7607  }
7608  type.fixup = fixup;
7609  type.use_color_key = !!color_key;
7610  type.padding = 0;
7611 
7612  if ((entry = wine_rb_get(&blitter->shaders, &type)))
7613  {
7615  shader = desc->shader;
7616  }
7617  else
7618  {
7619  switch (fixup)
7620  {
7621  case COMPLEX_FIXUP_NONE:
7622  if (!is_identity_fixup(texture->resource.format->color_fixup))
7623  FIXME("Implement support for sign or swizzle fixups.\n");
7624  shader = arbfp_gen_plain_shader(gl_info, &type);
7625  break;
7626 
7627  case COMPLEX_FIXUP_P8:
7628  shader = gen_p8_shader(gl_info, &type);
7629  break;
7630 
7631  case COMPLEX_FIXUP_YUY2:
7632  case COMPLEX_FIXUP_UYVY:
7633  case COMPLEX_FIXUP_YV12:
7634  case COMPLEX_FIXUP_NV12:
7635  shader = gen_yuv_shader(gl_info, &type);
7636  break;
7637  }
7638 
7639  if (!shader)
7640  {
7641  FIXME("Unsupported complex fixup %#x, not setting a shader\n", fixup);
7642  return E_NOTIMPL;
7643  }
7644 
7645  if (!(desc = heap_alloc(sizeof(*desc))))
7646  goto err_out;
7647 
7648  desc->type = type;
7649  desc->shader = shader;
7650  if (wine_rb_put(&blitter->shaders, &desc->type, &desc->entry) == -1)
7651  {
7652 err_out:
7653  ERR("Out of memory\n");
7654  GL_EXTCALL(glDeleteProgramsARB(1, &shader));
7655  checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &shader))");
7656  GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0));
7657  checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0)");
7658  heap_free(desc);
7659  return E_OUTOFMEMORY;
7660  }
7661  }
7662 
7663  if (fixup == COMPLEX_FIXUP_P8)
7664  upload_palette(blitter, texture, context);
7665 
7666  gl_info->gl_ops.gl.p_glEnable(GL_FRAGMENT_PROGRAM_ARB);
7667  checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB)");
7668  GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader));
7669  checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader)");
7670  GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARBFP_BLIT_PARAM_SIZE, &size.x));
7671  checkGLcall("glProgramLocalParameter4fvARB");
7672  if (type.use_color_key)
7673  {
7674  wined3d_format_get_float_color_key(texture->resource.format, color_key, float_color_key);
7675  GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB,
7676  ARBFP_BLIT_PARAM_COLOR_KEY_LOW, &float_color_key[0].r));
7677  GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB,
7678  ARBFP_BLIT_PARAM_COLOR_KEY_HIGH, &float_color_key[1].r));
7679  checkGLcall("glProgramLocalParameter4fvARB");
7680  }
7681 
7682  return WINED3D_OK;
7683 }
#define ARBFP_BLIT_PARAM_SIZE
GLint level
Definition: gl.h:1546
#define ARBFP_BLIT_PARAM_COLOR_KEY_LOW
struct opengl_funcs gl_ops
Definition: http.c:6587
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
complex_fixup
void wined3d_format_get_float_color_key(const struct wined3d_format *format, const struct wined3d_color_key *key, struct wined3d_color *float_colors)
Definition: utils.c:5263
static BOOL is_complex_fixup(struct color_fixup_desc fixup)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define GL_TEXTURE_CUBE_MAP_ARB
Definition: glext.h:1230
#define GL_TEXTURE_RECTANGLE_ARB
Definition: glext.h:1614
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define GL_TEXTURE_1D
Definition: gl.h:644
static GLuint gen_p8_shader(const struct wined3d_gl_info *gl_info, const struct arbfp_blit_type *type)
#define FIXME(fmt,...)
Definition: debug.h:110
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
#define GL_TEXTURE_3D
Definition: gl.h:1515
struct wine_rb_tree shaders
#define GL_EXTCALL(f)
GLuint shader
Definition: glext.h:6030
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint texture
Definition: glext.h:6295
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
#define WINED3D_OK
Definition: wined3d.h:37
static BOOL is_identity_fixup(struct color_fixup_desc fixup)
uint32_t entry
Definition: isohybrid.c:63
static unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture *texture, unsigned int level)
#define ERR(fmt,...)
Definition: debug.h:109
unsigned int GLuint
Definition: gl.h:159
static void upload_palette(struct wined3d_arbfp_blitter *blitter, const struct wined3d_texture *texture, struct wined3d_context *context)
Definition: rbtree.h:35
#define E_NOTIMPL
Definition: ddrawi.h:99
static int wine_rb_put(struct wine_rb_tree *tree, const void *key, struct wine_rb_entry *entry)
Definition: rbtree.h:215
static GLuint arbfp_gen_plain_shader(const struct wined3d_gl_info *gl_info, const struct arbfp_blit_type *type)
#define checkGLcall(A)
#define GL_TEXTURE_2D
Definition: gl.h:645
static struct wine_rb_entry * wine_rb_get(const struct wine_rb_tree *tree, const void *key)
Definition: rbtree.h:203
#define ARBFP_BLIT_PARAM_COLOR_KEY_HIGH
static enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup)
static GLuint gen_yuv_shader(const struct wined3d_gl_info *gl_info, const struct arbfp_blit_type *type)
static unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture *texture, unsigned int level)
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define GL_FRAGMENT_PROGRAM_ARB
Definition: glext.h:1466

Referenced by arbfp_blitter_blit().

◆ arbfp_blit_supported()

static BOOL arbfp_blit_supported ( enum wined3d_blit_op  blit_op,
const struct wined3d_context context,
const struct wined3d_resource src_resource,
DWORD  src_location,
const struct wined3d_resource dst_resource,
DWORD  dst_location 
)
static

Definition at line 7692 of file arb_program_shader.c.

7695 {
7696  const struct wined3d_format *src_format = src_resource->format;
7697  const struct wined3d_format *dst_format = dst_resource->format;
7698  enum complex_fixup src_fixup;
7699  BOOL decompress;
7700 
7701  if (src_resource->type != WINED3D_RTYPE_TEXTURE_2D)
7702  return FALSE;
7703 
7704  if (blit_op == WINED3D_BLIT_OP_RAW_BLIT && dst_format->id == src_format->id)
7705  {
7707  blit_op = WINED3D_BLIT_OP_DEPTH_BLIT;
7708  else
7709  blit_op = WINED3D_BLIT_OP_COLOR_BLIT;
7710  }
7711 
7712  switch (blit_op)
7713  {
7715  if (!context->d3d_info->shader_color_key)
7716  {
7717  /* The conversion modifies the alpha channel so the color key might no longer match. */
7718  TRACE("Color keying not supported with converted textures.\n");
7719  return FALSE;
7720  }
7723  break;
7724 
7725  default:
7726  TRACE("Unsupported blit_op=%d\n", blit_op);
7727  return FALSE;
7728  }
7729 
7730  decompress = src_format && (src_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED)
7732  if (!decompress && !(src_resource->access & dst_resource->access & WINED3D_RESOURCE_ACCESS_GPU))
7733  return FALSE;
7734 
7735  src_fixup = get_complex_fixup(src_format->color_fixup);
7736  if (TRACE_ON(d3d_shader) && TRACE_ON(d3d))
7737  {
7738  TRACE("Checking support for fixup:\n");
7739  dump_color_fixup_desc(src_format->color_fixup);
7740  }
7741 
7742  if (!is_identity_fixup(dst_format->color_fixup)
7743  && (dst_format->id != src_format->id || dst_location != WINED3D_LOCATION_DRAWABLE))
7744  {
7745  TRACE("Destination fixups are not supported\n");
7746  return FALSE;
7747  }
7748 
7749  if (is_identity_fixup(src_format->color_fixup))
7750  {
7751  TRACE("[OK]\n");
7752  return TRUE;
7753  }
7754 
7755  /* We only support YUV conversions. */
7756  if (!is_complex_fixup(src_format->color_fixup))
7757  {
7759  {
7760  WARN("Claiming fixup support because of ORM_BACKBUFFER.\n");
7761  return TRUE;
7762  }
7763 
7764  TRACE("[FAILED]\n");
7765  return FALSE;
7766  }
7767 
7768  switch(src_fixup)
7769  {
7770  case COMPLEX_FIXUP_YUY2:
7771  case COMPLEX_FIXUP_UYVY:
7772  case COMPLEX_FIXUP_YV12:
7773  case COMPLEX_FIXUP_NV12:
7774  case COMPLEX_FIXUP_P8:
7775  TRACE("[OK]\n");
7776  return TRUE;
7777 
7778  default:
7779  FIXME("Unsupported YUV fixup %#x\n", src_fixup);
7780  TRACE("[FAILED]\n");
7781  return FALSE;
7782  }
7783 }
#define WINED3DFMT_FLAG_STENCIL
enum wined3d_resource_type type
#define TRUE
Definition: types.h:120
static const char * dst_format
Definition: dib.c:1133
Definition: http.c:6587
complex_fixup
unsigned int access
#define WARN(fmt,...)
Definition: debug.h:111
static BOOL is_complex_fixup(struct color_fixup_desc fixup)
const struct wined3d_format * format
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
#define ORM_BACKBUFFER
struct color_fixup_desc color_fixup
#define WINED3D_LOCATION_DRAWABLE
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL is_identity_fixup(struct color_fixup_desc fixup)
enum wined3d_format_id id
#define WINED3D_RESOURCE_ACCESS_GPU
Definition: wined3d.h:55
#define WINED3DFMT_FLAG_COMPRESSED
unsigned int flags[WINED3D_GL_RES_TYPE_COUNT]
#define WINED3DFMT_FLAG_DEPTH
static enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup)
void dump_color_fixup_desc(struct color_fixup_desc fixup)
Definition: utils.c:4792
#define TRACE_ON(x)
Definition: compat.h:65

Referenced by arbfp_blitter_blit().

◆ arbfp_blit_type_compare()

static int arbfp_blit_type_compare ( const void key,
const struct wine_rb_entry entry 
)
static

Definition at line 6895 of file arb_program_shader.c.

6896 {
6897  const struct arbfp_blit_type *ka = key;
6898  const struct arbfp_blit_type *kb = &WINE_RB_ENTRY_VALUE(entry, const struct arbfp_blit_desc, entry)->type;
6899 
6900  return memcmp(ka, kb, sizeof(*ka));
6901 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
HKEY key
Definition: reg.c:42
uint32_t entry
Definition: isohybrid.c:63

Referenced by wined3d_arbfp_blitter_create().

◆ arbfp_blit_unset()

static void arbfp_blit_unset ( const struct wined3d_gl_info gl_info)
static

Definition at line 7686 of file arb_program_shader.c.

7687 {
7688  gl_info->gl_ops.gl.p_glDisable(GL_FRAGMENT_PROGRAM_ARB);
7689  checkGLcall("glDisable(GL_FRAGMENT_PROGRAM_ARB)");
7690 }
struct opengl_funcs gl_ops
#define checkGLcall(A)
#define GL_FRAGMENT_PROGRAM_ARB
Definition: glext.h:1466

Referenced by arbfp_blitter_blit().

◆ arbfp_blitter_blit()

static DWORD arbfp_blitter_blit ( struct wined3d_blitter blitter,
enum wined3d_blit_op  op,
struct wined3d_context context,
struct wined3d_texture src_texture,
unsigned int  src_sub_resource_idx,
DWORD  src_location,
const RECT src_rect,
struct wined3d_texture dst_texture,
unsigned int  dst_sub_resource_idx,
DWORD  dst_location,
const RECT dst_rect,
const struct wined3d_color_key color_key,
enum wined3d_texture_filter_type  filter 
)
static

Definition at line 7785 of file arb_program_shader.c.

7790 {
7791  struct wined3d_device *device = dst_texture->resource.device;
7792  struct wined3d_texture *staging_texture = NULL;
7793  struct wined3d_arbfp_blitter *arbfp_blitter;
7794  struct wined3d_color_key alpha_test_key;
7795  struct wined3d_blitter *next;
7796  unsigned int src_level;
7797  RECT s, d;
7798 
7799  TRACE("blitter %p, op %#x, context %p, src_texture %p, src_sub_resource_idx %u, src_location %s, src_rect %s, "
7800  "dst_texture %p, dst_sub_resource_idx %u, dst_location %s, dst_rect %s, colour_key %p, filter %s.\n",
7801  blitter, op, context, src_texture, src_sub_resource_idx, wined3d_debug_location(src_location),
7802  wine_dbgstr_rect(src_rect), dst_texture, dst_sub_resource_idx, wined3d_debug_location(dst_location),
7804 
7805  if (!arbfp_blit_supported(op, context, &src_texture->resource, src_location,
7806  &dst_texture->resource, dst_location))
7807  {
7808  if (!(next = blitter->next))
7809  {
7810  ERR("No blitter to handle blit op %#x.\n", op);
7811  return dst_location;
7812  }
7813 
7814  TRACE("Forwarding to blitter %p.\n", next);
7815  return next->ops->blitter_blit(next, op, context, src_texture, src_sub_resource_idx, src_location,
7816  src_rect, dst_texture, dst_sub_resource_idx, dst_location, dst_rect, color_key, filter);
7817  }
7818 
7819  arbfp_blitter = CONTAINING_RECORD(blitter, struct wined3d_arbfp_blitter, blitter);
7820 
7821  if (!(src_texture->resource.access & WINED3D_RESOURCE_ACCESS_GPU))
7822  {
7823  struct wined3d_resource_desc desc;
7824  struct wined3d_box upload_box;
7825  HRESULT hr;
7826 
7827  TRACE("Source texture is not GPU accessible, creating a staging texture.\n");
7828 
7829  src_level = src_sub_resource_idx % src_texture->level_count;
7830  desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
7831  desc.format = src_texture->resource.format->id;
7832  desc.multisample_type = src_texture->resource.multisample_type;
7833  desc.multisample_quality = src_texture->resource.multisample_quality;
7834  desc.usage = WINED3DUSAGE_PRIVATE;
7836  desc.width = wined3d_texture_get_level_width(src_texture, src_level);
7837  desc.height = wined3d_texture_get_level_height(src_texture, src_level);
7838  desc.depth = 1;
7839  desc.size = 0;
7840 
7841  if (FAILED(hr = wined3d_texture_create(device, &desc, 1, 1, 0,
7842  NULL, NULL, &wined3d_null_parent_ops, &staging_texture)))
7843  {
7844  ERR("Failed to create staging texture, hr %#x.\n", hr);
7845  return dst_location;
7846  }
7847 
7848  wined3d_box_set(&upload_box, 0, 0, desc.width, desc.height, 0, desc.depth);
7849  wined3d_texture_upload_from_texture(staging_texture, 0, 0, 0, 0,
7850  src_texture, src_sub_resource_idx, &upload_box);
7851 
7852  src_texture = staging_texture;
7853  src_sub_resource_idx = 0;
7854  }
7856  && (src_texture->sub_resources[src_sub_resource_idx].locations
7858  && !wined3d_resource_is_offscreen(&src_texture->resource))
7859  {
7860 
7861  /* Without FBO blits transferring from the drawable to the texture is
7862  * expensive, because we have to flip the data in sysmem. Since we can
7863  * flip in the blitter, we don't actually need that flip anyway. So we
7864  * use the surface's texture as scratch texture, and flip the source
7865  * rectangle instead. */
7866  texture2d_load_fb_texture(src_texture, src_sub_resource_idx, FALSE, context);
7867 
7868  s = *src_rect;
7869  src_level = src_sub_resource_idx % src_texture->level_count;
7870  s.top = wined3d_texture_get_level_height(src_texture, src_level) - s.top;
7871  s.bottom = wined3d_texture_get_level_height(src_texture, src_level) - s.bottom;
7872  src_rect = &s;
7873  }
7874  else
7875  {
7876  wined3d_texture_load(src_texture, context, FALSE);
7877  }
7878 
7880 
7881  if (dst_location == WINED3D_LOCATION_DRAWABLE)
7882  {
7883  d = *dst_rect;
7884  wined3d_texture_translate_drawable_coords(dst_texture, context->win_handle, &d);
7885  dst_rect = &d;
7886  }
7887 
7889  {
7890  GLenum buffer;
7891 
7892  if (dst_location == WINED3D_LOCATION_DRAWABLE)
7893  {
7894  TRACE("Destination texture %p is onscreen.\n", dst_texture);
7895  buffer = wined3d_texture_get_gl_buffer(dst_texture);
7896  }
7897  else
7898  {
7899  TRACE("Destination texture %p is offscreen.\n", dst_texture);
7901  }
7903  &dst_texture->resource, dst_sub_resource_idx, NULL, 0, dst_location);
7907  }
7908 
7910  {
7911  const struct wined3d_format *fmt = src_texture->resource.format;
7912  alpha_test_key.color_space_low_value = 0;
7913  alpha_test_key.color_space_high_value = ~(((1u << fmt->alpha_size) - 1) << fmt->alpha_offset);
7914  color_key = &alpha_test_key;
7915  }
7916 
7917  arbfp_blit_set(arbfp_blitter, context, src_texture, src_sub_resource_idx, color_key);
7918 
7919  /* Draw a textured quad */
7920  context_draw_textured_quad(context, src_texture, src_sub_resource_idx, src_rect, dst_rect, filter);
7921 
7922  /* Leave the opengl state valid for blitting */
7923  arbfp_blit_unset(context->gl_info);
7924 
7925  if (dst_texture->swapchain && (dst_texture->swapchain->front_buffer == dst_texture))
7926  context->gl_info->gl_ops.gl.p_glFlush();
7927 
7928  if (staging_texture)
7929  wined3d_texture_decref(staging_texture);
7930 
7931  return dst_location;
7932 }
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 ORM_FBO
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
HRESULT hr
Definition: shlfolder.c:183
Definition: http.c:6587
struct wined3d_swapchain * swapchain
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target, struct wined3d_resource *rt, unsigned int rt_sub_resource_idx, struct wined3d_resource *ds, unsigned int ds_sub_resource_idx, DWORD location)
Definition: context.c:788
struct wined3d_blitter * next
struct wined3d_resource resource
GLuint buffer
Definition: glext.h:5915
void context_invalidate_state(struct wined3d_context *context, DWORD state)
Definition: context.c:1638
static void wined3d_box_set(struct wined3d_box *box, unsigned int left, unsigned int top, unsigned int right, unsigned int bottom, unsigned int front, unsigned int back)
Definition: wined3d.h:2793
static HRESULT arbfp_blit_set(struct wined3d_arbfp_blitter *blitter, struct wined3d_context *context, const struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_color_key *color_key)
void context_draw_textured_quad(struct wined3d_context *context, struct wined3d_texture *texture, unsigned int sub_resource_idx, const RECT *src_rect, const RECT *dst_rect, enum wined3d_texture_filter_type filter)
Definition: context.c:5741
#define GL_COLOR_ATTACHMENT0
Definition: glext.h:1714
const char * wined3d_debug_location(DWORD location)
Definition: utils.c:6306
Definition: devices.h:37
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
smooth NULL
Definition: ftsmooth.c:416
#define WINED3D_LOCATION_DRAWABLE
void context_check_fbo_status(const struct wined3d_context *context, GLenum target)
Definition: context.c:382
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define GL_DRAW_FRAMEBUFFER
Definition: glext.h:1699
static BOOL arbfp_blit_supported(enum wined3d_blit_op blit_op, const struct wined3d_context *context, const struct wined3d_resource *src_resource, DWORD src_location, const struct wined3d_resource *dst_resource, DWORD dst_location)
void texture2d_load_fb_texture(struct wined3d_texture *texture, unsigned int sub_resource_idx, BOOL srgb, struct wined3d_context *context)
Definition: surface.c:1215
#define TRACE(s)
Definition: solgame.cpp:4
#define d
Definition: ke_i.h:81
void context_apply_ffp_blit_state(struct wined3d_context *context, const struct wined3d_device *device)
Definition: context.c:2899
LONG HRESULT
Definition: typedefs.h:77
const char * debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type)
Definition: utils.c:4480
const char * wine_dbgstr_rect(const RECT *rect)
void wined3d_texture_upload_from_texture(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, const struct wined3d_box *src_box)
Definition: texture.c:3528
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource)
Definition: resource.c:540
GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture)
Definition: texture.c:91
void wined3d_texture_translate_drawable_coords(const struct wined3d_texture *texture, HWND window, RECT *rect)
Definition: texture.c:69
GLdouble s
Definition: gl.h:2039
unsigned int GLenum
Definition: gl.h:150
#define WINED3DUSAGE_PRIVATE
Definition: wined3d.h:925
#define WINED3D_RESOURCE_ACCESS_GPU
Definition: wined3d.h:55
struct wined3d_texture::wined3d_texture_sub_resource sub_resources[1]
static void arbfp_blit_unset(const struct wined3d_gl_info *gl_info)
#define ERR(fmt,...)
Definition: debug.h:109
static unsigned __int64 next
Definition: rand_nt.c:6
const struct wined3d_parent_ops wined3d_null_parent_ops
Definition: directx.c:6781
#define WINED3D_LOCATION_TEXTURE_RGB
void wined3d_texture_load(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:1262
#define STATE_FRAMEBUFFER
ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
Definition: texture.c:1219
UINT op
Definition: effect.c:223
void context_set_draw_buffer(struct wined3d_context *context, GLenum buffer)
Definition: context.c:2470
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
Definition: dsound.c:943
HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct wined3d_resource_desc *desc, UINT layer_count, UINT level_count, DWORD flags, const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture)
Definition: texture.c:3326

◆ arbfp_blitter_clear()

static void arbfp_blitter_clear ( struct wined3d_blitter blitter,
struct wined3d_device device,
unsigned int  rt_count,
const struct wined3d_fb_state fb,
unsigned int  rect_count,
const RECT clear_rects,
const RECT draw_rect,
DWORD  flags,
const struct wined3d_color colour,
float  depth,
DWORD  stencil 
)
static

Definition at line 7934 of file arb_program_shader.c.

7937 {
7938  struct wined3d_blitter *next;
7939 
7940  if ((next = blitter->next))
7941  next->ops->blitter_clear(next, device, rt_count, fb, rect_count,
7942  clear_rects, draw_rect, flags, colour, depth, stencil);
7943 }
struct wined3d_blitter * next
GLint GLfloat GLint stencil
Definition: glext.h:6260
Definition: devices.h:37
GLbitfield flags
Definition: glext.h:7161
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
static unsigned __int64 next
Definition: rand_nt.c:6

◆ arbfp_blitter_destroy()

static void arbfp_blitter_destroy ( struct wined3d_blitter blitter,
struct wined3d_context context 
)
static

Definition at line 6919 of file arb_program_shader.c.

6920 {
6921  const struct wined3d_gl_info *gl_info = context->gl_info;
6922  struct wined3d_arbfp_blitter *arbfp_blitter;
6923  struct wined3d_blitter *next;
6924 
6925  if ((next = blitter->next))
6926  next->ops->blitter_destroy(next, context);
6927 
6928  arbfp_blitter = CONTAINING_RECORD(blitter, struct wined3d_arbfp_blitter, blitter);
6929 
6931  checkGLcall("Delete blit programs");
6932 
6933  if (arbfp_blitter->palette_texture)
6934  gl_info->gl_ops.gl.p_glDeleteTextures(1, &arbfp_blitter->palette_texture);
6935 
6936  heap_free(arbfp_blitter);
6937 }
struct opengl_funcs gl_ops
Definition: http.c:6587
struct wined3d_blitter * next
static void arbfp_free_blit_shader(struct wine_rb_entry *entry, void *ctx)
struct wine_rb_tree shaders
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static void wine_rb_destroy(struct wine_rb_tree *tree, wine_rb_traverse_func_t *callback, void *context)
Definition: rbtree.h:198
static unsigned __int64 next
Definition: rand_nt.c:6
#define checkGLcall(A)
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ arbfp_enable()

static void arbfp_enable ( const struct wined3d_gl_info gl_info,
BOOL  enable 
)
static

Definition at line 5692 of file arb_program_shader.c.

5693 {
5694  if (enable)
5695  {
5696  gl_info->gl_ops.gl.p_glEnable(GL_FRAGMENT_PROGRAM_ARB);
5697  checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB)");
5698  }
5699  else
5700  {
5701  gl_info->gl_ops.gl.p_glDisable(GL_FRAGMENT_PROGRAM_ARB);
5702  checkGLcall("glDisable(GL_FRAGMENT_PROGRAM_ARB)");
5703  }
5704 }
struct opengl_funcs gl_ops
GLboolean enable
Definition: glext.h:11120
#define checkGLcall(A)
#define GL_FRAGMENT_PROGRAM_ARB
Definition: glext.h:1466

◆ arbfp_free()

static void arbfp_free ( struct wined3d_device device)
static

Definition at line 5737 of file arb_program_shader.c.

5738 {
5739  struct shader_arb_priv *priv = device->fragment_priv;
5740 
5741  wine_rb_destroy(&priv->fragment_shaders, arbfp_free_ffpshader, &device->adapter->gl_info);
5742  priv->use_arbfp_fixed_func = FALSE;
5743 
5744  if (device->shader_backend != &arb_program_shader_backend)
5745  heap_free(device->fragment_priv);
5746 }
static void arbfp_free_ffpshader(struct wine_rb_entry *entry, void *context)
Definition: devices.h:37
struct wine_rb_tree fragment_shaders
static void wine_rb_destroy(struct wine_rb_tree *tree, wine_rb_traverse_func_t *callback, void *context)
Definition: rbtree.h:198
const struct wined3d_shader_backend_ops arb_program_shader_backend
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ arbfp_free_blit_shader()

static void arbfp_free_blit_shader ( struct wine_rb_entry entry,
void ctx 
)
static

Definition at line 6904 of file arb_program_shader.c.

6905 {
6906  struct arbfp_blit_desc *entry_arb = WINE_RB_ENTRY_VALUE(entry, struct arbfp_blit_desc, entry);
6907  const struct wined3d_gl_info *gl_info;
6908  struct wined3d_context *context;
6909 
6910  context = ctx;
6911  gl_info = context->gl_info;
6912 
6913  GL_EXTCALL(glDeleteProgramsARB(1, &entry_arb->shader));
6914  checkGLcall("glDeleteProgramsARB(1, &entry_arb->shader)");
6915  heap_free(entry_arb);
6916 }
Definition: http.c:6587
#define GL_EXTCALL(f)
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
uint32_t entry
Definition: isohybrid.c:63
#define checkGLcall(A)
const struct wined3d_gl_info * gl_info
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by arbfp_blitter_destroy().

◆ arbfp_free_context_data()

static void arbfp_free_context_data ( struct wined3d_context context)
static

Definition at line 6853 of file arb_program_shader.c.

6854 {
6855 }

◆ arbfp_free_ffpshader()

static void arbfp_free_ffpshader ( struct wine_rb_entry entry,
void context 
)
static

Definition at line 5726 of file arb_program_shader.c.

5727 {
5728  const struct wined3d_gl_info *gl_info = context;
5729  struct arbfp_ffp_desc *entry_arb = WINE_RB_ENTRY_VALUE(entry, struct arbfp_ffp_desc, parent.entry);
5730 
5731  GL_EXTCALL(glDeleteProgramsARB(1, &entry_arb->shader));
5732  checkGLcall("glDeleteProgramsARB(1, &entry_arb->shader)");
5733  heap_free(entry_arb);
5734 }
Definition: http.c:6587
#define GL_EXTCALL(f)
r parent
Definition: btrfs.c:2677
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
uint32_t entry
Definition: isohybrid.c:63
#define checkGLcall(A)
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by arbfp_free().

◆ arbfp_gen_plain_shader()

static GLuint arbfp_gen_plain_shader ( const struct wined3d_gl_info gl_info,
const struct arbfp_blit_type type 
)
static

Definition at line 7504 of file arb_program_shader.c.

7505 {
7506  GLuint shader;
7508  const char *tex_target = arbfp_texture_target(type->res_type);
7509 
7510  /* Shader header */
7511  if (!string_buffer_init(&buffer))
7512  {
7513  ERR("Failed to initialize shader buffer.\n");
7514  return 0;
7515  }
7516 
7517  GL_EXTCALL(glGenProgramsARB(1, &shader));
7518  if (!shader)
7519  {
7521  return 0;
7522  }
7523  GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader));
7524 
7525  shader_addline(&buffer, "!!ARBfp1.0\n");
7526 
7527  if (type->use_color_key)
7528  {
7529  shader_addline(&buffer, "TEMP color;\n");
7530  shader_addline(&buffer, "TEMP less, greater;\n");
7531  shader_addline(&buffer, "PARAM color_key_low = program.local[%u];\n", ARBFP_BLIT_PARAM_COLOR_KEY_LOW);
7532  shader_addline(&buffer, "PARAM color_key_high = program.local[%u];\n", ARBFP_BLIT_PARAM_COLOR_KEY_HIGH);
7533  shader_addline(&buffer, "TEX color, fragment.texcoord[0], texture[0], %s;\n", tex_target);
7534  shader_addline(&buffer, "SLT less, color, color_key_low;\n"); /* below low key */
7535  shader_addline(&buffer, "SGE greater, color, color_key_high;\n"); /* above high key */
7536  shader_addline(&buffer, "ADD less, less, greater;\n"); /* or */
7537  shader_addline(&buffer, "DP4 less.b, less, less;\n"); /* on any channel */
7538  shader_addline(&buffer, "SGE less, -less.b, 0.0;\n"); /* logical not */
7539  shader_addline(&buffer, "KIL -less;\n"); /* discard if true */
7540  shader_addline(&buffer, "MOV result.color, color;\n");
7541  }
7542  else
7543  {
7544  shader_addline(&buffer, "TEX result.color, fragment.texcoord[0], texture[0], %s;\n", tex_target);
7545  }
7546 
7547  shader_addline(&buffer, "END\n");
7548 
7550 
7552 
7553  return shader;
7554 }
#define ARBFP_BLIT_PARAM_COLOR_KEY_LOW
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
BOOL string_buffer_init(struct wined3d_string_buffer *buffer)
Definition: shader.c:437
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
static const char * arbfp_texture_target(enum wined3d_gl_resource_type type)
void string_buffer_free(struct wined3d_string_buffer *buffer)
Definition: shader.c:450
#define GL_EXTCALL(f)
GLuint shader
Definition: glext.h:6030
static BOOL shader_arb_compile(const struct wined3d_gl_info *gl_info, GLenum target, const char *src)
#define ERR(fmt,...)
Definition: debug.h:109
unsigned int GLuint
Definition: gl.h:159
#define ARBFP_BLIT_PARAM_COLOR_KEY_HIGH
#define GL_FRAGMENT_PROGRAM_ARB
Definition: glext.h:1466

Referenced by arbfp_blit_set().

◆ arbfp_get_caps()

static void arbfp_get_caps ( const struct wined3d_gl_info gl_info,
struct fragment_caps caps 
)
static

Definition at line 5748 of file arb_program_shader.c.

5749 {
5779 
5780  /* TODO: Implement WINED3DTEXOPCAPS_PREMODULATE */
5781 
5784 }
DWORD MaxTextureBlendStages
#define MAX_TEXTURES
#define WINED3D_FRAGMENT_CAP_PROJ_CONTROL
#define WINED3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA
Definition: wined3d.h:1167
#define WINED3DTEXOPCAPS_DISABLE
Definition: wined3d.h:1147
#define WINED3DTEXOPCAPS_BLENDCURRENTALPHA
Definition: wined3d.h:1162
#define WINED3DTEXOPCAPS_ADDSIGNED
Definition: wined3d.h:1154
#define WINED3DTEXOPCAPS_MODULATE
Definition: wined3d.h:1150
#define WINED3D_FRAGMENT_CAP_SRGB_WRITE
#define WINED3DTEXOPCAPS_ADDSIGNED2X
Definition: wined3d.h:1155
#define WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA
Definition: wined3d.h:1158
#define WINED3DTEXOPCAPS_ADDSMOOTH
Definition: wined3d.h:1157
#define WINED3DTEXOPCAPS_SELECTARG2
Definition: wined3d.h:1149
#define WINED3DTEXOPCAPS_LERP
Definition: wined3d.h:1172
#define WINED3DTEXOPCAPS_BLENDFACTORALPHA
Definition: wined3d.h:1160
#define WINED3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR
Definition: wined3d.h:1166
#define WINED3DPMISCCAPS_TSSARGTEMP
Definition: wined3d.h:1103
#define WINED3DTEXOPCAPS_DOTPRODUCT3
Definition: wined3d.h:1170
#define WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM
Definition: wined3d.h:1161
#define WINED3DTEXOPCAPS_MODULATE4X
Definition: wined3d.h:1152
#define WINED3DTEXOPCAPS_SELECTARG1
Definition: wined3d.h:1148
#define WINED3DTEXOPCAPS_BUMPENVMAPLUMINANCE
Definition: wined3d.h:1169
#define WINED3DTEXOPCAPS_MULTIPLYADD
Definition: wined3d.h:1171
DWORD MaxSimultaneousTextures
#define WINED3DTEXOPCAPS_MODULATE2X
Definition: wined3d.h:1151
#define min(a, b)
Definition: monoChain.cc:55
#define WINED3DTEXOPCAPS_SUBTRACT
Definition: wined3d.h:1156
#define WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
Definition: wined3d.h:1165
struct wined3d_gl_limits limits
#define WINED3DTEXOPCAPS_BLENDTEXTUREALPHA
Definition: wined3d.h:1159
#define WINED3DTEXOPCAPS_BUMPENVMAP
Definition: wined3d.h:1168
#define WINED3D_FRAGMENT_CAP_COLOR_KEY
#define WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
Definition: wined3d.h:1164
#define WINED3DTEXOPCAPS_ADD
Definition: wined3d.h:1153

◆ arbfp_get_emul_mask()

static DWORD arbfp_get_emul_mask ( const struct wined3d_gl_info gl_info)
static

Definition at line 5786 of file arb_program_shader.c.

5787 {
5789 }
#define GL_EXT_EMUL_EXT_FOG_COORD
#define GL_EXT_EMUL_ARB_MULTITEXTURE

◆ arbfp_texture_target()

static const char* arbfp_texture_target ( enum wined3d_gl_resource_type  type)
static

Definition at line 6206 of file arb_program_shader.c.

6207 {
6208  switch(type)
6209  {
6211  return "1D";
6213  return "2D";
6215  return "3D";
6217  return "CUBE";
6219  return "RECT";
6220  default:
6221  return "unexpected_resource_type";
6222  }
6223 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Referenced by arbfp_gen_plain_shader(), gen_arbfp_ffp_shader(), gen_nv12_read(), gen_p8_shader(), gen_packed_yuv_read(), and gen_yv12_read().

◆ calc_color_correction()

static struct color_fixup_masks calc_color_correction ( struct color_fixup_desc  fixup,
DWORD  dst_mask 
)
static

Definition at line 1290 of file arb_program_shader.c.

1291 {
1292  struct color_fixup_masks masks = {0, 0};
1293 
1294  if (is_complex_fixup(fixup))
1295  {
1297  FIXME("Complex fixup (%#x) not supported\n", complex_fixup);
1298  return masks;
1299  }
1300 
1301  if (fixup.x_source != CHANNEL_SOURCE_X)
1302  masks.source |= WINED3DSP_WRITEMASK_0;
1303  if (fixup.y_source != CHANNEL_SOURCE_Y)
1304  masks.source |= WINED3DSP_WRITEMASK_1;
1305  if (fixup.z_source != CHANNEL_SOURCE_Z)
1306  masks.source |= WINED3DSP_WRITEMASK_2;
1307  if (fixup.w_source != CHANNEL_SOURCE_W)
1308  masks.source |= WINED3DSP_WRITEMASK_3;
1309  masks.source &= dst_mask;
1310 
1311  if (fixup.x_sign_fixup)
1312  masks.sign |= WINED3DSP_WRITEMASK_0;
1313  if (fixup.y_sign_fixup)
1314  masks.sign |= WINED3DSP_WRITEMASK_1;
1315  if (fixup.z_sign_fixup)
1316  masks.sign |= WINED3DSP_WRITEMASK_2;
1317  if (fixup.w_sign_fixup)
1318  masks.sign |= WINED3DSP_WRITEMASK_3;
1319  masks.sign &= dst_mask;
1320 
1321  return masks;
1322 }
unsigned short w_sign_fixup
unsigned short x_source
#define WINED3DSP_WRITEMASK_0
unsigned short z_sign_fixup
unsigned short w_source
complex_fixup
static BOOL is_complex_fixup(struct color_fixup_desc fixup)
unsigned short x_sign_fixup
#define FIXME(fmt,...)
Definition: debug.h:110
unsigned short z_source
unsigned short y_sign_fixup
#define WINED3DSP_WRITEMASK_1
#define WINED3DSP_WRITEMASK_2
static enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup)
#define WINED3DSP_WRITEMASK_3
unsigned short y_source
static const BYTE masks[8]
Definition: dib.c:2760

Referenced by gen_arbfp_ffp_shader(), and shader_hw_sample().

◆ clone_sig()

static void clone_sig ( struct wined3d_shader_signature new,
const struct wined3d_shader_signature sig 
)
static

Definition at line 3865 of file arb_program_shader.c.

3866 {
3867  unsigned int i;
3868  char *name;
3869 
3870  new->element_count = sig->element_count;
3871  new->elements = heap_calloc(new->element_count, sizeof(*new->elements));
3872  for (i = 0; i < sig->element_count; ++i)
3873  {
3874  new->elements[i] = sig->elements[i];
3875 
3876  if (!new->elements[i].semantic_name)
3877  continue;
3878 
3879  /* Clone the semantic string */
3880  name = heap_alloc(strlen(sig->elements[i].semantic_name) + 1);
3881  strcpy(name, sig->elements[i].semantic_name);
3882  new->elements[i].semantic_name = name;
3883  }
3884 }
#define new(TYPE, numElems)
Definition: treelist.c:54
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static void * heap_calloc(SIZE_T count, SIZE_T size)
Definition: heap.h:49
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
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: name.c:36
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
struct wined3d_shader_signature_element * elements
Definition: wined3d.h:2047
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by find_input_signature().

◆ color_key_arbfp()

static void color_key_arbfp ( struct wined3d_context context,
const struct wined3d_state state,
DWORD  state_id 
)
static

Definition at line 5971 of file arb_program_shader.c.

5972 {
5973  const struct wined3d_texture *texture = state->textures[0];
5974  const struct wined3d_gl_info *gl_info = context->gl_info;
5975  struct wined3d_device *device = context->device;
5976  struct wined3d_color float_key[2];
5977 
5978  if (!texture)
5979  return;
5980 
5981  if (device->shader_backend == &arb_program_shader_backend)
5982  {
5983  struct shader_arb_priv *priv;
5984 
5985  /* Don't load the parameter if we're using an arbfp pixel shader,
5986  * otherwise we'll overwrite application provided constants. */
5987  if (use_ps(state))
5988  return;
5989 
5990  priv = device->shader_priv;
5994  }
5995 
5996  wined3d_format_get_float_color_key(texture->resource.format, &texture->async.src_blt_color_key, float_key);
5997 
5998  GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_COLOR_KEY_LOW, &float_key[0].r));
5999  checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_COLOR_KEY_LOW, &float_key[0].r)");
6000  GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_COLOR_KEY_HIGH, &float_key[1].r));
6001  checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_COLOR_KEY_HIGH, &float_key[1].r)");
6002 }
char pshader_const_dirty[WINED3D_MAX_PS_CONSTS_F]
#define max(a, b)
Definition: svc.c:63
unsigned int highest_dirty_ps_const
#define ARB_FFP_CONST_COLOR_KEY_LOW
Definition: http.c:6587
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
void wined3d_format_get_float_color_key(const struct wined3d_format *format, const struct wined3d_color_key *key, struct wined3d_color *float_colors)
Definition: utils.c:5263
Definition: devices.h:37
#define GL_EXTCALL(f)
GLenum GLuint texture
Definition: glext.h:6295
static int state
Definition: maze.c:121
static BOOL use_ps(const struct wined3d_state *state)
#define checkGLcall(A)
#define ARB_FFP_CONST_COLOR_KEY_HIGH
const struct wined3d_shader_backend_ops arb_program_shader_backend
#define GL_FRAGMENT_PROGRAM_ARB
Definition: glext.h:1466

Referenced by fragment_prog_arbfp().

◆ compare_sig()

static int compare_sig ( const struct wined3d_shader_signature sig1,
const struct wined3d_shader_signature sig2 
)
static

Definition at line 3825 of file arb_program_shader.c.

3826 {
3827  unsigned int i;
3828  int ret;
3829 
3830  if (sig1->element_count != sig2->element_count)
3831  return sig1->element_count < sig2->element_count ? -1 : 1;
3832 
3833  for (i = 0; i < sig1->element_count; ++i)
3834  {
3835  const struct wined3d_shader_signature_element *e1, *e2;
3836 
3837  e1 = &sig1->elements[i];
3838  e2 = &sig2->elements[i];
3839 
3840  if (!e1->semantic_name || !e2->semantic_name)
3841  {
3842  /* Compare pointers, not contents. One string is NULL (element
3843  * does not exist), the other one is not NULL. */
3844  if (e1->semantic_name != e2->semantic_name)
3845  return e1->semantic_name < e2->semantic_name ? -1 : 1;
3846  continue;
3847  }
3848 
3849  if ((ret = strcmp(e1->semantic_name, e2->semantic_name)))
3850  return ret;
3851  if (e1->semantic_idx != e2->semantic_idx)
3852  return e1->semantic_idx < e2->semantic_idx ? -1 : 1;
3853  if (e1->sysval_semantic != e2->sysval_semantic)
3854  return e1->sysval_semantic < e2->sysval_semantic ? -1 : 1;
3855  if (e1->component_type != e2->component_type)
3856  return e1->component_type < e2->component_type ? -1 : 1;
3857  if (e1->register_idx != e2->register_idx)
3858  return e1->register_idx < e2->register_idx ? -1 : 1;
3859  if (e1->mask != e2->mask)
3860  return e1->mask < e2->mask ? -1 : 1;
3861  }
3862  return 0;
3863 }
enum wined3d_component_type component_type
Definition: wined3d.h:2039
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
enum wined3d_sysval_semantic sysval_semantic
Definition: wined3d.h:2038
int ret
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
struct wined3d_shader_signature_element * elements
Definition: wined3d.h:2047

Referenced by sig_tree_compare().

◆ ffp_clip_emul()

static BOOL ffp_clip_emul ( const struct wined3d_context context)
inlinestatic

Definition at line 124 of file arb_program_shader.c.

125 {
126  return context->lowest_disabled_stage < 7;
127 }
Definition: http.c:6587

Referenced by find_arb_vs_compile_args().

◆ find_arb_ps_compile_args()

static void find_arb_ps_compile_args ( const struct wined3d_state state,
const struct wined3d_context context,
const struct wined3d_shader shader,
struct arb_ps_compile_args args 
)
static

Definition at line 4418 of file arb_program_shader.c.

4421 {
4422  const struct wined3d_gl_info *gl_info = context->gl_info;
4423  const struct wined3d_d3d_info *d3d_info = context->d3d_info;
4424  int i;
4425  WORD int_skip;
4426 
4427  find_ps_compile_args(state, shader, context->stream_info.position_transformed, &args->super, context);
4428 
4429  /* This forces all local boolean constants to 1 to make them stateblock independent */
4430  args->bools = shader->reg_maps.local_bool_consts;
4431 
4432  for (i = 0; i < WINED3D_MAX_CONSTS_B; ++i)
4433  {
4434  if (state->ps_consts_b[i])
4435  args->bools |= ( 1u << i);
4436  }
4437 
4438  /* Only enable the clip plane emulation KIL if at least one clipplane is enabled. The KIL instruction
4439  * is quite expensive because it forces the driver to disable early Z discards. It is cheaper to
4440  * duplicate the shader than have a no-op KIL instruction in every shader
4441  */
4442  if (!d3d_info->vs_clipping && use_vs(state)
4443  && state->render_states[WINED3D_RS_CLIPPING]
4444  && state->render_states[WINED3D_RS_CLIPPLANEENABLE])
4445  args->clip = 1;
4446  else
4447  args->clip = 0;
4448 
4449  /* Skip if unused or local, or supported natively */
4450  int_skip = ~shader->reg_maps.integer_constants | shader->reg_maps.local_int_consts;
4451  if (int_skip == 0xffff || gl_info->supported[NV_FRAGMENT_PROGRAM_OPTION])
4452  {
4453  memset(args->loop_ctrl, 0, sizeof(args->loop_ctrl));
4454  return;
4455  }
4456 
4457  for (i = 0; i < WINED3D_MAX_CONSTS_I; ++i)
4458  {
4459  if (int_skip & (1u << i))
4460  {
4461  args->loop_ctrl[i][0] = 0;
4462  args->loop_ctrl[i][1] = 0;
4463  args->loop_ctrl[i][2] = 0;
4464  }
4465  else
4466  {
4467  args->loop_ctrl[i][0] = state->ps_consts_i[i].x;
4468  args->loop_ctrl[i][1] = state->ps_consts_i[i].y;
4469  args->loop_ctrl[i][2] = state->ps_consts_i[i].z;
4470  }
4471  }
4472 }
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
Definition: http.c:6587
#define WINED3D_MAX_CONSTS_I
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: shader.c:3873
Definition: match.c:390
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
BOOL supported[WINED3D_GL_EXT_COUNT]
GLuint shader
Definition: glext.h:6030
if(!(yy_init))
Definition: macro.lex.yy.c:714
unsigned short WORD
Definition: ntddk_ex.h:93
static int state
Definition: maze.c:121
#define WINED3D_MAX_CONSTS_B
static BOOL use_vs(const struct wined3d_state *state)
#define memset(x, y, z)
Definition: compat.h:39

Referenced by shader_arb_select().

◆ find_arb_pshader()

static struct arb_ps_compiled_shader* find_arb_pshader ( struct wined3d_shader shader,
const struct arb_ps_compile_args args 
)
static

Definition at line 4232 of file arb_program_shader.c.

4234 {
4235  struct wined3d_device *device = shader->device;
4236  const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
4237  const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
4238  UINT i;
4239  DWORD new_size;
4240  struct arb_ps_compiled_shader *new_array;
4242  struct arb_pshader_private *shader_data;
4243  GLuint ret;
4244 
4245  if (!shader->backend_data)
4246  {
4247  struct shader_arb_priv *priv = device->shader_priv;
4248 
4249  shader->backend_data = heap_alloc_zero(sizeof(*shader_data));
4250  shader_data = shader->backend_data;
4251  shader_data->clamp_consts = shader->reg_maps.shader_version.major == 1;
4252 
4253  if (shader->reg_maps.shader_version.major < 3)
4254  shader_data->input_signature_idx = ~0U;
4255  else
4256  shader_data->input_signature_idx = find_input_signature(priv, &shader->input_signature);
4257 
4258  TRACE("Shader got assigned input signature index %u\n", shader_data->input_signature_idx);
4259 
4260  if (!d3d_info->vs_clipping)
4262  d3d_info->limits.ffp_blend_stages - 1);
4263  else
4264  shader_data->clipplane_emulation = ~0U;
4265  }
4266  shader_data = shader->backend_data;
4267 
4268  /* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
4269  * so a linear search is more performant than a hashmap or a binary search
4270  * (cache coherency etc)
4271  */
4272  for (i = 0; i < shader_data->num_gl_shaders; ++i)
4273  {
4274  if (!memcmp(&shader_data->gl_shaders[i].args, args, sizeof(*args)))
4275  return &shader_data->gl_shaders[i];
4276  }
4277 
4278  TRACE("No matching GL shader found, compiling a new shader\n");
4279  if(shader_data->shader_array_size == shader_data->num_gl_shaders) {
4280  if (shader_data->num_gl_shaders)
4281  {
4282  new_size = shader_data->shader_array_size + max(1, shader_data->shader_array_size / 2);
4283  new_array = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, shader_data->gl_shaders,
4284  new_size * sizeof(*shader_data->gl_shaders));
4285  }
4286  else
4287  {
4288  new_array = heap_alloc_zero(sizeof(*shader_data->gl_shaders));
4289  new_size = 1;
4290  }
4291 
4292  if(!new_array) {
4293  ERR("Out of memory\n");
4294  return 0;
4295  }
4296  shader_data->gl_shaders = new_array;
4297  shader_data->shader_array_size = new_size;
4298  }
4299 
4300  shader_data->gl_shaders[shader_data->num_gl_shaders].args = *args;
4301 
4302  pixelshader_update_resource_types(shader, args->super.tex_types);
4303 
4304  if (!string_buffer_init(&buffer))
4305  {
4306  ERR("Failed to initialize shader buffer.\n");
4307  return 0;
4308  }
4309 
4311  &shader_data->gl_shaders[shader_data->num_gl_shaders]);
4313  shader_data->gl_shaders[shader_data->num_gl_shaders].prgId = ret;
4314 
4315  return &shader_data->gl_shaders[shader_data->num_gl_shaders++];
4316 }
#define max(a, b)
Definition: svc.c:63
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
BOOL string_buffer_init(struct wined3d_string_buffer *buffer)
Definition: shader.c:437
#define U(x)
Definition: wordpad.c:44
GLuint buffer
Definition: glext.h:5915
Definition: match.c:390
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
void pixelshader_update_resource_types(struct wined3d_shader *shader, WORD tex_types)
Definition: shader.c:4163
Definition: devices.h:37
void string_buffer_free(struct wined3d_string_buffer *buffer)
Definition: shader.c:450
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define ERR(fmt,...)
Definition: debug.h:109
unsigned int GLuint
Definition: gl.h:159
struct wined3d_d3d_limits limits
#define HeapReAlloc
Definition: compat.h:393
struct arb_ps_compiled_shader * gl_shaders
unsigned int UINT
Definition: ndis.h:50
unsigned int shader_find_free_input_register(const struct wined3d_shader_reg_maps *reg_maps, unsigned int max)
Definition: shader.c:1871
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
static DWORD find_input_signature(struct shader_arb_priv *priv, const struct wined3d_shader_signature *sig)
static GLuint shader_arb_generate_pshader(const struct wined3d_shader *shader, const struct wined3d_gl_info *gl_info, struct wined3d_string_buffer *buffer, const struct arb_ps_compile_args *args, struct arb_ps_compiled_shader *compiled)
#define args
Definition: format.c:66

Referenced by shader_arb_select().

◆ find_arb_vs_compile_args()

static void find_arb_vs_compile_args ( const struct wined3d_state state,
const struct wined3d_context context,
const struct wined3d_shader shader,
struct arb_vs_compile_args args 
)
static

Definition at line 4474 of file arb_program_shader.c.

4477 {
4478  const struct wined3d_device *device = shader->device;
4479  const struct wined3d_adapter *adapter = device->adapter;
4480  const struct wined3d_gl_info *gl_info = context->gl_info;
4481  const struct wined3d_d3d_info *d3d_info = context->d3d_info;
4482  int i;
4483  WORD int_skip;
4484 
4485  find_vs_compile_args(state, shader, context->stream_info.swizzle_map, &args->super, context);
4486 
4487  args->clip.boolclip_compare = 0;
4488  if (use_ps(state))
4489  {
4490  const struct wined3d_shader *ps = state->shader[WINED3D_SHADER_TYPE_PIXEL];
4491  const struct arb_pshader_private *shader_priv = ps->backend_data;
4492  args->ps_signature = shader_priv->input_signature_idx;
4493 
4494  args->clip.boolclip.clip_texcoord = shader_priv->clipplane_emulation + 1;
4495  }
4496  else
4497  {
4498  args->ps_signature = ~0;
4499  if (!d3d_info->vs_clipping && adapter->fragment_pipe == &arbfp_fragment_pipeline)
4500  args->clip.boolclip.clip_texcoord = ffp_clip_emul(context) ? d3d_info->limits.ffp_blend_stages : 0;
4501  /* Otherwise: Setting boolclip_compare set clip_texcoord to 0 */
4502  }
4503 
4504  if (args->clip.boolclip.clip_texcoord)
4505  {
4506  if (state->render_states[WINED3D_RS_CLIPPING])
4507  args->clip.boolclip.clipplane_mask = (unsigned char)state->render_states[WINED3D_RS_CLIPPLANEENABLE];
4508  /* clipplane_mask was set to 0 by setting boolclip_compare to 0 */
4509  }
4510 
4511  /* This forces all local boolean constants to 1 to make them stateblock independent */
4512  args->clip.boolclip.bools = shader->reg_maps.local_bool_consts;
4513  /* TODO: Figure out if it would be better to store bool constants as bitmasks in the stateblock */
4514  for (i = 0; i < WINED3D_MAX_CONSTS_B; ++i)
4515  {
4516  if (state->vs_consts_b[i])
4517  args->clip.boolclip.bools |= (1u << i);
4518  }
4519 
4520  args->vertex.samplers[0] = context->tex_unit_map[MAX_FRAGMENT_SAMPLERS + 0];
4521  args->vertex.samplers[1] = context->tex_unit_map[MAX_FRAGMENT_SAMPLERS + 1];
4522  args->vertex.samplers[2] = context->tex_unit_map[MAX_FRAGMENT_SAMPLERS + 2];
4523  args->vertex.samplers[3] = 0;
4524 
4525  /* Skip if unused or local */
4526  int_skip = ~shader->reg_maps.integer_constants | shader->reg_maps.local_int_consts;
4527  /* This is about flow control, not clipping. */
4528  if (int_skip == 0xffff || gl_info->supported[NV_VERTEX_PROGRAM2_OPTION])
4529  {
4530  memset(args->loop_ctrl, 0, sizeof(args->loop_ctrl));
4531  return;
4532  }
4533 
4534  for (i = 0; i < WINED3D_MAX_CONSTS_I; ++i)
4535  {
4536  if (int_skip & (1u << i))
4537  {
4538  args->loop_ctrl[i][0] = 0;
4539  args->loop_ctrl[i][1] = 0;
4540  args->loop_ctrl[i][2] = 0;
4541  }
4542  else
4543  {
4544  args->loop_ctrl[i][0] = state->vs_consts_i[i].x;
4545  args->loop_ctrl[i][1] = state->vs_consts_i[i].y;
4546  args->loop_ctrl[i][2] = state->vs_consts_i[i].z;
4547  }
4548  }
4549 }
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
Definition: http.c:6587
struct wined3d_pixel_shader ps
#define WINED3D_MAX_CONSTS_I
Definition: match.c:390
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
BOOL supported[WINED3D_GL_EXT_COUNT]
unsigned char
Definition: typeof.h:29
GLuint shader
Definition: glext.h:6030
#define MAX_FRAGMENT_SAMPLERS
unsigned short WORD
Definition: ntddk_ex.h:93
static BOOL ffp_clip_emul(const struct wined3d_context *context)
static int state
Definition: maze.c:121
static BOOL use_ps(const struct wined3d_state *state)
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: shader.c:3520
const struct fragment_pipeline arbfp_fragment_pipeline
struct wined3d_d3d_limits limits
const struct fragment_pipeline * fragment_pipe
#define WINED3D_MAX_CONSTS_B
#define memset(x, y, z)
Definition: compat.h:39

Referenced by shader_arb_select().

◆ find_arb_vshader()

static struct arb_vs_compiled_shader* find_arb_vshader ( struct wined3d_shader shader,
const struct wined3d_gl_info gl_info,
DWORD  use_map,
const struct arb_vs_compile_args args,
const struct wined3d_shader_signature ps_input_sig 
)
static

Definition at line 4331 of file arb_program_shader.c.

4334 {
4335  UINT i;
4336  DWORD new_size;
4337  struct arb_vs_compiled_shader *new_array;
4339  struct arb_vshader_private *shader_data;
4340  GLuint ret;
4341 
4342  if (!shader->backend_data)
4343  {
4344  const struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
4345 
4346  shader->backend_data = heap_alloc_zero(sizeof(*shader_data));
4347  shader_data = shader->backend_data;
4348 
4349  if ((gl_info->quirks & WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT)
4350  && reg_maps->min_rel_offset <= reg_maps->max_rel_offset)
4351  {
4352  if (reg_maps->max_rel_offset - reg_maps->min_rel_offset > 127)
4353  {
4354  FIXME("The difference between the minimum and maximum relative offset is > 127.\n");
4355  FIXME("Which this OpenGL implementation does not support. Try using GLSL.\n");
4356  FIXME("Min: %u, Max: %u.\n", reg_maps->min_rel_offset, reg_maps->max_rel_offset);
4357  }
4358  else if (reg_maps->max_rel_offset - reg_maps->min_rel_offset > 63)
4359  shader_data->rel_offset = reg_maps->min_rel_offset + 63;
4360  else if (reg_maps->max_rel_offset > 63)
4361  shader_data->rel_offset = reg_maps->min_rel_offset;
4362  }
4363  }
4364  shader_data = shader->backend_data;
4365 
4366  /* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
4367  * so a linear search is more performant than a hashmap or a binary search
4368  * (cache coherency etc)
4369  */
4370  for(i = 0; i < shader_data->num_gl_shaders; i++) {
4371  if (vs_args_equal(&shader_data->gl_shaders[i].args, args,
4372  use_map, gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]))
4373  {
4374  return &shader_data->gl_shaders[i];
4375  }
4376  }
4377 
4378  TRACE("No matching GL shader found, compiling a new shader\n");
4379 
4380  if(shader_data->shader_array_size == shader_data->num_gl_shaders) {
4381  if (shader_data->num_gl_shaders)
4382  {
4383  new_size = shader_data->shader_array_size + max(1, shader_data->shader_array_size / 2);
4384  new_array = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, shader_data->gl_shaders,
4385  new_size * sizeof(*shader_data->gl_shaders));
4386  }
4387  else
4388  {
4389  new_array = heap_alloc_zero(sizeof(*shader_data->gl_shaders));
4390  new_size = 1;
4391  }
4392 
4393  if(!new_array) {
4394  ERR("Out of memory\n");
4395  return 0;
4396  }
4397  shader_data->gl_shaders = new_array;
4398  shader_data->shader_array_size = new_size;
4399  }
4400 
4401  shader_data->gl_shaders[shader_data->num_gl_shaders].args = *args;
4402 
4403  if (!string_buffer_init(&buffer))
4404  {
4405  ERR("Failed to initialize shader buffer.\n");
4406  return 0;
4407  }
4408 
4410  &shader_data->gl_shaders[shader_data->num_gl_shaders],
4411  ps_input_sig);
4413  shader_data->gl_shaders[shader_data->num_gl_shaders].prgId = ret;
4414 
4415  return &shader_data->gl_shaders[shader_data->num_gl_shaders++];
4416 }
#define WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT
#define max(a, b)
Definition: svc.c:63
static BOOL vs_args_equal(const struct arb_vs_compile_args *stored, const struct arb_vs_compile_args *new, const DWORD use_map, BOOL skip_int)
BOOL string_buffer_init(struct wined3d_string_buffer *buffer)
Definition: shader.c:437
struct arb_vs_compiled_shader * gl_shaders
GLuint buffer
Definition: glext.h:5915
Definition: match.c:390
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 FIXME(fmt,...)
Definition: debug.h:110
BOOL supported[WINED3D_GL_EXT_COUNT]
void string_buffer_free(struct wined3d_string_buffer *buffer)
Definition: shader.c:450
static GLuint shader_arb_generate_vshader(const struct wined3d_shader *shader, const struct wined3d_gl_info *gl_info, struct wined3d_string_buffer *buffer, const struct arb_vs_compile_args *args, struct arb_vs_compiled_shader *compiled, const struct wined3d_shader_signature *ps_input_sig)
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define ERR(fmt,...)
Definition: debug.h:109
unsigned int GLuint
Definition: gl.h:159
#define HeapReAlloc
Definition: compat.h:393
unsigned int UINT
Definition: ndis.h:50
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define args
Definition: format.c:66

Referenced by shader_arb_select().

◆ find_input_signature()

static DWORD find_input_signature ( struct shader_arb_priv priv,
const struct wined3d_shader_signature sig 
)
static

Definition at line 3886 of file arb_program_shader.c.

3887 {
3888  struct wine_rb_entry *entry = wine_rb_get(&priv->signature_tree, sig);
3889  struct ps_signature *found_sig;
3890 
3891  if (entry)
3892  {
3893  found_sig = WINE_RB_ENTRY_VALUE(entry, struct ps_signature, entry);
3894  TRACE("Found existing signature %u\n", found_sig->idx);
3895  return found_sig->idx;
3896  }
3897  found_sig = heap_alloc_zero(sizeof(*found_sig));
3898  clone_sig(&found_sig->sig, sig);
3899  found_sig->idx = priv->ps_sig_number++;
3900  TRACE("New signature stored and assigned number %u\n", found_sig->idx);
3901  if(wine_rb_put(&priv->signature_tree, sig, &found_sig->entry) == -1)
3902  {
3903  ERR("Failed to insert program entry.\n");
3904  }
3905  return found_sig->idx;
3906 }
struct wine_rb_tree signature_tree
static void clone_sig(struct wined3d_shader_signature *new, const struct wined3d_shader_signature *sig)
struct wined3d_shader_signature sig
#define TRACE(s)
Definition: solgame.cpp:4
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
uint32_t entry
Definition: isohybrid.c:63
#define ERR(fmt,...)
Definition: debug.h:109
Definition: rbtree.h:35
static int wine_rb_put(struct wine_rb_tree *tree, const void *key, struct wine_rb_entry *entry)
Definition: rbtree.h:215
struct wine_rb_entry entry
static struct wine_rb_entry * wine_rb_get(const struct wine_rb_tree *tree, const void *key)
Definition: rbtree.h:203

Referenced by find_arb_pshader().

◆ find_last_loop()

static const struct control_frame* find_last_loop ( const struct shader_arb_ctx_priv priv)
static

Definition at line 2963 of file arb_program_shader.c.

2964 {
2965  struct control_frame *control_frame;
2966 
2968  {
2969  if(control_frame->type == LOOP || control_frame->type == REP) return control_frame;
2970  }
2971  ERR("Could not find loop for break\n");
2972  return NULL;
2973 }
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define REP
Definition: patmatch.h:52
smooth NULL
Definition: ftsmooth.c:416
enum control_frame::@251 type
uint32_t entry
Definition: isohybrid.c:63
#define ERR(fmt,...)
Definition: debug.h:109

Referenced by shader_hw_break(), and shader_hw_breakc().

◆ find_loop_control_values()

static const DWORD* find_loop_control_values ( const struct wined3d_shader shader,
DWORD  idx 
)
static

Definition at line 3391 of file arb_program_shader.c.

3392 {
3393  const struct wined3d_shader_lconst *constant;
3394 
3396  {
3397  if (constant->idx == idx)
3398  {
3399  return constant->value;
3400  }
3401  }
3402  return NULL;
3403 }
union constant::@229 value[4]
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
GLuint shader
Definition: glext.h:6030
uint32_t entry
Definition: isohybrid.c:63

Referenced by shader_arb_generate_pshader(), and shader_arb_generate_vshader().

◆ fragment_prog_arbfp()

static void fragment_prog_arbfp ( struct wined3d_context context,
const struct wined3d_state state,
DWORD  state_id 
)
static

Definition at line 6546 of file arb_program_shader.c.

6547 {
6548  const struct wined3d_gl_info *gl_info = context->gl_info;
6549  const struct wined3d_device *device = context->device;
6550  struct shader_arb_priv *priv = device->fragment_priv;
6551  BOOL use_pshader = use_ps(state);
6552  struct ffp_frag_settings settings;
6553  const struct arbfp_ffp_desc *desc;
6554  unsigned int i;
6555 
6556  TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id);
6557 
6559  {
6560  if (!use_pshader && device->shader_backend == &arb_program_shader_backend && context->last_was_pshader)
6561  {
6562  /* Reload fixed function constants since they collide with the
6563  * pixel shader constants. */
6564  for (i = 0; i < MAX_TEXTURES; ++i)
6565  {
6568  }
6572  }
6573  else if (use_pshader)
6574  {
6575  context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_PIXEL;
6576  }
6577  return;
6578  }
6579 
6580  if (!use_pshader)
6581  {
6582  /* Find or create a shader implementing the fixed function pipeline
6583  * settings, then activate it. */
6586  if (!desc)
6587  {
6588  struct arbfp_ffp_desc *new_desc;
6589 
6590  if (!(new_desc = heap_alloc(sizeof(*new_desc))))
6591  {
6592  ERR("Out of memory\n");
6593  return;
6594  }
6595 
6596  new_desc->parent.settings = settings;
6597  new_desc->shader = gen_arbfp_ffp_shader(&settings, gl_info);
6598  add_ffp_frag_shader(&priv->fragment_shaders, &new_desc->parent);
6599  TRACE("Allocated fixed function replacement shader descriptor %p\n", new_desc);
6600  desc = new_desc;
6601  }
6602 
6603  /* Now activate the replacement program. GL_FRAGMENT_PROGRAM_ARB is already active (however, note the
6604  * comment above the shader_select call below). If e.g. GLSL is active, the shader_select call will
6605  * deactivate it.
6606  */
6607  GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, desc->shader));
6608  checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, desc->shader)");
6609  priv->current_fprogram_id = desc->shader;
6610 
6611  if (device->shader_backend == &arb_program_shader_backend && context->last_was_pshader)
6612  {
6613  /* Reload fixed function constants since they collide with the
6614  * pixel shader constants. */
6615  for (i = 0; i < MAX_TEXTURES; ++i)
6616  {
6619  }
6623  }
6624  context->last_was_pshader = FALSE;
6625  }
6626  else if (!context->last_was_pshader)
6627  {
6628  if (device->shader_backend == &arb_program_shader_backend)
6629  context->constant_update_mask |= WINED3D_SHADER_CONST_PS_F;
6630  context->last_was_pshader = TRUE;
6631  }
6632 
6633  context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_PIXEL;
6634 }
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 STATE_TEXTURESTAGE(stage, num)
struct mke2fs_defaults settings[]
#define MAX_TEXTURES
#define TRUE
Definition: types.h:120
struct ffp_frag_desc parent
Definition: http.c:6587
static void set_bumpmat_arbfp(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
static BOOL isStateDirty(const struct wined3d_context *context, DWORD state)
#define STATE_COLOR_KEY
static void state_texfactor_arbfp(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
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
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *desc)
Definition: utils.c:6021
static void state_tss_constant_arbfp(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
struct wine_rb_tree fragment_shaders
#define GL_EXTCALL(f)
#define TRACE(s)
Definition: solgame.cpp:4
const struct ffp_frag_desc * find_ffp_frag_shader(const struct wine_rb_tree *fragment_shaders, const struct ffp_frag_settings *settings)
Definition: utils.c:6014
static void state_arb_specularenable(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
static int state
Definition: maze.c:121
static BOOL use_ps(const struct wined3d_state *state)
#define STATE_RENDER(a)
#define ERR(fmt,...)
Definition: debug.h:109
#define WINED3D_SHADER_CONST_PS_F
#define checkGLcall(A)
static void color_key_arbfp(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
static GLuint gen_arbfp_ffp_shader(const struct ffp_frag_settings *settings, const struct wined3d_gl_info *gl_info)
void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d_state *state, struct ffp_frag_settings *settings, BOOL ignore_textype)
Definition: utils.c:5693
const struct wined3d_shader_backend_ops arb_program_shader_backend
#define GL_FRAGMENT_PROGRAM_ARB
Definition: glext.h:1466

Referenced by state_arbfp_fog(), and textransform().

◆ free_recorded_instruction()

static void free_recorded_instruction ( struct list list)
static

Definition at line 5386 of file arb_program_shader.c.

5387 {
5388  struct recorded_instruction *rec_ins, *entry2;
5389  unsigned int i;
5390 
5391  LIST_FOR_EACH_ENTRY_SAFE(rec_ins, entry2, list, struct recorded_instruction, entry)
5392  {
5393  list_remove(&rec_ins->entry);
5394  if (rec_ins->ins.dst)
5395  {
5396  heap_free((void *)rec_ins->ins.dst->reg.idx[0].rel_addr);
5397  heap_free((void *)rec_ins->ins.dst);
5398  }
5399  if (rec_ins->ins.src)
5400  {
5401  for (i = 0; i < rec_ins->ins.src_count; ++i)
5402  {
5403  heap_free((void *)rec_ins->ins.src[i].reg.idx[0].rel_addr);
5404  }
5405  heap_free((void *)rec_ins->ins.src);
5406  }
5407  heap_free(rec_ins);
5408  }
5409 }
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
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
struct wined3d_shader_instruction ins
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by shader_arb_handle_instruction().

◆ gen_arbfp_ffp_shader()

static GLuint gen_arbfp_ffp_shader ( const struct ffp_frag_settings settings,
const struct wined3d_gl_info gl_info 
)
static

Definition at line 6225 of file arb_program_shader.c.

6226 {
6227  BYTE tex_read = 0, bump_used = 0, luminance_used = 0, constant_used = 0;
6228  BOOL tempreg_used = FALSE, tfactor_used = FALSE;
6229  unsigned int stage, lowest_disabled_stage;
6231  struct color_fixup_masks masks;
6232  BOOL custom_linear_fog = FALSE;
6233  const char *textype, *instr;
6234  DWORD arg0, arg1, arg2;
6235  char colorcor_dst[8];
6236  BOOL op_equal;
6237  GLuint ret;
6238 
6239  if (!string_buffer_init(&buffer))
6240  {
6241  ERR("Failed to initialize shader buffer.\n");
6242  return 0;
6243  }
6244 
6245  shader_addline(&buffer, "!!ARBfp1.0\n");
6246 
6247  if (settings->color_key_enabled)
6248  {
6249  shader_addline(&buffer, "PARAM color_key_low = program.env[%u];\n", ARB_FFP_CONST_COLOR_KEY_LOW);
6250  shader_addline(&buffer, "PARAM color_key_high = program.env[%u];\n", ARB_FFP_CONST_COLOR_KEY_HIGH);
6251  tex_read |= 1;
6252  }
6253 
6254  /* Find out which textures are read */
6255  for (stage = 0; stage < MAX_TEXTURES; ++stage)
6256  {
6257  if (settings->op[stage].cop == WINED3D_TOP_DISABLE)
6258  break;
6259 
6260  arg0 = settings->op[stage].carg0 & WINED3DTA_SELECTMASK;
6261  arg1 = settings->op[stage].carg1 & WINED3DTA_SELECTMASK;
6262  arg2 = settings->op[stage].carg2 & WINED3DTA_SELECTMASK;
6263 
6265  tex_read |= 1u << stage;
6266  if (settings->op[stage].tmp_dst)
6267  tempreg_used = TRUE;
6268  if (arg0 == WINED3DTA_TEMP || arg1 == WINED3DTA_TEMP || arg2 == WINED3DTA_TEMP)
6269  tempreg_used = TRUE;
6271  tfactor_used = TRUE;
6273  constant_used |= 1u << stage;
6274 
6275  switch (settings->op[stage].cop)
6276  {
6278  luminance_used |= 1u << stage;
6279  /* fall through */
6281  bump_used |= 1u << stage;
6282  /* fall through */
6285  tex_read |= 1u << stage;
6286  break;
6287 
6289  tfactor_used = TRUE;
6290  break;
6291 
6292  default:
6293  break;
6294  }
6295 
6296  if (settings->op[stage].aop == WINED3D_TOP_DISABLE)
6297  continue;
6298 
6299  arg0 = settings->op[stage].aarg0 & WINED3DTA_SELECTMASK;
6300  arg1 = settings->op[stage].aarg1 & WINED3DTA_SELECTMASK;
6301  arg2 = settings->op[stage].aarg2 & WINED3DTA_SELECTMASK;
6302 
6304  tex_read |= 1u << stage;
6305  if (arg0 == WINED3DTA_TEMP || arg1 == WINED3DTA_TEMP || arg2 == WINED3DTA_TEMP)
6306  tempreg_used = TRUE;
6308  tfactor_used = TRUE;
6310  constant_used |= 1u << stage;
6311  }
6312  lowest_disabled_stage = stage;
6313 
6314  switch (settings->fog)
6315  {
6316  case WINED3D_FFP_PS_FOG_OFF: break;
6318  if (gl_info->quirks & WINED3D_QUIRK_BROKEN_ARB_FOG)
6319  {
6320  custom_linear_fog = TRUE;
6321  break;
6322  }
6323  shader_addline(&buffer, "OPTION ARB_fog_linear;\n");
6324  break;
6325 
6326  case WINED3D_FFP_PS_FOG_EXP: shader_addline(&buffer, "OPTION ARB_fog_exp;\n"); break;
6327  case WINED3D_FFP_PS_FOG_EXP2: shader_addline(&buffer, "OPTION ARB_fog_exp2;\n"); break;
6328  default: FIXME("Unexpected fog setting %d\n", settings->fog);
6329  }
6330 
6331  shader_addline(&buffer, "PARAM const = {1, 2, 4, 0.5};\n");
6332  shader_addline(&buffer, "TEMP TMP;\n");
6333  shader_addline(&buffer, "TEMP ret;\n");
6334  if (tempreg_used || settings->sRGB_write) shader_addline(&buffer, "TEMP tempreg;\n");
6335  shader_addline(&buffer, "TEMP arg0;\n");
6336  shader_addline(&buffer, "TEMP arg1;\n");
6337  shader_addline(&buffer, "TEMP arg2;\n");
6338  for (stage = 0; stage < MAX_TEXTURES; ++stage)
6339  {
6340  if (constant_used & (1u << stage))
6341  shader_addline(&buffer, "PARAM const%u = program.env[%u];\n", stage, ARB_FFP_CONST_CONSTANT(stage));
6342 
6343  if (!(tex_read & (1u << stage)))
6344  continue;
6345 
6346  shader_addline(&buffer, "TEMP tex%u;\n", stage);
6347 
6348  if (!(bump_used & (1u << stage)))
6349  continue;
6350  shader_addline(&buffer, "PARAM bumpmat%u = program.env[%u];\n", stage, ARB_FFP_CONST_BUMPMAT(stage));
6351 
6352  if (!(luminance_used & (1u << stage)))
6353  continue;
6354  shader_addline(&buffer, "PARAM luminance%u = program.env[%u];\n", stage, ARB_FFP_CONST_LUMINANCE(stage));
6355  }
6356  if (tfactor_used)
6357  shader_addline(&buffer, "PARAM tfactor = program.env[%u];\n", ARB_FFP_CONST_TFACTOR);
6358  shader_addline(&buffer, "PARAM specular_enable = program.env[%u];\n", ARB_FFP_CONST_SPECULAR_ENABLE);
6359 
6360  if (settings->sRGB_write)
6361  {
6362  shader_addline(&buffer, "PARAM srgb_consts0 = ");
6364  shader_addline(&buffer, ";\n");
6365  shader_addline(&buffer, "PARAM srgb_consts1 = ");
6367  shader_addline(&buffer, ";\n");
6368  }
6369 
6370  if (lowest_disabled_stage < 7 && settings->emul_clipplanes)
6371  shader_addline(&buffer, "KIL fragment.texcoord[7];\n");
6372 
6373  if (tempreg_used || settings->sRGB_write)
6374  shader_addline(&buffer, "MOV tempreg, 0.0;\n");
6375 
6376  /* Generate texture sampling instructions */
6377  for (stage = 0; stage < MAX_TEXTURES && settings->op[stage].cop != WINED3D_TOP_DISABLE; ++stage)
6378  {
6379  if (!(tex_read & (1u << stage)))
6380  continue;
6381 
6382  textype = arbfp_texture_target(settings->op[stage].tex_type);
6383 
6384  if (settings->op[stage].projected == WINED3D_PROJECTION_NONE)
6385  {
6386  instr = "TEX";
6387  }
6388  else if (settings->op[stage].projected == WINED3D_PROJECTION_COUNT4
6389  || settings->op[stage].projected == WINED3D_PROJECTION_COUNT3)
6390  {
6391  instr = "TXP";
6392  }
6393  else
6394  {
6395  FIXME("Unexpected projection mode %d\n", settings->op[stage].projected);
6396  instr = "TXP";
6397  }
6398 
6399  if (stage > 0
6400  && (settings->op[stage - 1].cop == WINED3D_TOP_BUMPENVMAP
6401  || settings->op[stage - 1].cop == WINED3D_TOP_BUMPENVMAP_LUMINANCE))
6402  {
6403  shader_addline(&buffer, "SWZ arg1, bumpmat%u, x, z, 0, 0;\n", stage - 1);
6404  shader_addline(&buffer, "DP3 ret.x, arg1, tex%u;\n", stage - 1);
6405  shader_addline(&buffer, "SWZ arg1, bumpmat%u, y, w, 0, 0;\n", stage - 1);
6406  shader_addline(&buffer, "DP3 ret.y, arg1, tex%u;\n", stage - 1);
6407 
6408  /* With projective textures, texbem only divides the static
6409  * texture coordinate, not the displacement, so multiply the
6410  * displacement with the dividing parameter before passing it to
6411  * TXP. */
6412  if (settings->op[stage].projected != WINED3D_PROJECTION_NONE)
6413  {
6414  if (settings->op[stage].projected == WINED3D_PROJECTION_COUNT4)
6415  {
6416  shader_addline(&buffer, "MOV ret.w, fragment.texcoord[%u].w;\n", stage);
6417  shader_addline(&buffer, "MUL ret.xyz, ret, fragment.texcoord[%u].w, fragment.texcoord[%u];\n",
6418  stage, stage);
6419  }
6420  else
6421  {
6422  shader_addline(&buffer, "MOV ret.w, fragment.texcoord[%u].z;\n", stage);
6423  shader_addline(&buffer, "MAD ret.xyz, ret, fragment.texcoord[%u].z, fragment.texcoord[%u];\n",
6424  stage, stage);
6425  }
6426  }
6427  else
6428  {
6429  shader_addline(&buffer, "ADD ret, ret, fragment.texcoord[%u];\n", stage);
6430  }
6431 
6432  shader_addline(&buffer, "%s tex%u, ret, texture[%u], %s;\n",
6433  instr, stage, stage, textype);
6434  if (settings->op[stage - 1].cop == WINED3D_TOP_BUMPENVMAP_LUMINANCE)
6435  {
6436  shader_addline(&buffer, "MAD_SAT ret.x, tex%u.z, luminance%u.x, luminance%u.y;\n",
6437  stage - 1, stage - 1, stage - 1);
6438  shader_addline(&buffer, "MUL tex%u, tex%u, ret.x;\n", stage, stage);
6439  }
6440  }
6441  else if (settings->op[stage].projected == WINED3D_PROJECTION_COUNT3)
6442  {
6443  shader_addline(&buffer, "MOV ret, fragment.texcoord[%u];\n", stage);
6444  shader_addline(&buffer, "MOV ret.w, ret.z;\n");
6445  shader_addline(&buffer, "%s tex%u, ret, texture[%u], %s;\n",
6446  instr, stage, stage, textype);
6447  }
6448  else
6449  {
6450  shader_addline(&buffer, "%s tex%u, fragment.texcoord[%u], texture[%u], %s;\n",
6451  instr, stage, stage, stage, textype);
6452  }
6453 
6454  sprintf(colorcor_dst, "tex%u", stage);
6455  masks = calc_color_correction(settings->op[stage].color_fixup, WINED3DSP_WRITEMASK_ALL);
6456  gen_color_correction(&buffer, colorcor_dst, colorcor_dst, "const.x", "const.y",
6457  settings->op[stage].color_fixup, masks);
6458  }
6459 
6460  if (settings->color_key_enabled)
6461  {
6462  shader_addline(&buffer, "SLT TMP, tex0, color_key_low;\n"); /* below low key */
6463  shader_addline(&buffer, "SGE ret, tex0, color_key_high;\n"); /* above high key */
6464  shader_addline(&buffer, "ADD TMP, TMP, ret;\n"); /* or */
6465  shader_addline(&buffer, "DP4 TMP.b, TMP, TMP;\n"); /* on any channel */
6466  shader_addline(&buffer, "SGE TMP, -TMP.b, 0.0;\n"); /* logical not */
6467  shader_addline(&buffer, "KIL -TMP;\n"); /* discard if true */
6468  }
6469 
6470  shader_addline(&buffer, "MOV ret, fragment.color.primary;\n");
6471 
6472  /* Generate the main shader */
6473  for (stage = 0; stage < MAX_TEXTURES; ++stage)
6474  {
6475  if (settings->op[stage].cop == WINED3D_TOP_DISABLE)
6476  break;
6477 
6478  if (settings->op[stage].cop == WINED3D_TOP_SELECT_ARG1
6479  && settings->op[stage].aop == WINED3D_TOP_SELECT_ARG1)
6480  op_equal = settings->op[stage].carg1 == settings->op[stage].aarg1;
6481  else if (settings->op[stage].cop == WINED3D_TOP_SELECT_ARG1
6482  && settings->op[stage].aop == WINED3D_TOP_SELECT_ARG2)
6483  op_equal = settings->op[stage].carg1 == settings->op[stage].aarg2;
6484  else if (settings->op[stage].cop == WINED3D_TOP_SELECT_ARG2
6485  && settings->op[stage].aop == WINED3D_TOP_SELECT_ARG1)
6486  op_equal = settings->op[stage].carg2 == settings->op[stage].aarg1;
6487  else if (settings->op[stage].cop == WINED3D_TOP_SELECT_ARG2
6488  && settings->op[stage].aop == WINED3D_TOP_SELECT_ARG2)
6489  op_equal = settings->op[stage].carg2 == settings->op[stage].aarg2;
6490  else
6491  op_equal = settings->op[stage].aop == settings->op[stage].cop
6492  && settings->op[stage].carg0 == settings->op[stage].aarg0
6493  && settings->op[stage].carg1 == settings->op[stage].aarg1
6494  && settings->op[stage].carg2 == settings->op[stage].aarg2;
6495 
6496  if (settings->op[stage].aop == WINED3D_TOP_DISABLE)
6497  {
6498  gen_ffp_instr(&buffer, stage, TRUE, FALSE, settings->op[stage].tmp_dst,
6499  settings->op[stage].cop, settings->op[stage].carg0,
6500  settings->op[stage].carg1, settings->op[stage].carg2);
6501  }
6502  else if (op_equal)
6503  {
6504  gen_ffp_instr(&buffer, stage, TRUE, TRUE, settings->op[stage].tmp_dst,
6505  settings->op[stage].cop, settings->op[stage].carg0,
6506  settings->op[stage].carg1, settings->op[stage].carg2);
6507  }
6508  else if (settings->op[stage].cop != WINED3D_TOP_BUMPENVMAP
6509  && settings->op[stage].cop != WINED3D_TOP_BUMPENVMAP_LUMINANCE)
6510  {
6511  gen_ffp_instr(&buffer, stage, TRUE, FALSE, settings->op[stage].tmp_dst,
6512  settings->op[stage].cop, settings->op[stage].carg0,
6513  settings->op[stage].carg1, settings->op[stage].carg2);
6514  gen_ffp_instr(&buffer, stage, FALSE, TRUE, settings->op[stage].tmp_dst,
6515  settings->op[stage].aop, settings->op[stage].aarg0,
6516  settings->op[stage].aarg1, settings->op[stage].aarg2);
6517  }
6518  }
6519 
6520  if (settings->sRGB_write || custom_linear_fog)
6521  {
6522  shader_addline(&buffer, "MAD ret, fragment.color.secondary, specular_enable, ret;\n");
6523  if (settings->sRGB_write)
6524  arbfp_add_sRGB_correction(&buffer, "ret", "arg0", "arg1", "arg2", "tempreg", FALSE);
6525  if (custom_linear_fog)
6526  arbfp_add_linear_fog(&buffer, "ret", "arg0");
6527  shader_addline(&buffer, "MOV result.color, ret;\n");
6528  }
6529  else
6530  {
6531  shader_addline(&buffer, "MAD result.color, fragment.color.secondary, specular_enable, ret;\n");
6532  }
6533 
6534  /* Footer */
6535  shader_addline(&buffer, "END\n");
6536 
6537  /* Generate the shader */
6538  GL_EXTCALL(glGenProgramsARB(1, &ret));
6539  GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, ret));
6541 
6543  return ret;
6544 }
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
struct mke2fs_defaults settings[]
#define MAX_TEXTURES
#define TRUE
Definition: types.h:120
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
#define ARB_FFP_CONST_COLOR_KEY_LOW
struct x86_inst instr
#define WINED3DTA_CONSTANT
Definition: wined3d.h:882
#define ARB_FFP_CONST_TFACTOR
BOOL string_buffer_init(struct wined3d_string_buffer *buffer)
Definition: shader.c:437
GLuint buffer
Definition: glext.h:5915
static const char * arbfp_texture_target(enum wined3d_gl_resource_type type)
static void gen_ffp_instr(struct wined3d_string_buffer *buffer, unsigned int stage, BOOL color, BOOL alpha, BOOL tmp_dst, DWORD op, DWORD dw_arg0, DWORD dw_arg1, DWORD dw_arg2)
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
Definition: glext.h:9514
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLuint GLuint GLuint arg1
Definition: glext.h:9513
#define FIXME(fmt,...)
Definition: debug.h:110
void string_buffer_free(struct wined3d_string_buffer *buffer)
Definition: shader.c:450
#define WINED3DTA_TEXTURE
Definition: wined3d.h:878
#define ARB_FFP_CONST_CONSTANT(i)
const float wined3d_srgb_const0[]
Definition: shader.c:36
#define WINED3DTA_SELECTMASK
Definition: wined3d.h:875
#define GL_EXTCALL(f)
static void shader_arb_append_imm_vec4(struct wined3d_string_buffer *buffer, const float *values)
const float wined3d_srgb_const1[]
Definition: shader.c:38
static BOOL shader_arb_compile(const struct wined3d_gl_info *gl_info, GLenum target, const char *src)
#define WINED3D_QUIRK_BROKEN_ARB_FOG
#define ARB_FFP_CONST_SPECULAR_ENABLE
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WINED3DTA_TFACTOR
Definition: wined3d.h:879
#define ARB_FFP_CONST_LUMINANCE(i)
static struct color_fixup_masks calc_color_correction(struct color_fixup_desc fixup, DWORD dst_mask)
int ret
static void gen_color_correction(struct wined3d_string_buffer *buffer, const char *dst, const char *src, const char *one, const char *two, struct color_fixup_desc fixup, struct color_fixup_masks masks)
unsigned char BYTE
Definition: mem.h:68
#define WINED3DSP_WRITEMASK_ALL
static void arbfp_add_sRGB_correction(struct wined3d_string_buffer *buffer, const char *fragcolor, const char *tmp1, const char *tmp2, const char *tmp3, const char *tmp4, BOOL condcode)
#define ERR(fmt,...)
Definition: debug.h:109
static void arbfp_add_linear_fog(struct wined3d_string_buffer *buffer, const char *fragcolor, const char *tmp)
unsigned int GLuint
Definition: gl.h:159
#define ARB_FFP_CONST_BUMPMAT(i)
#define ARB_FFP_CONST_COLOR_KEY_HIGH
#define WINED3DTA_TEMP
Definition: wined3d.h:881
#define GL_FRAGMENT_PROGRAM_ARB
Definition: glext.h:1466
static const BYTE masks[8]
Definition: dib.c:2760

Referenced by fragment_prog_arbfp().

◆ gen_color_correction()

static void gen_color_correction ( struct wined3d_string_buffer buffer,
const char dst,
const char src,
const char one,
const char two,
struct color_fixup_desc  fixup,
struct color_fixup_masks  masks 
)
static

Definition at line 1324 of file arb_program_shader.c.

1327 {
1328  const char *sign_fixup_src = dst;
1329 
1330  if (masks.source)
1331  {
1332  if (masks.sign)
1333  sign_fixup_src = "TA";
1334 
1335  shader_addline(buffer, "SWZ %s, %s, %s, %s, %s, %s;\n", sign_fixup_src, src,
1338  }
1339  else if (masks.sign)
1340  {
1341  sign_fixup_src = src;
1342  }
1343 
1344  if (masks.sign)
1345  {
1346  char reg_mask[6];
1347  char *ptr = reg_mask;
1348 
1349  if (masks.sign != WINED3DSP_WRITEMASK_ALL)
1350  {
1351  *ptr++ = '.';
1352  if (masks.sign & WINED3DSP_WRITEMASK_0)
1353  *ptr++ = 'x';
1354  if (masks.sign & WINED3DSP_WRITEMASK_1)
1355  *ptr++ = 'y';
1356  if (masks.sign & WINED3DSP_WRITEMASK_2)
1357  *ptr++ = 'z';
1358  if (masks.sign & WINED3DSP_WRITEMASK_3)
1359  *ptr++ = 'w';
1360  }
1361  *ptr = '\0';
1362 
1363  shader_addline(buffer, "MAD %s%s, %s, %s, -%s;\n", dst, reg_mask, sign_fixup_src, two, one);
1364  }
1365 }
unsigned short x_source
#define WINED3DSP_WRITEMASK_0
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:487
unsigned short w_source
GLuint buffer
Definition: glext.h:5915
static double one
Definition: j0_y0.c:80
static double two
Definition: jn_yn.c:52
static PVOID ptr
Definition: dispmode.c:27
unsigned short z_source
#define WINED3DSP_WRITEMASK_1
#define WINED3DSP_WRITEMASK_2
GLenum src
Definition: glext.h:6340
#define WINED3DSP_WRITEMASK_ALL
GLenum GLenum dst
Definition: glext.h:6340
#define WINED3DSP_WRITEMASK_3
unsigned short y_source
static const char * shader_arb_get_fixup_swizzle(enum fixup_channel_source channel_source)
static const BYTE masks[8]
Definition: dib.c:2760

Referenced by gen_arbfp_ffp_shader(), and shader_hw_sample().

◆ gen_ffp_instr()

static void gen_ffp_instr ( struct wined3d_string_buffer buffer,
unsigned int  stage,
BOOL  color,
BOOL  alpha,
BOOL  tmp_dst,
DWORD  op,
DWORD  dw_arg0,
DWORD  dw_arg1,
DWORD  dw_arg2 
)
static

Definition at line 6074 of file arb_program_shader.c.

6076 {
6077  const char *dstmask, *dstreg, *arg0, *arg1, *arg2;
6078  unsigned int mul = 1;
6079 
6080  if (color && alpha)
6081  dstmask = "";
6082  else if (color)
6083  dstmask = ".xyz";
6084  else
6085  dstmask = ".w";
6086 
6087  dstreg = tmp_dst ? "tempreg" : "ret";
6088 
6089  arg0 = get_argreg(buffer, 0, stage, dw_arg0);
6090  arg1 = get_argreg(buffer, 1, stage, dw_arg1);
6091  arg2 = get_argreg(buffer, 2, stage, dw_arg2);
6092 
6093  switch (op)
6094  {
6095  case WINED3D_TOP_DISABLE:
6096  break;
6097 
6099  arg1 = arg2;
6100  /* FALLTHROUGH */
6102  shader_addline(buffer, "MOV %s%s, %s;\n", dstreg, dstmask, arg1);
6103  break;
6104 
6106  mul = 2;
6107  /* FALLTHROUGH */
6109  mul *= 2;
6110  /* FALLTHROUGH */
6111  case WINED3D_TOP_MODULATE:
6112  shader_addline(buffer, "MUL %s%s, %s, %s;\n", dstreg, dstmask, arg1, arg2);
6113  break;
6114 
6116  mul = 2;
6117  /* FALLTHROUGH */
6119  shader_addline(buffer, "SUB arg2, %s, const.w;\n", arg2);
6120  arg2 = "arg2";
6121  /* FALLTHROUGH */
6122  case WINED3D_TOP_ADD:
6123  shader_addline(buffer, "ADD_SAT %s%s, %s, %s;\n", dstreg, dstmask, arg1, arg2);
6124  break;
6125 
6126  case WINED3D_TOP_SUBTRACT:
6127  shader_addline(buffer, "SUB_SAT %s%s, %s, %s;\n", dstreg, dstmask, arg1, arg2);
6128  break;
6129 
6131  shader_addline(buffer, "SUB arg1, const.x, %s;\n", arg1);
6132  shader_addline(buffer, "MAD_SAT %s%s, arg1, %s, %s;\n", dstreg, dstmask, arg2, arg1);
6133  break;
6134 
6136  arg0 = get_argreg(buffer, 0, stage, WINED3DTA_CURRENT);
6137  shader_addline(buffer, "LRP %s%s, %s.w, %s, %s;\n", dstreg, dstmask, arg0, arg1, arg2);
6138  break;
6140  arg0 = get_argreg(buffer, 0, stage, WINED3DTA_TFACTOR);
6141  shader_addline(buffer, "LRP %s%s, %s.w, %s, %s;\n", dstreg, dstmask, arg0, arg1, arg2);
6142  break;
6144  arg0 = get_argreg(buffer, 0, stage, WINED3DTA_TEXTURE);
6145  shader_addline(buffer, "LRP %s%s, %s.w, %s, %s;\n", dstreg, dstmask, arg0, arg1, arg2);
6146  break;
6148  arg0 = get_argreg(buffer, 0, stage, WINED3DTA_DIFFUSE);
6149  shader_addline(buffer, "LRP %s%s, %s.w, %s, %s;\n", dstreg, dstmask, arg0, arg1, arg2);
6150  break;
6151 
6153  arg0 = get_argreg(buffer, 0, stage, WINED3DTA_TEXTURE);
6154  shader_addline(buffer, "SUB arg0.w, const.x, %s.w;\n", arg0);
6155  shader_addline(buffer, "MAD_SAT %s%s, %s, arg0.w, %s;\n", dstreg, dstmask, arg2, arg1);
6156  break;
6157 
6158  /* D3DTOP_PREMODULATE ???? */
6159 
6161  shader_addline(buffer, "SUB arg0.w, const.x, %s;\n", arg1);
6162  shader_addline(buffer, "MAD_SAT %s%s, arg0.w, %s, %s;\n", dstreg, dstmask, arg2, arg1);
6163  break;
6165  shader_addline(buffer, "MAD_SA