ReactOS 0.4.15-dev-7906-g1b85a5f
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, DWORD 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 BOOL gen_planar_yuv_read (struct wined3d_string_buffer *buffer, const struct arbfp_blit_type *type, char *luminance)
 
static BOOL gen_yv12_read (struct wined3d_string_buffer *buffer, const struct arbfp_blit_type *type, char *luminance)
 
static BOOL 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_surface *src_surface, DWORD src_location, const RECT *src_rect, struct wined3d_surface *dst_surface, 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 5694 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 5691 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 5690 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 5693 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 5695 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 5692 of file arb_program_shader.c.

◆ ARB_FFP_CONST_TFACTOR

#define ARB_FFP_CONST_TFACTOR   0

Definition at line 5689 of file arb_program_shader.c.

◆ ARBFP_BLIT_PARAM_COLOR_KEY_HIGH

#define ARBFP_BLIT_PARAM_COLOR_KEY_HIGH   2

Definition at line 6878 of file arb_program_shader.c.

◆ ARBFP_BLIT_PARAM_COLOR_KEY_LOW

#define ARBFP_BLIT_PARAM_COLOR_KEY_LOW   1

Definition at line 6877 of file arb_program_shader.c.

◆ ARBFP_BLIT_PARAM_SIZE

#define ARBFP_BLIT_PARAM_SIZE   0

Definition at line 6876 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.

69{
71 ARB_ONE,
72 ARB_TWO,
74 ARB_EPS,
75
77};
@ ARB_VS_REL_OFFSET
@ ARB_EPS
@ ARB_ONE
@ ARB_0001
@ ARB_ZERO
@ ARB_TWO

Function Documentation

◆ abs_modifier()

static DWORD abs_modifier ( DWORD  mod,
BOOL need_abs 
)
static

Definition at line 2511 of file arb_program_shader.c.

2512{
2513 *need_abs = FALSE;
2514
2515 switch(mod)
2516 {
2517 case WINED3DSPSM_NONE: return WINED3DSPSM_ABS;
2518 case WINED3DSPSM_NEG: return WINED3DSPSM_ABS;
2519 case WINED3DSPSM_BIAS: *need_abs = TRUE; return WINED3DSPSM_BIAS;
2520 case WINED3DSPSM_BIASNEG: *need_abs = TRUE; return WINED3DSPSM_BIASNEG;
2521 case WINED3DSPSM_SIGN: *need_abs = TRUE; return WINED3DSPSM_SIGN;
2522 case WINED3DSPSM_SIGNNEG: *need_abs = TRUE; return WINED3DSPSM_SIGNNEG;
2523 case WINED3DSPSM_COMP: *need_abs = TRUE; return WINED3DSPSM_COMP;
2524 case WINED3DSPSM_X2: *need_abs = TRUE; return WINED3DSPSM_X2;
2525 case WINED3DSPSM_X2NEG: *need_abs = TRUE; return WINED3DSPSM_X2NEG;
2526 case WINED3DSPSM_DZ: *need_abs = TRUE; return WINED3DSPSM_DZ;
2527 case WINED3DSPSM_DW: *need_abs = TRUE; return WINED3DSPSM_DW;
2528 case WINED3DSPSM_ABS: return WINED3DSPSM_ABS;
2530 }
2531 FIXME("Unknown modifier %u\n", mod);
2532 return mod;
2533}
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static int mod
Definition: i386-dis.c:1288
@ WINED3DSPSM_ABSNEG
@ WINED3DSPSM_X2NEG
@ WINED3DSPSM_BIAS
@ WINED3DSPSM_BIASNEG
@ WINED3DSPSM_COMP
@ WINED3DSPSM_ABS
@ WINED3DSPSM_SIGNNEG
@ WINED3DSPSM_DW
@ WINED3DSPSM_X2
@ WINED3DSPSM_SIGN
@ WINED3DSPSM_NONE
@ WINED3DSPSM_NEG
@ WINED3DSPSM_DZ

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 5953 of file arb_program_shader.c.

5954{
5955 const struct wined3d_gl_info *gl_info = context->gl_info;
5956 int glParm;
5957 float ref;
5958
5959 TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id);
5960
5961 if (state->render_states[WINED3D_RS_ALPHATESTENABLE])
5962 {
5963 gl_info->gl_ops.gl.p_glEnable(GL_ALPHA_TEST);
5964 checkGLcall("glEnable GL_ALPHA_TEST");
5965 }
5966 else
5967 {
5968 gl_info->gl_ops.gl.p_glDisable(GL_ALPHA_TEST);
5969 checkGLcall("glDisable GL_ALPHA_TEST");
5970 return;
5971 }
5972
5973 ref = ((float)state->render_states[WINED3D_RS_ALPHAREF]) / 255.0f;
5974 glParm = wined3d_gl_compare_func(state->render_states[WINED3D_RS_ALPHAFUNC]);
5975
5976 if (glParm)
5977 {
5978 gl_info->gl_ops.gl.p_glAlphaFunc(glParm, ref);
5979 checkGLcall("glAlphaFunc");
5980 }
5981}
static int state
Definition: maze.c:121
GLenum wined3d_gl_compare_func(enum wined3d_cmp_func f)
Definition: state.c:348
#define GL_ALPHA_TEST
Definition: gl.h:366
static float(__cdecl *square_half_float)(float x
#define TRACE(s)
Definition: solgame.cpp:4
Definition: http.c:7252
Definition: send.c:48
struct opengl_funcs gl_ops
@ WINED3D_RS_ALPHAREF
Definition: wined3d.h:283
@ WINED3D_RS_ALPHATESTENABLE
Definition: wined3d.h:277
@ WINED3D_RS_ALPHAFUNC
Definition: wined3d.h:284
#define checkGLcall(A)

◆ 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 ERR(fmt,...)
Definition: debug.h:110
const char * debug_shader_type(enum wined3d_shader_type type)
Definition: utils.c:4658
GLuint shader
Definition: glext.h:6030
Definition: pdh_main.c:94
@ WINED3D_SHADER_TYPE_PIXEL
@ WINED3D_SHADER_TYPE_VERTEX

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 3495 of file arb_program_shader.c.

3497{
3498 shader_addline(buffer, "SUB %s.x, state.fog.params.z, fragment.fogcoord.x;\n", tmp);
3499 shader_addline(buffer, "MUL_SAT %s.x, %s.x, state.fog.params.w;\n", tmp, tmp);
3500 shader_addline(buffer, "LRP %s.rgb, %s.x, %s, state.fog.color;\n", fragcolor, tmp, fragcolor);
3501}
int shader_addline(struct wined3d_string_buffer *buffer, const char *format,...)
Definition: shader.c:478
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 3354 of file arb_program_shader.c.

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

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 5718 of file arb_program_shader.c.

5719{
5720 struct shader_arb_priv *priv;
5721
5722 /* Share private data between the shader backend and the pipeline
5723 * replacement, if both are the arb implementation. This is needed to
5724 * figure out whether ARBfp should be disabled if no pixel shader is bound
5725 * or not. */
5726 if (shader_backend == &arb_program_shader_backend)
5727 priv = shader_priv;
5728 else if (!(priv = heap_alloc_zero(sizeof(*priv))))
5729 return NULL;
5730
5732 priv->use_arbfp_fixed_func = TRUE;
5733
5734 return priv;
5735}
const struct wined3d_shader_backend_ops arb_program_shader_backend
#define NULL
Definition: types.h:112
int wined3d_ffp_frag_program_key_compare(const void *key, const struct wine_rb_entry *entry)
Definition: utils.c:6230
static void wine_rb_init(struct wine_rb_tree *tree, wine_rb_compare_func_t compare)
Definition: rbtree.h:179
struct wine_rb_tree fragment_shaders

◆ arbfp_alloc_context_data()

static BOOL arbfp_alloc_context_data ( struct wined3d_context context)
static

Definition at line 6840 of file arb_program_shader.c.

6841{
6842 return TRUE;
6843}

◆ 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 7569 of file arb_program_shader.c.

7572{
7573 enum complex_fixup fixup;
7574 const struct wined3d_gl_info *gl_info = context->gl_info;
7575 struct wine_rb_entry *entry;
7576 struct arbfp_blit_type type;
7577 struct arbfp_blit_desc *desc;
7578 struct wined3d_color float_color_key[2];
7579 struct wined3d_vec4 size;
7580 unsigned int level;
7581 GLuint shader;
7582
7583 level = sub_resource_idx % texture->level_count;
7586 size.z = 1.0f;
7587 size.w = 1.0f;
7588
7589 if (is_complex_fixup(texture->resource.format->color_fixup))
7590 fixup = get_complex_fixup(texture->resource.format->color_fixup);
7591 else
7592 fixup = COMPLEX_FIXUP_NONE;
7593
7594 switch (texture->target)
7595 {
7596 case GL_TEXTURE_1D:
7598 break;
7599
7600 case GL_TEXTURE_2D:
7602 break;
7603
7604 case GL_TEXTURE_3D:
7606 break;
7607
7610 break;
7611
7614 break;
7615
7616 default:
7617 ERR("Unexpected GL texture type %#x.\n", texture->target);
7619 }
7620 type.fixup = fixup;
7621 type.use_color_key = !!color_key;
7622 type.padding = 0;
7623
7624 if ((entry = wine_rb_get(&blitter->shaders, &type)))
7625 {
7627 shader = desc->shader;
7628 }
7629 else
7630 {
7631 switch (fixup)
7632 {
7633 case COMPLEX_FIXUP_NONE:
7634 if (!is_identity_fixup(texture->resource.format->color_fixup))
7635 FIXME("Implement support for sign or swizzle fixups.\n");
7636 shader = arbfp_gen_plain_shader(gl_info, &type);
7637 break;
7638
7639 case COMPLEX_FIXUP_P8:
7640 shader = gen_p8_shader(gl_info, &type);
7641 break;
7642
7643 case COMPLEX_FIXUP_YUY2:
7644 case COMPLEX_FIXUP_UYVY:
7645 case COMPLEX_FIXUP_YV12:
7646 case COMPLEX_FIXUP_NV12:
7647 shader = gen_yuv_shader(gl_info, &type);
7648 break;
7649 }
7650
7651 if (!shader)
7652 {
7653 FIXME("Unsupported complex fixup %#x, not setting a shader\n", fixup);
7654 return E_NOTIMPL;
7655 }
7656
7657 if (!(desc = heap_alloc(sizeof(*desc))))
7658 goto err_out;
7659
7660 desc->type = type;
7661 desc->shader = shader;
7662 if (wine_rb_put(&blitter->shaders, &desc->type, &desc->entry) == -1)
7663 {
7664err_out:
7665 ERR("Out of memory\n");
7666 GL_EXTCALL(glDeleteProgramsARB(1, &shader));
7667 checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &shader))");
7668 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0));
7669 checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0)");
7670 heap_free(desc);
7671 return E_OUTOFMEMORY;
7672 }
7673 }
7674
7675 if (fixup == COMPLEX_FIXUP_P8)
7676 upload_palette(blitter, texture, context);
7677
7678 gl_info->gl_ops.gl.p_glEnable(GL_FRAGMENT_PROGRAM_ARB);
7679 checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB)");
7680 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader));
7681 checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader)");
7682 GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARBFP_BLIT_PARAM_SIZE, &size.x));
7683 checkGLcall("glProgramLocalParameter4fvARB");
7684 if (type.use_color_key)
7685 {
7686 wined3d_format_get_float_color_key(texture->resource.format, color_key, float_color_key);
7687 GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB,
7688 ARBFP_BLIT_PARAM_COLOR_KEY_LOW, &float_color_key[0].r));
7689 GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB,
7690 ARBFP_BLIT_PARAM_COLOR_KEY_HIGH, &float_color_key[1].r));
7691 checkGLcall("glProgramLocalParameter4fvARB");
7692 }
7693
7694 return WINED3D_OK;
7695}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define ARBFP_BLIT_PARAM_COLOR_KEY_LOW
static GLuint gen_p8_shader(const struct wined3d_gl_info *gl_info, const struct arbfp_blit_type *type)
#define ARBFP_BLIT_PARAM_SIZE
static GLuint arbfp_gen_plain_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)
#define ARBFP_BLIT_PARAM_COLOR_KEY_HIGH
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
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:5321
GLint level
Definition: gl.h:1546
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
unsigned int GLuint
Definition: gl.h:159
#define GL_TEXTURE_3D
Definition: gl.h:1515
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define GL_TEXTURE_2D
Definition: gl.h:645
#define GL_TEXTURE_1D
Definition: gl.h:644
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint texture
Definition: glext.h:6295
#define GL_FRAGMENT_PROGRAM_ARB
Definition: glext.h:1466
#define GL_TEXTURE_CUBE_MAP_ARB
Definition: glext.h:1230
#define GL_TEXTURE_RECTANGLE_ARB
Definition: glext.h:1614
uint32_t entry
Definition: isohybrid.c:63
static const WCHAR desc[]
Definition: protectdata.c:36
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
static struct wine_rb_entry * wine_rb_get(const struct wine_rb_tree *tree, const void *key)
Definition: rbtree.h:203
static int wine_rb_put(struct wine_rb_tree *tree, const void *key, struct wine_rb_entry *entry)
Definition: rbtree.h:215
Definition: rbtree.h:36
struct wine_rb_tree shaders
#define WINED3D_OK
Definition: wined3d.h:37
static unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture *texture, unsigned int level)
static enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup)
static BOOL is_complex_fixup(struct color_fixup_desc fixup)
#define GL_EXTCALL(f)
static unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture *texture, unsigned int level)
static BOOL is_identity_fixup(struct color_fixup_desc fixup)
@ WINED3D_GL_RES_TYPE_TEX_3D
@ WINED3D_GL_RES_TYPE_TEX_CUBE
@ WINED3D_GL_RES_TYPE_TEX_2D
@ WINED3D_GL_RES_TYPE_TEX_RECT
@ WINED3D_GL_RES_TYPE_TEX_1D
complex_fixup
@ COMPLEX_FIXUP_P8
@ COMPLEX_FIXUP_YUY2
@ COMPLEX_FIXUP_UYVY
@ COMPLEX_FIXUP_NV12
@ COMPLEX_FIXUP_YV12
@ COMPLEX_FIXUP_NONE

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 7704 of file arb_program_shader.c.

7707{
7708 const struct wined3d_format *src_format = src_resource->format;
7709 const struct wined3d_format *dst_format = dst_resource->format;
7710 enum complex_fixup src_fixup;
7711 BOOL decompress;
7712
7713 if (!context->gl_info->supported[ARB_FRAGMENT_PROGRAM])
7714 return FALSE;
7715
7716 if (blit_op == WINED3D_BLIT_OP_RAW_BLIT && dst_format->id == src_format->id)
7717 {
7720 else
7722 }
7723
7724 switch (blit_op)
7725 {
7727 if (!context->d3d_info->shader_color_key)
7728 {
7729 /* The conversion modifies the alpha channel so the color key might no longer match. */
7730 TRACE("Color keying not supported with converted textures.\n");
7731 return FALSE;
7732 }
7735 break;
7736
7737 default:
7738 TRACE("Unsupported blit_op=%d\n", blit_op);
7739 return FALSE;
7740 }
7741
7742 decompress = src_format && (src_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED)
7744 if (!decompress && !(src_resource->access & dst_resource->access & WINED3D_RESOURCE_ACCESS_GPU))
7745 return FALSE;
7746
7747 src_fixup = get_complex_fixup(src_format->color_fixup);
7748 if (TRACE_ON(d3d_shader) && TRACE_ON(d3d))
7749 {
7750 TRACE("Checking support for fixup:\n");
7752 }
7753
7754 if (!is_identity_fixup(dst_format->color_fixup)
7755 && (dst_format->id != src_format->id || dst_location != WINED3D_LOCATION_DRAWABLE))
7756 {
7757 TRACE("Destination fixups are not supported\n");
7758 return FALSE;
7759 }
7760
7761 if (is_identity_fixup(src_format->color_fixup))
7762 {
7763 TRACE("[OK]\n");
7764 return TRUE;
7765 }
7766
7767 /* We only support YUV conversions. */
7768 if (!is_complex_fixup(src_format->color_fixup))
7769 {
7771 {
7772 WARN("Claiming fixup support because of ORM_BACKBUFFER.\n");
7773 return TRUE;
7774 }
7775
7776 TRACE("[FAILED]\n");
7777 return FALSE;
7778 }
7779
7780 switch(src_fixup)
7781 {
7782 case COMPLEX_FIXUP_YUY2:
7783 case COMPLEX_FIXUP_UYVY:
7784 case COMPLEX_FIXUP_YV12:
7785 case COMPLEX_FIXUP_NV12:
7786 case COMPLEX_FIXUP_P8:
7787 TRACE("[OK]\n");
7788 return TRUE;
7789
7790 default:
7791 FIXME("Unsupported YUV fixup %#x\n", src_fixup);
7792 TRACE("[FAILED]\n");
7793 return FALSE;
7794 }
7795}
#define WARN(fmt,...)
Definition: debug.h:112
void dump_color_fixup_desc(struct color_fixup_desc fixup)
Definition: utils.c:4851
#define TRACE_ON(x)
Definition: compat.h:75
unsigned int BOOL
Definition: ntddk_ex.h:94
static const char * dst_format
Definition: dib.c:1133
unsigned int flags[WINED3D_GL_RES_TYPE_COUNT]
enum wined3d_format_id id
struct color_fixup_desc color_fixup
unsigned int access
const struct wined3d_format * format
#define WINED3D_RESOURCE_ACCESS_GPU
Definition: wined3d.h:55
@ ARB_FRAGMENT_PROGRAM
Definition: wined3d_gl.h:70
#define ORM_BACKBUFFER
#define WINED3D_LOCATION_DRAWABLE
#define WINED3DFMT_FLAG_STENCIL
#define WINED3DFMT_FLAG_COMPRESSED
#define WINED3DFMT_FLAG_DEPTH
@ WINED3D_BLIT_OP_COLOR_BLIT_CKEY
@ WINED3D_BLIT_OP_RAW_BLIT
@ WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST
@ WINED3D_BLIT_OP_DEPTH_BLIT
@ WINED3D_BLIT_OP_COLOR_BLIT

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 6887 of file arb_program_shader.c.

6888{
6889 const struct arbfp_blit_type *ka = key;
6890 const struct arbfp_blit_type *kb = &WINE_RB_ENTRY_VALUE(entry, const struct arbfp_blit_desc, entry)->type;
6891
6892 return memcmp(ka, kb, sizeof(*ka));
6893}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
Definition: copy.c:22

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 7698 of file arb_program_shader.c.

7699{
7700 gl_info->gl_ops.gl.p_glDisable(GL_FRAGMENT_PROGRAM_ARB);
7701 checkGLcall("glDisable(GL_FRAGMENT_PROGRAM_ARB)");
7702}

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_surface src_surface,
DWORD  src_location,
const RECT src_rect,
struct wined3d_surface dst_surface,
DWORD  dst_location,
const RECT dst_rect,
const struct wined3d_color_key color_key,
enum wined3d_texture_filter_type  filter 
)
static

Definition at line 7797 of file arb_program_shader.c.

7801{
7802 unsigned int src_sub_resource_idx = surface_get_sub_resource_idx(src_surface);
7803 struct wined3d_texture *src_texture = src_surface->container;
7804 struct wined3d_texture *dst_texture = dst_surface->container;
7805 struct wined3d_device *device = dst_texture->resource.device;
7806 struct wined3d_arbfp_blitter *arbfp_blitter;
7807 struct wined3d_color_key alpha_test_key;
7808 struct wined3d_blitter *next;
7809 RECT s, d;
7810
7811 if (!arbfp_blit_supported(op, context, &src_texture->resource, src_location,
7812 &dst_texture->resource, dst_location))
7813 {
7814 if ((next = blitter->next))
7815 return next->ops->blitter_blit(next, op, context, src_surface, src_location,
7816 src_rect, dst_surface, dst_location, dst_rect, color_key, filter);
7817 }
7818
7819 arbfp_blitter = CONTAINING_RECORD(blitter, struct wined3d_arbfp_blitter, blitter);
7820
7821 /* Now load the surface */
7823 && (surface_get_sub_resource(src_surface)->locations
7826 && !wined3d_resource_is_offscreen(&src_texture->resource))
7827 {
7828 unsigned int src_level = src_sub_resource_idx % src_texture->level_count;
7829
7830 /* Without FBO blits transferring from the drawable to the texture is
7831 * expensive, because we have to flip the data in sysmem. Since we can
7832 * flip in the blitter, we don't actually need that flip anyway. So we
7833 * use the surface's texture as scratch texture, and flip the source
7834 * rectangle instead. */
7835 surface_load_fb_texture(src_surface, FALSE, context);
7836
7837 s = *src_rect;
7838 s.top = wined3d_texture_get_level_height(src_texture, src_level) - s.top;
7839 s.bottom = wined3d_texture_get_level_height(src_texture, src_level) - s.bottom;
7840 src_rect = &s;
7841 }
7842 else
7843 wined3d_texture_load(src_texture, context, FALSE);
7844
7846
7847 if (dst_location == WINED3D_LOCATION_DRAWABLE)
7848 {
7849 d = *dst_rect;
7850 surface_translate_drawable_coords(dst_surface, context->win_handle, &d);
7851 dst_rect = &d;
7852 }
7853
7855 {
7856 GLenum buffer;
7857
7858 if (dst_location == WINED3D_LOCATION_DRAWABLE)
7859 {
7860 TRACE("Destination surface %p is onscreen.\n", dst_surface);
7862 }
7863 else
7864 {
7865 TRACE("Destination surface %p is offscreen.\n", dst_surface);
7867 }
7868 context_apply_fbo_state_blit(context, GL_DRAW_FRAMEBUFFER, dst_surface, NULL, dst_location);
7872 }
7873
7875 {
7876 const struct wined3d_format *fmt = src_texture->resource.format;
7877 alpha_test_key.color_space_low_value = 0;
7878 alpha_test_key.color_space_high_value = ~(((1u << fmt->alpha_size) - 1) << fmt->alpha_offset);
7879 color_key = &alpha_test_key;
7880 }
7881
7882 arbfp_blit_set(arbfp_blitter, context, src_texture, src_sub_resource_idx, color_key);
7883
7884 /* Draw a textured quad */
7885 draw_textured_quad(src_texture, src_sub_resource_idx, context, src_rect, dst_rect, filter);
7886
7887 /* Leave the opengl state valid for blitting */
7888 arbfp_blit_unset(context->gl_info);
7889
7891 || (dst_texture->swapchain && (dst_texture->swapchain->front_buffer == dst_texture)))
7892 context->gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */
7893
7894 return dst_location;
7895}
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 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)
UINT op
Definition: effect.c:236
void context_check_fbo_status(const struct wined3d_context *context, GLenum target)
Definition: context.c:381
void context_set_draw_buffer(struct wined3d_context *context, GLenum buffer)
Definition: context.c:2701
void context_invalidate_state(struct wined3d_context *context, DWORD state)
Definition: context.c:1652
void context_apply_blit_state(struct wined3d_context *context, const struct wined3d_device *device)
Definition: context.c:2981
void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target, struct wined3d_surface *render_target, struct wined3d_surface *depth_stencil, DWORD location)
Definition: context.c:802
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource)
Definition: resource.c:547
void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb, struct wined3d_context *old_ctx)
Definition: surface.c:1710
void draw_textured_quad(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, const RECT *src_rect, const RECT *dst_rect, enum wined3d_texture_filter_type filter)
Definition: surface.c:188
void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect)
Definition: surface.c:2164
GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture)
Definition: texture.c:51
void wined3d_texture_load(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:1066
unsigned int GLenum
Definition: gl.h:150
GLdouble s
Definition: gl.h:2039
GLsizei const GLint * locations
Definition: glext.h:10542
#define GL_COLOR_ATTACHMENT0
Definition: glext.h:1714
#define GL_DRAW_FRAMEBUFFER
Definition: glext.h:1699
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
#define d
Definition: ke_i.h:81
static unsigned __int64 next
Definition: rand_nt.c:6
Definition: devices.h:37
Definition: dsound.c:943
LONG top
Definition: windef.h:307
struct wined3d_blitter * next
struct wined3d_texture * container
struct wined3d_swapchain * swapchain
struct wined3d_resource resource
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
static unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *surface)
static struct wined3d_texture_sub_resource * surface_get_sub_resource(struct wined3d_surface *surface)
#define WINED3D_LOCATION_TEXTURE_RGB
#define ORM_FBO
#define STATE_FRAMEBUFFER

◆ 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 7897 of file arb_program_shader.c.

7900{
7901 struct wined3d_blitter *next;
7902
7903 if ((next = blitter->next))
7904 next->ops->blitter_clear(next, device, rt_count, fb, rect_count,
7905 clear_rects, draw_rect, flags, colour, depth, stencil);
7906}
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLbitfield flags
Definition: glext.h:7161
GLint GLfloat GLint stencil
Definition: glext.h:6260

◆ arbfp_blitter_destroy()

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

Definition at line 6911 of file arb_program_shader.c.

6912{
6913 const struct wined3d_gl_info *gl_info = context->gl_info;
6914 struct wined3d_arbfp_blitter *arbfp_blitter;
6915 struct wined3d_blitter *next;
6916
6917 if ((next = blitter->next))
6918 next->ops->blitter_destroy(next, context);
6919
6920 arbfp_blitter = CONTAINING_RECORD(blitter, struct wined3d_arbfp_blitter, blitter);
6921
6923 checkGLcall("Delete blit programs");
6924
6925 if (arbfp_blitter->palette_texture)
6926 gl_info->gl_ops.gl.p_glDeleteTextures(1, &arbfp_blitter->palette_texture);
6927
6928 heap_free(arbfp_blitter);
6929}
static void arbfp_free_blit_shader(struct wine_rb_entry *entry, void *ctx)
static void wine_rb_destroy(struct wine_rb_tree *tree, wine_rb_traverse_func_t *callback, void *context)
Definition: rbtree.h:198

◆ arbfp_enable()

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

Definition at line 5704 of file arb_program_shader.c.

5705{
5706 if (enable)
5707 {
5708 gl_info->gl_ops.gl.p_glEnable(GL_FRAGMENT_PROGRAM_ARB);
5709 checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB)");
5710 }
5711 else
5712 {
5713 gl_info->gl_ops.gl.p_glDisable(GL_FRAGMENT_PROGRAM_ARB);
5714 checkGLcall("glDisable(GL_FRAGMENT_PROGRAM_ARB)");
5715 }
5716}
GLboolean enable
Definition: glext.h:11120

◆ arbfp_free()

static void arbfp_free ( struct wined3d_device device)
static

Definition at line 5749 of file arb_program_shader.c.

5750{
5751 struct shader_arb_priv *priv = device->fragment_priv;
5752
5753 wine_rb_destroy(&priv->fragment_shaders, arbfp_free_ffpshader, &device->adapter->gl_info);
5755
5756 if (device->shader_backend != &arb_program_shader_backend)
5757 heap_free(device->fragment_priv);
5758}
static void arbfp_free_ffpshader(struct wine_rb_entry *entry, void *context)

◆ arbfp_free_blit_shader()

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

Definition at line 6896 of file arb_program_shader.c.

6897{
6898 struct arbfp_blit_desc *entry_arb = WINE_RB_ENTRY_VALUE(entry, struct arbfp_blit_desc, entry);
6899 const struct wined3d_gl_info *gl_info;
6900 struct wined3d_context *context;
6901
6902 context = ctx;
6903 gl_info = context->gl_info;
6904
6905 GL_EXTCALL(glDeleteProgramsARB(1, &entry_arb->shader));
6906 checkGLcall("glDeleteProgramsARB(1, &entry_arb->shader)");
6907 heap_free(entry_arb);
6908}
const struct wined3d_gl_info * gl_info

Referenced by arbfp_blitter_destroy().

◆ arbfp_free_context_data()

static void arbfp_free_context_data ( struct wined3d_context context)
static

Definition at line 6845 of file arb_program_shader.c.

6846{
6847}

◆ arbfp_free_ffpshader()

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

Definition at line 5738 of file arb_program_shader.c.

5739{
5740 const struct wined3d_gl_info *gl_info = context;
5741 struct arbfp_ffp_desc *entry_arb = WINE_RB_ENTRY_VALUE(entry, struct arbfp_ffp_desc, parent.entry);
5742
5743 GL_EXTCALL(glDeleteProgramsARB(1, &entry_arb->shader));
5744 checkGLcall("glDeleteProgramsARB(1, &entry_arb->shader)");
5745 heap_free(entry_arb);
5746}
r parent
Definition: btrfs.c:3010

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 7516 of file arb_program_shader.c.

7517{
7518 GLuint shader;
7520 const char *tex_target = arbfp_texture_target(type->res_type);
7521
7522 /* Shader header */
7524 {
7525 ERR("Failed to initialize shader buffer.\n");
7526 return 0;
7527 }
7528
7529 GL_EXTCALL(glGenProgramsARB(1, &shader));
7530 if (!shader)
7531 {
7533 return 0;
7534 }
7535 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader));
7536
7537 shader_addline(&buffer, "!!ARBfp1.0\n");
7538
7539 if (type->use_color_key)
7540 {
7541 shader_addline(&buffer, "TEMP color;\n");
7542 shader_addline(&buffer, "TEMP less, greater;\n");
7543 shader_addline(&buffer, "PARAM color_key_low = program.local[%u];\n", ARBFP_BLIT_PARAM_COLOR_KEY_LOW);
7544 shader_addline(&buffer, "PARAM color_key_high = program.local[%u];\n", ARBFP_BLIT_PARAM_COLOR_KEY_HIGH);
7545 shader_addline(&buffer, "TEX color, fragment.texcoord[0], texture[0], %s;\n", tex_target);
7546 shader_addline(&buffer, "SLT less, color, color_key_low;\n"); /* below low key */
7547 shader_addline(&buffer, "SGE greater, color, color_key_high;\n"); /* above high key */
7548 shader_addline(&buffer, "ADD less, less, greater;\n"); /* or */
7549 shader_addline(&buffer, "DP4 less.b, less, less;\n"); /* on any channel */
7550 shader_addline(&buffer, "SGE less, -less.b, 0.0;\n"); /* logical not */
7551 shader_addline(&buffer, "KIL -less;\n"); /* discard if true */
7552 shader_addline(&buffer, "MOV result.color, color;\n");
7553 }
7554 else
7555 {
7556 shader_addline(&buffer, "TEX result.color, fragment.texcoord[0], texture[0], %s;\n", tex_target);
7557 }
7558
7559 shader_addline(&buffer, "END\n");
7560
7562
7564
7565 return shader;
7566}
static BOOL shader_arb_compile(const struct wined3d_gl_info *gl_info, GLenum target, const char *src)
static const char * arbfp_texture_target(enum wined3d_gl_resource_type type)
void string_buffer_free(struct wined3d_string_buffer *buffer)
Definition: shader.c:441
BOOL string_buffer_init(struct wined3d_string_buffer *buffer)
Definition: shader.c:428

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 5760 of file arb_program_shader.c.

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

◆ arbfp_get_emul_mask()

static DWORD arbfp_get_emul_mask ( const struct wined3d_gl_info gl_info)
static

Definition at line 5798 of file arb_program_shader.c.

5799{
5801}
#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 6216 of file arb_program_shader.c.

6217{
6218 switch(type)
6219 {
6221 return "1D";
6223 return "2D";
6225 return "3D";
6227 return "CUBE";
6229 return "RECT";
6230 default:
6231 return "unexpected_resource_type";
6232 }
6233}

Referenced by arbfp_gen_plain_shader(), gen_arbfp_ffp_shader(), gen_nv12_read(), gen_p8_shader(), gen_planar_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)
1313 if (fixup.y_sign_fixup)
1315 if (fixup.z_sign_fixup)
1317 if (fixup.w_sign_fixup)
1319 masks.sign &= dst_mask;
1320
1321 return masks;
1322}
static const BYTE masks[8]
Definition: dib.c:2760
unsigned short x_source
unsigned short y_sign_fixup
unsigned short w_source
unsigned short x_sign_fixup
unsigned short z_sign_fixup
unsigned short y_source
unsigned short w_sign_fixup
unsigned short z_source
#define WINED3DSP_WRITEMASK_0
#define WINED3DSP_WRITEMASK_3
@ CHANNEL_SOURCE_W
@ CHANNEL_SOURCE_X
@ CHANNEL_SOURCE_Z
@ CHANNEL_SOURCE_Y
#define WINED3DSP_WRITEMASK_2
#define WINED3DSP_WRITEMASK_1

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 3877 of file arb_program_shader.c.

3878{
3879 unsigned int i;
3880 char *name;
3881
3882 new->element_count = sig->element_count;
3883 new->elements = heap_calloc(new->element_count, sizeof(*new->elements));
3884 for (i = 0; i < sig->element_count; ++i)
3885 {
3886 new->elements[i] = sig->elements[i];
3887
3888 if (!new->elements[i].semantic_name)
3889 continue;
3890
3891 /* Clone the semantic string */
3892 name = heap_alloc(strlen(sig->elements[i].semantic_name) + 1);
3893 strcpy(name, sig->elements[i].semantic_name);
3894 new->elements[i].semantic_name = name;
3895 }
3896}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static void * heap_calloc(SIZE_T count, SIZE_T size)
Definition: heap.h:49
Definition: name.c:39
struct wined3d_shader_signature_element * elements
Definition: wined3d.h:2046
#define new(TYPE, numElems)
Definition: treelist.c:54

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 5983 of file arb_program_shader.c.

5984{
5985 const struct wined3d_texture *texture = state->textures[0];
5986 const struct wined3d_gl_info *gl_info = context->gl_info;
5987 struct wined3d_device *device = context->device;
5988 struct wined3d_color float_key[2];
5989
5990 if (!texture)
5991 return;
5992
5993 if (device->shader_backend == &arb_program_shader_backend)
5994 {
5995 struct shader_arb_priv *priv;
5996
5997 /* Don't load the parameter if we're using an arbfp pixel shader,
5998 * otherwise we'll overwrite application provided constants. */
5999 if (use_ps(state))
6000 return;
6001
6002 priv = device->shader_priv;
6006 }
6007
6008 wined3d_format_get_float_color_key(texture->resource.format, &texture->async.src_blt_color_key, float_key);
6009
6010 GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_COLOR_KEY_LOW, &float_key[0].r));
6011 checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_COLOR_KEY_LOW, &float_key[0].r)");
6012 GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_COLOR_KEY_HIGH, &float_key[1].r));
6013 checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_COLOR_KEY_HIGH, &float_key[1].r)");
6014}
#define ARB_FFP_CONST_COLOR_KEY_HIGH
#define ARB_FFP_CONST_COLOR_KEY_LOW
char pshader_const_dirty[WINED3D_MAX_PS_CONSTS_F]
unsigned int highest_dirty_ps_const
#define max(a, b)
Definition: svc.c:63
static BOOL use_ps(const struct wined3d_state *state)

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 3837 of file arb_program_shader.c.

3838{
3839 unsigned int i;
3840 int ret;
3841
3842 if (sig1->element_count != sig2->element_count)
3843 return sig1->element_count < sig2->element_count ? -1 : 1;
3844
3845 for (i = 0; i < sig1->element_count; ++i)
3846 {
3847 const struct wined3d_shader_signature_element *e1, *e2;
3848
3849 e1 = &sig1->elements[i];
3850 e2 = &sig2->elements[i];
3851
3852 if (!e1->semantic_name || !e2->semantic_name)
3853 {
3854 /* Compare pointers, not contents. One string is NULL (element
3855 * does not exist), the other one is not NULL. */
3856 if (e1->semantic_name != e2->semantic_name)
3857 return e1->semantic_name < e2->semantic_name ? -1 : 1;
3858 continue;
3859 }
3860
3861 if ((ret = strcmp(e1->semantic_name, e2->semantic_name)))
3862 return ret;
3863 if (e1->semantic_idx != e2->semantic_idx)
3864 return e1->semantic_idx < e2->semantic_idx ? -1 : 1;
3865 if (e1->sysval_semantic != e2->sysval_semantic)
3866 return e1->sysval_semantic < e2->sysval_semantic ? -1 : 1;
3867 if (e1->component_type != e2->component_type)
3868 return e1->component_type < e2->component_type ? -1 : 1;
3869 if (e1->register_idx != e2->register_idx)
3870 return e1->register_idx < e2->register_idx ? -1 : 1;
3871 if (e1->mask != e2->mask)
3872 return e1->mask < e2->mask ? -1 : 1;
3873 }
3874 return 0;
3875}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
enum wined3d_component_type component_type
Definition: wined3d.h:2038
enum wined3d_sysval_semantic sysval_semantic
Definition: wined3d.h:2037
int ret

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}

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 4430 of file arb_program_shader.c.

4433{
4434 const struct wined3d_gl_info *gl_info = context->gl_info;
4435 const struct wined3d_d3d_info *d3d_info = context->d3d_info;
4436 int i;
4437 WORD int_skip;
4438
4439 find_ps_compile_args(state, shader, context->stream_info.position_transformed, &args->super, context);
4440
4441 /* This forces all local boolean constants to 1 to make them stateblock independent */
4442 args->bools = shader->reg_maps.local_bool_consts;
4443
4444 for (i = 0; i < WINED3D_MAX_CONSTS_B; ++i)
4445 {
4446 if (state->ps_consts_b[i])
4447 args->bools |= ( 1u << i);
4448 }
4449
4450 /* Only enable the clip plane emulation KIL if at least one clipplane is enabled. The KIL instruction
4451 * is quite expensive because it forces the driver to disable early Z discards. It is cheaper to
4452 * duplicate the shader than have a no-op KIL instruction in every shader
4453 */
4454 if (!d3d_info->vs_clipping && use_vs(state)
4455 && state->render_states[WINED3D_RS_CLIPPING]
4456 && state->render_states[WINED3D_RS_CLIPPLANEENABLE])
4457 args->clip = 1;
4458 else
4459 args->clip = 0;
4460
4461 /* Skip if unused or local, or supported natively */
4462 int_skip = ~shader->reg_maps.integer_constants | shader->reg_maps.local_int_consts;
4463 if (int_skip == 0xffff || gl_info->supported[NV_FRAGMENT_PROGRAM_OPTION])
4464 {
4465 memset(args->loop_ctrl, 0, sizeof(args->loop_ctrl));
4466 return;
4467 }
4468
4469 for (i = 0; i < WINED3D_MAX_CONSTS_I; ++i)
4470 {
4471 if (int_skip & (1u << i))
4472 {
4473 args->loop_ctrl[i][0] = 0;
4474 args->loop_ctrl[i][1] = 0;
4475 args->loop_ctrl[i][2] = 0;
4476 }
4477 else
4478 {
4479 args->loop_ctrl[i][0] = state->ps_consts_i[i].x;
4480 args->loop_ctrl[i][1] = state->ps_consts_i[i].y;
4481 args->loop_ctrl[i][2] = state->ps_consts_i[i].z;
4482 }
4483 }
4484}
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:3782
unsigned short WORD
Definition: ntddk_ex.h:93
if(dx< 0)
Definition: linetemp.h:194
#define memset(x, y, z)
Definition: compat.h:39
Definition: match.c:390
BOOL supported[WINED3D_GL_EXT_COUNT]
@ WINED3D_RS_CLIPPLANEENABLE
Definition: wined3d.h:337
@ WINED3D_RS_CLIPPING
Definition: wined3d.h:323
@ NV_FRAGMENT_PROGRAM_OPTION
Definition: wined3d_gl.h:190
static BOOL use_vs(const struct wined3d_state *state)
#define WINED3D_MAX_CONSTS_B
#define WINED3D_MAX_CONSTS_I

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 4244 of file arb_program_shader.c.

4246{
4247 struct wined3d_device *device = shader->device;
4248 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
4249 const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
4250 UINT i;
4251 DWORD new_size;
4252 struct arb_ps_compiled_shader *new_array;
4254 struct arb_pshader_private *shader_data;
4255 GLuint ret;
4256
4257 if (!shader->backend_data)
4258 {
4259 struct shader_arb_priv *priv = device->shader_priv;
4260
4261 shader->backend_data = heap_alloc_zero(sizeof(*shader_data));
4262 shader_data = shader->backend_data;
4263 shader_data->clamp_consts = shader->reg_maps.shader_version.major == 1;
4264
4265 if (shader->reg_maps.shader_version.major < 3)
4266 shader_data->input_signature_idx = ~0U;
4267 else
4268 shader_data->input_signature_idx = find_input_signature(priv, &shader->input_signature);
4269
4270 TRACE("Shader got assigned input signature index %u\n", shader_data->input_signature_idx);
4271
4272 if (!d3d_info->vs_clipping)
4274 d3d_info->limits.ffp_blend_stages - 1);
4275 else
4276 shader_data->clipplane_emulation = ~0U;
4277 }
4278 shader_data = shader->backend_data;
4279
4280 /* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
4281 * so a linear search is more performant than a hashmap or a binary search
4282 * (cache coherency etc)
4283 */
4284 for (i = 0; i < shader_data->num_gl_shaders; ++i)
4285 {
4286 if (!memcmp(&shader_data->gl_shaders[i].args, args, sizeof(*args)))
4287 return &shader_data->gl_shaders[i];
4288 }
4289
4290 TRACE("No matching GL shader found, compiling a new shader\n");
4291 if(shader_data->shader_array_size == shader_data->num_gl_shaders) {
4292 if (shader_data->num_gl_shaders)
4293 {
4294 new_size = shader_data->shader_array_size + max(1, shader_data->shader_array_size / 2);
4295 new_array = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, shader_data->gl_shaders,
4296 new_size * sizeof(*shader_data->gl_shaders));
4297 }
4298 else
4299 {
4300 new_array = heap_alloc_zero(sizeof(*shader_data->gl_shaders));
4301 new_size = 1;
4302 }
4303
4304 if(!new_array) {
4305 ERR("Out of memory\n");
4306 return 0;
4307 }
4308 shader_data->gl_shaders = new_array;
4309 shader_data->shader_array_size = new_size;
4310 }
4311
4312 shader_data->gl_shaders[shader_data->num_gl_shaders].args = *args;
4313
4315
4317 {
4318 ERR("Failed to initialize shader buffer.\n");
4319 return 0;
4320 }
4321
4323 &shader_data->gl_shaders[shader_data->num_gl_shaders]);
4325 shader_data->gl_shaders[shader_data->num_gl_shaders].prgId = ret;
4326
4327 return &shader_data->gl_shaders[shader_data->num_gl_shaders++];
4328}
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 DWORD find_input_signature(struct shader_arb_priv *priv, const struct wined3d_shader_signature *sig)
#define U(x)
Definition: wordpad.c:45
void pixelshader_update_resource_types(struct wined3d_shader *shader, WORD tex_types)
Definition: shader.c:4073
unsigned int shader_find_free_input_register(const struct wined3d_shader_reg_maps *reg_maps, unsigned int max)
Definition: shader.c:1838
#define GetProcessHeap()
Definition: compat.h:736
#define HeapReAlloc
Definition: compat.h:734
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned int UINT
Definition: ndis.h:50
#define args
Definition: format.c:66
struct arb_ps_compiled_shader * gl_shaders
struct wined3d_d3d_limits limits

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 4486 of file arb_program_shader.c.

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

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 4343 of file arb_program_shader.c.

4346{
4347 UINT i;
4348 DWORD new_size;
4349 struct arb_vs_compiled_shader *new_array;
4351 struct arb_vshader_private *shader_data;
4352 GLuint ret;
4353
4354 if (!shader->backend_data)
4355 {
4356 const struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
4357
4358 shader->backend_data = heap_alloc_zero(sizeof(*shader_data));
4359 shader_data = shader->backend_data;
4360
4362 && reg_maps->min_rel_offset <= reg_maps->max_rel_offset)
4363 {
4364 if (reg_maps->max_rel_offset - reg_maps->min_rel_offset > 127)
4365 {
4366 FIXME("The difference between the minimum and maximum relative offset is > 127.\n");
4367 FIXME("Which this OpenGL implementation does not support. Try using GLSL.\n");
4368 FIXME("Min: %u, Max: %u.\n", reg_maps->min_rel_offset, reg_maps->max_rel_offset);
4369 }
4370 else if (reg_maps->max_rel_offset - reg_maps->min_rel_offset > 63)
4371 shader_data->rel_offset = reg_maps->min_rel_offset + 63;
4372 else if (reg_maps->max_rel_offset > 63)
4373 shader_data->rel_offset = reg_maps->min_rel_offset;
4374 }
4375 }
4376 shader_data = shader->backend_data;
4377
4378 /* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
4379 * so a linear search is more performant than a hashmap or a binary search
4380 * (cache coherency etc)
4381 */
4382 for(i = 0; i < shader_data->num_gl_shaders; i++) {
4383 if (vs_args_equal(&shader_data->gl_shaders[i].args, args,
4384 use_map, gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]))
4385 {
4386 return &shader_data->gl_shaders[i];
4387 }
4388 }
4389
4390 TRACE("No matching GL shader found, compiling a new shader\n");
4391
4392 if(shader_data->shader_array_size == shader_data->num_gl_shaders) {
4393 if (shader_data->num_gl_shaders)
4394 {
4395 new_size = shader_data->shader_array_size + max(1, shader_data->shader_array_size / 2);
4396 new_array = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, shader_data->gl_shaders,
4397 new_size * sizeof(*shader_data->gl_shaders));
4398 }
4399 else
4400 {
4401 new_array = heap_alloc_zero(sizeof(*shader_data->gl_shaders));
4402 new_size = 1;
4403 }
4404
4405 if(!new_array) {
4406 ERR("Out of memory\n");
4407 return 0;
4408 }
4409 shader_data->gl_shaders = new_array;
4410 shader_data->shader_array_size = new_size;
4411 }
4412
4413 shader_data->gl_shaders[shader_data->num_gl_shaders].args = *args;
4414
4416 {
4417 ERR("Failed to initialize shader buffer.\n");
4418 return 0;
4419 }
4420
4422 &shader_data->gl_shaders[shader_data->num_gl_shaders],
4423 ps_input_sig);
4425 shader_data->gl_shaders[shader_data->num_gl_shaders].prgId = ret;
4426
4427 return &shader_data->gl_shaders[shader_data->num_gl_shaders++];
4428}
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 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)
struct arb_vs_compiled_shader * gl_shaders
#define WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT

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 3898 of file arb_program_shader.c.

3899{
3900 struct wine_rb_entry *entry = wine_rb_get(&priv->signature_tree, sig);
3901 struct ps_signature *found_sig;
3902
3903 if (entry)
3904 {
3905 found_sig = WINE_RB_ENTRY_VALUE(entry, struct ps_signature, entry);
3906 TRACE("Found existing signature %u\n", found_sig->idx);
3907 return found_sig->idx;
3908 }
3909 found_sig = heap_alloc_zero(sizeof(*found_sig));
3910 clone_sig(&found_sig->sig, sig);
3911 found_sig->idx = priv->ps_sig_number++;
3912 TRACE("New signature stored and assigned number %u\n", found_sig->idx);
3913 if(wine_rb_put(&priv->signature_tree, sig, &found_sig->entry) == -1)
3914 {
3915 ERR("Failed to insert program entry.\n");
3916 }
3917 return found_sig->idx;
3918}
static void clone_sig(struct wined3d_shader_signature *new, const struct wined3d_shader_signature *sig)
struct wine_rb_entry entry
struct wined3d_shader_signature sig
struct wine_rb_tree signature_tree

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 2970 of file arb_program_shader.c.

2971{
2973
2975 {
2977 }
2978 ERR("Could not find loop for break\n");
2979 return NULL;
2980}
#define REP
Definition: patmatch.h:52
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
enum control_frame::@266 type

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 3398 of file arb_program_shader.c.

3399{
3400 const struct wined3d_shader_lconst *constant;
3401
3403 {
3404 if (constant->idx == idx)
3405 {
3406 return constant->value;
3407 }
3408 }
3409 return NULL;
3410}
unsigned int idx
Definition: utils.c:41
union constant::@236 value[4]

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 6538 of file arb_program_shader.c.

6539{
6540 const struct wined3d_gl_info *gl_info = context->gl_info;
6541 const struct wined3d_device *device = context->device;
6542 struct shader_arb_priv *priv = device->fragment_priv;
6543 BOOL use_pshader = use_ps(state);
6545 const struct arbfp_ffp_desc *desc;
6546 unsigned int i;
6547
6548 TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id);
6549
6551 {
6552 if (!use_pshader && device->shader_backend == &arb_program_shader_backend && context->last_was_pshader)
6553 {
6554 /* Reload fixed function constants since they collide with the
6555 * pixel shader constants. */
6556 for (i = 0; i < MAX_TEXTURES; ++i)
6557 {
6560 }
6564 }
6565 else if (use_pshader)
6566 {
6567 context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_PIXEL;
6568 }
6569 return;
6570 }
6571
6572 if (!use_pshader)
6573 {
6574 /* Find or create a shader implementing the fixed function pipeline
6575 * settings, then activate it. */
6578 if (!desc)
6579 {
6580 struct arbfp_ffp_desc *new_desc;
6581
6582 if (!(new_desc = heap_alloc(sizeof(*new_desc))))
6583 {
6584 ERR("Out of memory\n");
6585 return;
6586 }
6587
6588 new_desc->parent.settings = settings;
6589 new_desc->shader = gen_arbfp_ffp_shader(&settings, gl_info);
6590 add_ffp_frag_shader(&priv->fragment_shaders, &new_desc->parent);
6591 TRACE("Allocated fixed function replacement shader descriptor %p\n", new_desc);
6592 desc = new_desc;
6593 }
6594
6595 /* Now activate the replacement program. GL_FRAGMENT_PROGRAM_ARB is already active (however, note the
6596 * comment above the shader_select call below). If e.g. GLSL is active, the shader_select call will
6597 * deactivate it.
6598 */
6599 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, desc->shader));
6600 checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, desc->shader)");
6601 priv->current_fprogram_id = desc->shader;
6602
6603 if (device->shader_backend == &arb_program_shader_backend && context->last_was_pshader)
6604 {
6605 /* Reload fixed function constants since they collide with the
6606 * pixel shader constants. */
6607 for (i = 0; i < MAX_TEXTURES; ++i)
6608 {
6611 }
6615 }
6616 context->last_was_pshader = FALSE;
6617 }
6618 else if (!context->last_was_pshader)
6619 {
6620 if (device->shader_backend == &arb_program_shader_backend)
6621 context->constant_update_mask |= WINED3D_SHADER_CONST_PS_F;
6622 context->last_was_pshader = TRUE;
6623 }
6624
6625 context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_PIXEL;
6626}
struct mke2fs_defaults settings[]
static void state_arb_specularenable(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)
static void set_bumpmat_arbfp(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
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 color_key_arbfp(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
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:6076
void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *desc)
Definition: utils.c:6083
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:5751
struct ffp_frag_desc parent
@ WINED3D_RS_TEXTUREFACTOR
Definition: wined3d.h:314
@ WINED3D_RS_FOGENABLE
Definition: wined3d.h:287
@ WINED3D_RS_SPECULARENABLE
Definition: wined3d.h:288
@ WINED3D_TSS_CONSTANT
Definition: wined3d.h:592
@ WINED3D_TSS_BUMPENV_MAT00
Definition: wined3d.h:581
#define WINED3D_SHADER_CONST_PS_F
#define STATE_TEXTURESTAGE(stage, num)
static BOOL isStateDirty(const struct wined3d_context *context, DWORD state)
#define STATE_RENDER(a)
#define STATE_COLOR_KEY

Referenced by state_arbfp_fog(), and textransform().

◆ free_recorded_instruction()

static void free_recorded_instruction ( struct list list)
static

Definition at line 5398 of file arb_program_shader.c.

5399{
5400 struct recorded_instruction *rec_ins, *entry2;
5401 unsigned int i;
5402
5403 LIST_FOR_EACH_ENTRY_SAFE(rec_ins, entry2, list, struct recorded_instruction, entry)
5404 {
5405 list_remove(&rec_ins->entry);
5406 if (rec_ins->ins.dst)
5407 {
5408 heap_free((void *)rec_ins->ins.dst->reg.idx[0].rel_addr);
5409 heap_free((void *)rec_ins->ins.dst);
5410 }
5411 if (rec_ins->ins.src)
5412 {
5413 for (i = 0; i < rec_ins->ins.src_count; ++i)
5414 {
5415 heap_free((void *)rec_ins->ins.src[i].reg.idx[0].rel_addr);
5416 }
5417 heap_free((void *)rec_ins->ins.src);
5418 }
5419 heap_free(rec_ins);
5420 }
5421}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
Definition: list.h:37
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
struct wined3d_shader_instruction ins

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 6235 of file arb_program_shader.c.

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

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}
static const char * shader_arb_get_fixup_swizzle(enum fixup_channel_source channel_source)
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
static double two
Definition: jn_yn.c:52
static PVOID ptr
Definition: dispmode.c:27
int one
Definition: sehframes.cpp:28

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,
DWORD  dst,
DWORD  op,
DWORD  dw_arg0,
DWORD  dw_arg1,
DWORD  dw_arg2 
)
static

Definition at line 6086 of file arb_program_shader.c.

6088{
6089 const char *dstmask, *dstreg, *arg0, *arg1, *arg2;
6090 unsigned int mul = 1;
6091
6092 if(color && alpha) dstmask = "";
6093 else if(color) dstmask = ".xyz";
6094 else dstmask = ".w";
6095
6096 if(dst == tempreg) dstreg = "tempreg";
6097 else dstreg = "ret";
6098
6099 arg0 = get_argreg(buffer, 0, stage, dw_arg0);
6100 arg1 = get_argreg(buffer, 1, stage, dw_arg1);
6101 arg2 = get_argreg(buffer, 2, stage, dw_arg2);
6102
6103 switch (op)
6104 {
6106 break;
6107
6109 arg1 = arg2;
6110 /* FALLTHROUGH */
6112 shader_addline(buffer, "MOV %s%s, %s;\n", dstreg, dstmask, arg1);
6113 break;
6114
6116 mul = 2;
6117 /* FALLTHROUGH */
6119 mul *= 2;
6120 /* FALLTHROUGH */
6122 shader_addline(buffer, "MUL %s%s, %s, %s;\n", dstreg, dstmask, arg1, arg2);
6123 break;
6124
6126 mul = 2;
6127 /* FALLTHROUGH */
6129 shader_addline(buffer, "SUB arg2, %s, const.w;\n", arg2);
6130 arg2 = "arg2";
6131 /* FALLTHROUGH */
6132 case WINED3D_TOP_ADD:
6133 shader_addline(buffer, "ADD_SAT %s%s, %s, %s;\n", dstreg, dstmask, arg1, arg2);
6134 break;
6135
6137 shader_addline(buffer, "SUB_SAT %s%s, %s, %s;\n", dstreg, dstmask, arg1, arg2);
6138 break;
6139
6141 shader_addline(buffer, "SUB arg1, const.x, %s;\n", arg1);
6142 shader_addline(buffer, "MAD_SAT %s%s, arg1, %s, %s;\n", dstreg, dstmask, arg2, arg1);
6143 break;
6144
6146 arg0 = get_argreg(buffer, 0, stage, WINED3DTA_CURRENT);
6147 shader_addline(buffer, "LRP %s%s, %s.w, %s, %s;\n", dstreg, dstmask, arg0, arg1, arg2);
6148 break;
6150 arg0 = get_argreg(buffer, 0, stage, WINED3DTA_TFACTOR);
6151 shader_addline(buffer, "LRP %s%s, %s.w, %s, %s;\n", dstreg, dstmask, arg0, arg1, arg2);
6152 break;
6154 arg0 = get_argreg(buffer, 0, stage, WINED3DTA_TEXTURE);
6155 shader_addline(buffer, "LRP %s%s, %s.w, %s, %s;\n", dstreg, dstmask, arg0, arg1, arg2);
6156 break;
6158 arg0 = get_argreg(buffer, 0, stage, WINED3DTA_DIFFUSE);
6159 shader_addline(buffer, "LRP %s%s, %s.w, %s, %s;\n", dstreg, dstmask, arg0, arg1, arg2);
6160 break;
6161
6163 arg0 = get_argreg(buffer, 0, stage, WINED3DTA_TEXTURE);
6164 shader_addline(buffer, "SUB arg0.w, const.x, %s.w;\n", arg0);
6165 shader_addline(buffer, "MAD_SAT %s%s, %s, arg0.w, %s;\n", dstreg, dstmask, arg2, arg1);
6166 break;
6167
6168 /* D3DTOP_PREMODULATE ???? */
6169
6171 shader_addline(buffer, "SUB arg0.w, const.x, %s;\n", arg1);
6172 shader_addline(buffer, "MAD_SAT %s%s, arg0.w, %s, %s;\n", dstreg, dstmask, arg2, arg1);
6173 break;
6175 shader_addline(buffer, "MAD_SAT %s%s, %s.w, %s, %s;\n", dstreg, dstmask, arg1, arg2, arg1);
6176 break;
6178 shader_addline(buffer, "SUB arg0, const.x, %s;\n", arg1);
6179 shader_addline(buffer, "MAD_SAT %s%s, arg0, %s, %s.w;\n", dstreg, dstmask, arg2, arg1);
6180 break;
6182 shader_addline(buffer, "MAD_SAT %s%s, %s, %s, %s.w;\n", dstreg, dstmask, arg1, arg2, arg1);
6183 break;
6184
6186 mul = 4;
6187 shader_addline(buffer, "SUB arg1, %s, const.w;\n", arg1);
6188 shader_addline(buffer, "SUB arg2, %s, const.w;\n", arg2);
6189 shader_addline(buffer, "DP3_SAT %s%s, arg1, arg2;\n", dstreg, dstmask);
6190 break;
6191
6193 shader_addline(buffer, "MAD_SAT %s%s, %s, %s, %s;\n", dstreg, dstmask, arg1, arg2, arg0);
6194 break;
6195
6196 case WINED3D_TOP_LERP:
6197 /* The msdn is not quite right here */
6198 shader_addline(buffer, "LRP %s%s, %s, %s, %s;\n", dstreg, dstmask, arg0, arg1, arg2);
6199 break;
6200
6203 /* Those are handled in the first pass of the shader(generation pass 1 and 2) already */
6204 break;
6205
6206 default:
6207 FIXME("Unhandled texture op %08x\n", op);
6208 }
6209
6210 if (mul == 2)
6211 shader_addline(buffer, "MUL_SAT %s%s, %s, const.y;\n", dstreg, dstmask, dstreg);
6212 else if (mul == 4)
6213 shader_addline(buffer, "MUL_SAT %s%s, %s, const.z;\n", dstreg, dstmask, dstreg);
6214}
static const char * get_argreg(struct wined3d_string_buffer *buffer, DWORD argnum, unsigned int stage, DWORD arg)
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
GLuint color
Definition: glext.h:6243
#define mul(aa, bb)
Definition: mvAesAlg.c:25
#define WINED3DTA_CURRENT
Definition: wined3d.h:868
@ WINED3D_TOP_BLEND_DIFFUSE_ALPHA
Definition: wined3d.h:620
@ WINED3D_TOP_ADD
Definition: wined3d.h:615
@ WINED3D_TOP_BLEND_CURRENT_ALPHA
Definition: wined3d.h:624
@ WINED3D_TOP_ADD_SIGNED_2X
Definition: wined3d.h:617
@ WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
Definition: wined3d.h:629
@ WINED3D_TOP_MULTIPLY_ADD
Definition: wined3d.h:633
@ WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
Definition: wined3d.h:628
@ WINED3D_TOP_SUBTRACT
Definition: wined3d.h:618
@ WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
Definition: wined3d.h:627
@ WINED3D_TOP_MODULATE
Definition: wined3d.h:612
@ WINED3D_TOP_MODULATE_4X
Definition: wined3d.h:614
@ WINED3D_TOP_LERP
Definition: wined3d.h:634
@ WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
Definition: wined3d.h:626
@ WINED3D_TOP_ADD_SIGNED
Definition: wined3d.h:616
@ WINED3D_TOP_DOTPRODUCT3
Definition: wined3d.h:632
@ WINED3D_TOP_ADD_SMOOTH
Definition: wined3d.h:619
@ WINED3D_TOP_MODULATE_2X
Definition: wined3d.h:613
#define WINED3DTA_DIFFUSE
Definition: wined3d.h:867

Referenced by gen_arbfp_ffp_shader().

◆ gen_nv12_read()

static BOOL gen_nv12_read ( struct wined3d_string_buffer buffer,
const struct arbfp_blit_type type,
char luminance 
)
static

Definition at line 7168 of file arb_program_shader.c.

7170{
7171 const char *tex;
7172 static const float nv12_coef[]
7173 = {2.0f / 3.0f, 1.0f / 3.0f, 1.0f, 1.0f};
7174
7175 tex = arbfp_texture_target(type->res_type);
7176
7177 /* NV12 surfaces contain a WxH sized luminance plane, followed by a (W/2)x(H/2)
7178 * sized plane where each component is an UV pair. So the effective
7179 * bitdepth is 12 bits per pixel If the whole texture is interpreted as luminance
7180 * data it looks approximately like this:
7181 *
7182 * +----------------------------------+----
7183 * | |
7184 * | |
7185 * | |
7186 * | |
7187 * | | 2
7188 * | LUMINANCE | -
7189 * | | 3
7190 * | |
7191 * | |
7192 * | |
7193 * | |
7194 * +----------------------------------+----
7195 * |UVUVUVUVUVUVUVUVUVUVUVUVUVUVUVUVUV|
7196 * |UVUVUVUVUVUVUVUVUVUVUVUVUVUVUVUVUV|
7197 * | | 1
7198 * | | -
7199 * | | 3
7200 * | |
7201 * | |
7202 * +----------------------------------+----
7203 *
7204 * When reading from rectangle textures, keep in mind that the input y coordinates
7205 * go from 0 to d3d_height, whereas the opengl texture height is 1.5 * d3d_height. */
7206
7207 shader_addline(buffer, "PARAM nv12_coef = ");
7209 shader_addline(buffer, ";\n");
7210
7211 shader_addline(buffer, "MOV texcrd, fragment.texcoord[0];\n");
7212 /* We only have half the number of chroma pixels. */
7213 shader_addline(buffer, "MUL texcrd.x, texcrd.x, coef.y;\n");
7214
7215 if (type->res_type == WINED3D_GL_RES_TYPE_TEX_2D)
7216 {
7217 shader_addline(buffer, "RCP chroma.w, size.x;\n");
7218 shader_addline(buffer, "RCP chroma.z, size.y;\n");
7219
7220 shader_addline(buffer, "MAD texcrd.y, texcrd.y, nv12_coef.y, nv12_coef.x;\n");
7221
7222 /* We must not allow filtering horizontally, this would mix U and V.
7223 * Vertical filtering is ok. However, bear in mind that the pixel center is at
7224 * 0.5, so add 0.5. */
7225
7226 /* Convert to non-normalized coordinates so we can find the
7227 * individual pixel. */
7228 shader_addline(buffer, "MUL texcrd.x, texcrd.x, size.x;\n");
7229 shader_addline(buffer, "FLR texcrd.x, texcrd.x;\n");
7230 /* Multiply by 2 since chroma components are stored in UV pixel pairs,
7231 * add 0.5 to hit the center of the pixel. */
7232 shader_addline(buffer, "MAD texcrd.x, texcrd.x, coef.z, coef.y;\n");
7233
7234 /* Convert back to normalized coordinates. */
7235 shader_addline(buffer, "MUL texcrd.x, texcrd.x, chroma.w;\n");
7236
7237 /* Clamp, keep the half pixel origin in mind. */
7238 shader_addline(buffer, "MAD temp.y, coef.y, chroma.z, nv12_coef.x;\n");
7239 shader_addline(buffer, "MAX texcrd.y, temp.y, texcrd.y;\n");
7240 shader_addline(buffer, "MAD temp.y, -coef.y, chroma.z, nv12_coef.z;\n");
7241 shader_addline(buffer, "MIN texcrd.y, temp.y, texcrd.y;\n");
7242 }
7243 else
7244 {
7245 /* Read from [size - size+size/2] */
7246 shader_addline(buffer, "MAD texcrd.y, texcrd.y, coef.y, size.y;\n");
7247
7248 shader_addline(buffer, "FLR texcrd.x, texcrd.x;\n");
7249 /* Multiply by 2 since chroma components are stored in UV pixel pairs,
7250 * add 0.5 to hit the center of the pixel. */
7251 shader_addline(buffer, "MAD texcrd.x, texcrd.x, coef.z, coef.y;\n");
7252
7253 /* Clamp */
7254 shader_addline(buffer, "MAD temp.y, size.y, coef.y, size.y;\n");
7255 shader_addline(buffer, "ADD temp.y, temp.y, -coef.y;\n");
7256 shader_addline(buffer, "MIN texcrd.y, temp.y, texcrd.y;\n");
7257 shader_addline(buffer, "ADD temp.y, size.y, coef.y;\n");
7258 shader_addline(buffer, "MAX texcrd.y, temp.y, texcrd.y;\n");
7259 }
7260 /* Read the texture, put the result into the output register. */
7261 shader_addline(buffer, "TEX temp, texcrd, texture[0], %s;\n", tex);
7262 shader_addline(buffer, "MOV chroma.y, temp.w;\n");
7263
7264 if (type->res_type == WINED3D_GL_RES_TYPE_TEX_2D)
7265 {
7266 /* Add 1/size.x */
7267 shader_addline(buffer, "ADD texcrd.x, texcrd.x, chroma.w;\n");
7268 }
7269 else
7270 {
7271 /* Add 1 */
7272 shader_addline(buffer, "ADD texcrd.x, texcrd.x, coef.x;\n");
7273 }
7274 shader_addline(buffer, "TEX temp, texcrd, texture[0], %s;\n", tex);
7275 shader_addline(buffer, "MOV chroma.x, temp.w;\n");
7276
7277 /* Sample the luminance value. It is in the top 2/3rd of the texture, so scale the y coordinate.
7278 * Clamp the y coordinate to prevent the chroma values from bleeding into the sampled luminance
7279 * values due to filtering. */
7280 shader_addline(buffer, "MOV texcrd, fragment.texcoord[0];\n");
7281 if (type->res_type == WINED3D_GL_RES_TYPE_TEX_2D)
7282 {
7283 /* Multiply the y coordinate by 2/3 and clamp it */
7284 shader_addline(buffer, "MUL texcrd.y, texcrd.y, nv12_coef.x;\n");
7285 shader_addline(buffer, "MAD temp.y, -coef.y, chroma.w, nv12_coef.x;\n");
7286 shader_addline(buffer, "MIN texcrd.y, temp.y, texcrd.y;\n");
7287 shader_addline(buffer, "TEX luminance, texcrd, texture[0], %s;\n", tex);
7288 }
7289 else
7290 {
7291 /* Reading from texture_rectangles is pretty straightforward, just use the unmodified
7292 * texture coordinate. It is still a good idea to clamp it though, since the opengl texture
7293 * is bigger
7294 */
7295 shader_addline(buffer, "ADD temp.x, size.y, -coef.y;\n");
7296 shader_addline(buffer, "MIN texcrd.y, texcrd.y, size.x;\n");
7297 shader_addline(buffer, "TEX luminance, texcrd, texture[0], %s;\n", tex);
7298 }
7299 *luminance = 'a';
7300
7301 return TRUE;
7302}

Referenced by gen_yuv_shader().

◆ gen_p8_shader()

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

Definition at line 7305 of file arb_program_shader.c.

7306{
7307 GLuint shader;
7309 const char *tex_target = arbfp_texture_target(type->res_type);
7310
7311 /* This should not happen because we only use this conversion for
7312 * present blits which don't use color keying. */
7313 if (type->use_color_key)
7314 FIXME("Implement P8 color keying.\n");
7315
7316 /* Shader header */
7318 {
7319 ERR("Failed to initialize shader buffer.\n");
7320 return 0;
7321 }
7322
7323 GL_EXTCALL(glGenProgramsARB(1, &shader));
7324 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader));
7325 if (!shader)
7326 {
7328 return 0;
7329 }
7330
7331 shader_addline(&buffer, "!!ARBfp1.0\n");
7332 shader_addline(&buffer, "TEMP index;\n");
7333
7334 /* { 255/256, 0.5/255*255/256, 0, 0 } */
7335 shader_addline(&buffer, "PARAM constants = { 0.996, 0.00195, 0, 0 };\n");
7336
7337 /* The alpha-component contains the palette index */
7338 shader_addline(&buffer, "TEX index, fragment.texcoord[0], texture[0], %s;\n", tex_target);
7339
7340 /* Scale the index by 255/256 and add a bias of '0.5' in order to sample in the middle */
7341 shader_addline(&buffer, "MAD index.a, index.a, constants.x, constants.y;\n");
7342
7343 /* Use the alpha-component as an index in the palette to get the final color */
7344 shader_addline(&buffer, "TEX result.color, index.a, texture[1], 1D;\n");
7345 shader_addline(&buffer, "END\n");
7346
7348
7350
7351 return shader;
7352}

Referenced by arbfp_blit_set().

◆ gen_planar_yuv_read()

static BOOL gen_planar_yuv_read ( struct wined3d_string_buffer buffer,
const struct arbfp_blit_type type,
char luminance 
)
static

Definition at line 6931 of file arb_program_shader.c.

6933{
6934 char chroma;
6935 const char *tex, *texinstr = "TXP";
6936
6937 if (type->fixup == COMPLEX_FIXUP_UYVY)
6938 {
6939 chroma = 'x';
6940 *luminance = 'w';
6941 }
6942 else
6943 {
6944 chroma = 'w';
6945 *luminance = 'x';
6946 }
6947
6948 tex = arbfp_texture_target(type->res_type);
6949 if (type->res_type == WINED3D_GL_RES_TYPE_TEX_RECT)
6950 texinstr = "TEX";
6951
6952 /* First we have to read the chroma values. This means we need at least two pixels(no filtering),
6953 * or 4 pixels(with filtering). To get the unmodified chromas, we have to rid ourselves of the
6954 * filtering when we sample the texture.
6955 *
6956 * These are the rules for reading the chroma:
6957 *
6958 * Even pixel: Cr
6959 * Even pixel: U
6960 * Odd pixel: V
6961 *
6962 * So we have to get the sampling x position in non-normalized coordinates in integers
6963 */
6964 if (type->res_type != WINED3D_GL_RES_TYPE_TEX_RECT)
6965 {
6966 shader_addline(buffer, "MUL texcrd.xy, fragment.texcoord[0], size.x;\n");
6967 shader_addline(buffer, "MOV texcrd.w, size.x;\n");
6968 }
6969 else
6970 {
6971 shader_addline(buffer, "MOV texcrd, fragment.texcoord[0];\n");
6972 }
6973 /* We must not allow filtering between pixel x and x+1, this would mix U and V
6974 * Vertical filtering is ok. However, bear in mind that the pixel center is at
6975 * 0.5, so add 0.5.
6976 */
6977 shader_addline(buffer, "FLR texcrd.x, texcrd.x;\n");
6978 shader_addline(buffer, "ADD texcrd.x, texcrd.x, coef.y;\n");
6979
6980 /* Divide the x coordinate by 0.5 and get the fraction. This gives 0.25 and 0.75 for the
6981 * even and odd pixels respectively
6982 */
6983 shader_addline(buffer, "MUL texcrd2, texcrd, coef.y;\n");
6984 shader_addline(buffer, "FRC texcrd2, texcrd2;\n");
6985
6986 /* Sample Pixel 1 */
6987 shader_addline(buffer, "%s luminance, texcrd, texture[0], %s;\n", texinstr, tex);
6988
6989 /* Put the value into either of the chroma values */
6990 shader_addline(buffer, "SGE temp.x, texcrd2.x, coef.y;\n");
6991 shader_addline(buffer, "MUL chroma.x, luminance.%c, temp.x;\n", chroma);
6992 shader_addline(buffer, "SLT temp.x, texcrd2.x, coef.y;\n");
6993 shader_addline(buffer, "MUL chroma.y, luminance.%c, temp.x;\n", chroma);
6994
6995 /* Sample pixel 2. If we read an even pixel(SLT above returned 1), sample
6996 * the pixel right to the current one. Otherwise, sample the left pixel.
6997 * Bias and scale the SLT result to -1;1 and add it to the texcrd.x.
6998 */
6999 shader_addline(buffer, "MAD temp.x, temp.x, coef.z, -coef.x;\n");
7000 shader_addline(buffer, "ADD texcrd.x, texcrd, temp.x;\n");
7001 shader_addline(buffer, "%s luminance, texcrd, texture[0], %s;\n", texinstr, tex);
7002
7003 /* Put the value into the other chroma */
7004 shader_addline(buffer, "SGE temp.x, texcrd2.x, coef.y;\n");
7005 shader_addline(buffer, "MAD chroma.y, luminance.%c, temp.x, chroma.y;\n", chroma);
7006 shader_addline(buffer, "SLT temp.x, texcrd2.x, coef.y;\n");
7007 shader_addline(buffer, "MAD chroma.x, luminance.%c, temp.x, chroma.x;\n", chroma);
7008
7009 /* TODO: If filtering is enabled, sample a 2nd pair of pixels left or right of
7010 * the current one and lerp the two U and V values
7011 */
7012
7013 /* This gives the correctly filtered luminance value */
7014 shader_addline(buffer, "TEX luminance, fragment.texcoord[0], texture[0], %s;\n", tex);
7015
7016 return TRUE;
7017}

Referenced by gen_yuv_shader().

◆ gen_yuv_shader()

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

Definition at line 7392 of file arb_program_shader.c.

7393{
7394 GLuint shader;
7396 char luminance_component;
7397
7398 if (type->use_color_key)
7399 FIXME("Implement YUV color keying.\n");
7400
7401 /* Shader header */
7403 {
7404 ERR("Failed to initialize shader buffer.\n");
7405 return 0;
7406 }
7407
7408 GL_EXTCALL(glGenProgramsARB(1, &shader));
7409 checkGLcall("GL_EXTCALL(glGenProgramsARB(1, &shader))");
7410 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader));
7411 checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader)");
7412 if (!shader)
7413 {
7415 return 0;
7416 }
7417
7418 /* The YUY2 and UYVY formats contain two pixels packed into a 32 bit macropixel,
7419 * giving effectively 16 bit per pixel. The color consists of a luminance(Y) and
7420 * two chroma(U and V) values. Each macropixel has two luminance values, one for
7421 * each single pixel it contains, and one U and one V value shared between both
7422 * pixels.
7423 *
7424 * The data is loaded into an A8L8 texture. With YUY2, the luminance component
7425 * contains the luminance and alpha the chroma. With UYVY it is vice versa. Thus
7426 * take the format into account when generating the read swizzles
7427 *
7428 * Reading the Y value is straightforward - just sample the texture. The hardware
7429 * takes care of filtering in the horizontal and vertical direction.
7430 *
7431 * Reading the U and V values is harder. We have to avoid filtering horizontally,
7432 * because that would mix the U and V values of one pixel or two adjacent pixels.
7433 * Thus floor the texture coordinate and add 0.5 to get an unfiltered read,
7434 * regardless of the filtering setting. Vertical filtering works automatically
7435 * though - the U and V values of two rows are mixed nicely.
7436 *
7437 * Apart of avoiding filtering issues, the code has to know which value it just
7438 * read, and where it can find the other one. To determine this, it checks if
7439 * it sampled an even or odd pixel, and shifts the 2nd read accordingly.
7440 *
7441 * Handling horizontal filtering of U and V values requires reading a 2nd pair
7442 * of pixels, extracting U and V and mixing them. This is not implemented yet.
7443 *
7444 * An alternative implementation idea is to load the texture as A8R8G8B8 texture,
7445 * with width / 2. This way one read gives all 3 values, finding U and V is easy
7446 * in an unfiltered situation. Finding the luminance on the other hand requires
7447 * finding out if it is an odd or even pixel. The real drawback of this approach
7448 * is filtering. This would have to be emulated completely in the shader, reading
7449 * up two 2 packed pixels in up to 2 rows and interpolating both horizontally and
7450 * vertically. Beyond that it would require adjustments to the texture handling
7451 * code to deal with the width scaling
7452 */
7453 shader_addline(&buffer, "!!ARBfp1.0\n");
7454 shader_addline(&buffer, "TEMP luminance;\n");
7455 shader_addline(&buffer, "TEMP temp;\n");
7456 shader_addline(&buffer, "TEMP chroma;\n");
7457 shader_addline(&buffer, "TEMP texcrd;\n");
7458 shader_addline(&buffer, "TEMP texcrd2;\n");
7459 shader_addline(&buffer, "PARAM coef = {1.0, 0.5, 2.0, 0.25};\n");
7460 shader_addline(&buffer, "PARAM yuv_coef = {1.403, 0.344, 0.714, 1.770};\n");
7461 shader_addline(&buffer, "PARAM size = program.local[%u];\n", ARBFP_BLIT_PARAM_SIZE);
7462
7463 switch (type->fixup)
7464 {
7465 case COMPLEX_FIXUP_UYVY:
7466 case COMPLEX_FIXUP_YUY2:
7467 if (!gen_planar_yuv_read(&buffer, type, &luminance_component))
7468 {
7470 return 0;
7471 }
7472 break;
7473
7474 case COMPLEX_FIXUP_YV12:
7475 if (!gen_yv12_read(&buffer, type, &luminance_component))
7476 {
7478 return 0;
7479 }
7480 break;
7481
7482 case COMPLEX_FIXUP_NV12:
7483 if (!gen_nv12_read(&buffer, type, &luminance_component))
7484 {
7486 return 0;
7487 }
7488 break;
7489
7490 default:
7491 FIXME("Unsupported YUV fixup %#x\n", type->fixup);
7493 return 0;
7494 }
7495
7496 /* Calculate the final result. Formula is taken from
7497 * http://www.fourcc.org/fccyvrgb.php. Note that the chroma
7498 * ranges from -0.5 to 0.5
7499 */
7500 shader_addline(&buffer, "SUB chroma.xy, chroma, coef.y;\n");
7501
7502 shader_addline(&buffer, "MAD result.color.x, chroma.x, yuv_coef.x, luminance.%c;\n", luminance_component);
7503 shader_addline(&buffer, "MAD temp.x, -chroma.y, yuv_coef.y, luminance.%c;\n", luminance_component);
7504 shader_addline(&buffer, "MAD result.color.y, -chroma.x, yuv_coef.z, temp.x;\n");
7505 shader_addline(&buffer, "MAD result.color.z, chroma.y, yuv_coef.w, luminance.%c;\n", luminance_component);
7506 shader_addline(&buffer, "END\n");
7507
7509
7511
7512 return shader;
7513}
static BOOL gen_yv12_read(struct wined3d_string_buffer *buffer, const struct arbfp_blit_type *type, char *luminance)
static BOOL gen_nv12_read(struct wined3d_string_buffer *buffer, const struct arbfp_blit_type *type, char *luminance)
static BOOL gen_planar_yuv_read(struct wined3d_string_buffer *buffer, const struct arbfp_blit_type *type, char *luminance)

Referenced by arbfp_blit_set().

◆ gen_yv12_read()

static BOOL gen_yv12_read ( struct wined3d_string_buffer buffer,
const struct arbfp_blit_type type,
char luminance 
)
static

Definition at line 7019 of file arb_program_shader.c.

7021{
7022 const char *tex;
7023 static const float yv12_coef[]
7024 = {2.0f / 3.0f, 1.0f / 6.0f, (2.0f / 3.0f) + (1.0f / 6.0f), 1.0f / 3.0f};
7025
7026 tex = arbfp_texture_target(type->res_type);
7027
7028 /* YV12 surfaces contain a WxH sized luminance plane, followed by a (W/2)x(H/2)
7029 * V and a (W/2)x(H/2) U plane, each with 8 bit per pixel. So the effective
7030 * bitdepth is 12 bits per pixel. Since the U and V planes have only half the
7031 * pitch of the luminance plane, the packing into the gl texture is a bit
7032 * unfortunate. If the whole texture is interpreted as luminance data it looks
7033 * approximately like this:
7034 *
7035 * +----------------------------------+----
7036 * | |
7037 * | |
7038 * | |
7039 * | |
7040 * | | 2
7041 * | LUMINANCE | -
7042 * | | 3
7043 * | |
7044 * | |
7045 * | |
7046 * | |
7047 * +----------------+-----------------+----
7048 * | | |
7049 * | V even rows | V odd rows |
7050 * | | | 1
7051 * +----------------+------------------ -
7052 * | | | 3
7053 * | U even rows | U odd rows |
7054 * | | |
7055 * +----------------+-----------------+----
7056 * | | |
7057 * | 0.5 | 0.5 |
7058 *
7059 * So it appears as if there are 4 chroma images, but in fact the odd rows
7060 * in the chroma images are in the same row as the even ones. So it is
7061 * kinda tricky to read
7062 *
7063 * When reading from rectangle textures, keep in mind that the input y coordinates
7064 * go from 0 to d3d_height, whereas the opengl texture height is 1.5 * d3d_height
7065 */
7066 shader_addline(buffer, "PARAM yv12_coef = ");
7068 shader_addline(buffer, ";\n");
7069
7070 shader_addline(buffer, "MOV texcrd, fragment.texcoord[0];\n");
7071 /* the chroma planes have only half the width */
7072 shader_addline(buffer, "MUL texcrd.x, texcrd.x, coef.y;\n");
7073
7074 /* The first value is between 2/3 and 5/6th of the texture's height, so scale+bias
7075 * the coordinate. Also read the right side of the image when reading odd lines
7076 *
7077 * Don't forget to clamp the y values in into the range, otherwise we'll get filtering
7078 * bleeding
7079 */
7080 if (type->res_type == WINED3D_GL_RES_TYPE_TEX_2D)
7081 {
7082
7083 shader_addline(buffer, "RCP chroma.w, size.y;\n");
7084
7085 shader_addline(buffer, "MUL texcrd2.y, texcrd.y, size.y;\n");
7086
7087 shader_addline(buffer, "FLR texcrd2.y, texcrd2.y;\n");
7088 shader_addline(buffer, "MAD texcrd.y, texcrd.y, yv12_coef.y, yv12_coef.x;\n");
7089
7090 /* Read odd lines from the right side(add size * 0.5 to the x coordinate */
7091 shader_addline(buffer, "ADD texcrd2.x, texcrd2.y, yv12_coef.y;\n"); /* To avoid 0.5 == 0.5 comparisons */
7092 shader_addline(buffer, "FRC texcrd2.x, texcrd2.x;\n");
7093 shader_addline(buffer, "SGE texcrd2.x, texcrd2.x, coef.y;\n");
7094 shader_addline(buffer, "MAD texcrd.x, texcrd2.x, coef.y, texcrd.x;\n");
7095
7096 /* clamp, keep the half pixel origin in mind */
7097 shader_addline(buffer, "MAD temp.y, coef.y, chroma.w, yv12_coef.x;\n");
7098 shader_addline(buffer, "MAX texcrd.y, temp.y, texcrd.y;\n");
7099 shader_addline(buffer, "MAD temp.y, -coef.y, chroma.w, yv12_coef.z;\n");
7100 shader_addline(buffer, "MIN texcrd.y, temp.y, texcrd.y;\n");
7101 }
7102 else
7103 {
7104 /* Read from [size - size+size/4] */
7105 shader_addline(buffer, "FLR texcrd.y, texcrd.y;\n");
7106 shader_addline(buffer, "MAD texcrd.y, texcrd.y, coef.w, size.y;\n");
7107
7108 /* Read odd lines from the right side(add size * 0.5 to the x coordinate */
7109 shader_addline(buffer, "ADD texcrd2.x, texcrd.y, yv12_coef.y;\n"); /* To avoid 0.5 == 0.5 comparisons */
7110 shader_addline(buffer, "FRC texcrd2.x, texcrd2.x;\n");
7111 shader_addline(buffer, "SGE texcrd2.x, texcrd2.x, coef.y;\n");
7112 shader_addline(buffer, "MUL texcrd2.x, texcrd2.x, size.x;\n");
7113 shader_addline(buffer, "MAD texcrd.x, texcrd2.x, coef.y, texcrd.x;\n");
7114
7115 /* Make sure to read exactly from the pixel center */
7116 shader_addline(buffer, "FLR texcrd.y, texcrd.y;\n");
7117 shader_addline(buffer, "ADD texcrd.y, texcrd.y, coef.y;\n");
7118
7119 /* Clamp */
7120 shader_addline(buffer, "MAD temp.y, size.y, coef.w, size.y;\n");
7121 shader_addline(buffer, "ADD temp.y, temp.y, -coef.y;\n");
7122 shader_addline(buffer, "MIN texcrd.y, temp.y, texcrd.y;\n");
7123 shader_addline(buffer, "ADD temp.y, size.y, coef.y;\n");
7124 shader_addline(buffer, "MAX texcrd.y, temp.y, texcrd.y;\n");
7125 }
7126 /* Read the texture, put the result into the output register */
7127 shader_addline(buffer, "TEX temp, texcrd, texture[0], %s;\n", tex);
7128 shader_addline(buffer, "MOV chroma.x, temp.w;\n");
7129
7130 /* The other chroma value is 1/6th of the texture lower, from 5/6th to 6/6th
7131 * No need to clamp because we're just reusing the already clamped value from above
7132 */
7133 if (type->res_type == WINED3D_GL_RES_TYPE_TEX_2D)
7134 shader_addline(buffer, "ADD texcrd.y, texcrd.y, yv12_coef.y;\n");
7135 else
7136 shader_addline(buffer, "MAD texcrd.y, size.y, coef.w, texcrd.y;\n");
7137 shader_addline(buffer, "TEX temp, texcrd, texture[0], %s;\n", tex);
7138 shader_addline(buffer, "MOV chroma.y, temp.w;\n");
7139
7140 /* Sample the luminance value. It is in the top 2/3rd of the texture, so scale the y coordinate.
7141 * Clamp the y coordinate to prevent the chroma values from bleeding into the sampled luminance
7142 * values due to filtering
7143 */
7144 shader_addline(buffer, "MOV texcrd, fragment.texcoord[0];\n");
7145 if (type->res_type == WINED3D_GL_RES_TYPE_TEX_2D)
7146 {
7147 /* Multiply the y coordinate by 2/3 and clamp it */
7148 shader_addline(buffer, "MUL texcrd.y, texcrd.y, yv12_coef.x;\n");
7149 shader_addline(buffer, "MAD temp.y, -coef.y, chroma.w, yv12_coef.x;\n");
7150 shader_addline(buffer, "MIN texcrd.y, temp.y, texcrd.y;\n");
7151 shader_addline(buffer, "TEX luminance, texcrd, texture[0], %s;\n", tex);
7152 }
7153 else
7154 {
7155 /* Reading from texture_rectangles is pretty straightforward, just use the unmodified
7156 * texture coordinate. It is still a good idea to clamp it though, since the opengl texture
7157 * is bigger
7158 */
7159 shader_addline(buffer, "ADD temp.x, size.y, -coef.y;\n");
7160 shader_addline(buffer, "MIN texcrd.y, texcrd.y, size.x;\n");
7161 shader_addline(buffer, "TEX luminance, texcrd, texture[0], %s;\n", tex);
7162 }
7163 *luminance = 'a';
7164
7165 return TRUE;
7166}

Referenced by gen_yuv_shader().

◆ get_argreg()

static const char * get_argreg ( struct wined3d_string_buffer buffer,
DWORD  argnum,
unsigned int  stage,
DWORD  arg 
)
static

Definition at line 6016 of file arb_program_shader.c.

6017{
6018 const char *ret;
6019
6020 if(arg == ARG_UNUSED) return "unused"; /* This is the marker for unused registers */
6021
6022 switch(arg & WINED3DTA_SELECTMASK) {
6023 case WINED3DTA_DIFFUSE:
6024 ret = "fragment.color.primary"; break;
6025
6026 case WINED3DTA_CURRENT:
6027 ret = "ret";
6028 break;
6029
6030 case WINED3DTA_TEXTURE:
6031 switch(stage) {
6032 case 0: ret = "tex0"; break;
6033 case 1: ret = "tex1"; break;
6034 case 2: ret = "tex2"; break;
6035 case 3: ret = "tex3"; break;
6036 case 4: ret = "tex4"; break;
6037 case 5: ret = "tex5"; break;
6038 case 6: ret = "tex6"; break;
6039 case 7: ret = "tex7"; break;
6040 default: ret = "unknown texture";
6041 }
6042 break;
6043
6044 case WINED3DTA_TFACTOR:
6045 ret = "tfactor"; break;
6046
6047 case WINED3DTA_SPECULAR:
6048 ret = "fragment.color.secondary"; break;
6049
6050 case WINED3DTA_TEMP:
6051 ret = "tempreg"; break;
6052
6053 case WINED3DTA_CONSTANT:
6054 switch(stage) {
6055 case 0: ret = "const0"; break;
6056 case 1: ret = "const1"; break;
6057 case 2: ret = "const2"; break;
6058 case 3: ret = "const3"; break;
6059 case 4: ret = "const4"; break;
6060 case 5: ret = "const5"; break;
6061 case 6: ret = "const6"; break;
6062 case 7: ret = "const7"; break;
6063 default: ret = "unknown constant";
6064 }
6065 break;
6066
6067 default:
6068 return "unknown";
6069 }
6070
6072 shader_addline(buffer, "SUB arg%u, const.x, %s;\n", argnum, ret);
6073 if(argnum == 0) ret = "arg0";
6074 if(argnum == 1) ret = "arg1";
6075 if(argnum == 2) ret = "arg2";
6076 }
6078 shader_addline(buffer, "MOV arg%u, %s.w;\n", argnum, ret);
6079 if(argnum == 0) ret = "arg0";
6080 if(argnum == 1) ret = "arg1";
6081 if(argnum == 2) ret = "arg2";
6082 }
6083 return ret;
6084}
#define WINED3DTA_SPECULAR
Definition: wined3d.h:871
#define WINED3DTA_COMPLEMENT
Definition: wined3d.h:874
#define WINED3DTA_ALPHAREPLICATE
Definition: wined3d.h:875
#define ARG_UNUSED

Referenced by gen_ffp_instr().

◆ get_bool_const()

static BOOL get_bool_const ( const struct wined3d_shader_instruction ins,
const struct wined3d_shader shader,
DWORD  idx 
)
static

Definition at line 5253 of file arb_program_shader.c.

5255{
5256 const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps;
5257 BOOL vshader = shader_is_vshader_version(reg_maps->shader_version.type);
5258 const struct