ReactOS 0.4.16-dev-109-gf4cb10f
state.c File Reference
#include "config.h"
#include "wine/port.h"
#include <stdio.h>
#include "wined3d_private.h"
Include dependency graph for state.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d)
 
 WINE_DECLARE_DEBUG_CHANNEL (d3d_shader)
 
 void (WINE_GLAPI *glDisableWINE)(GLenum cap)
 
ULONG CDECL wined3d_blend_state_incref (struct wined3d_blend_state *state)
 
static void wined3d_blend_state_destroy_object (void *object)
 
ULONG CDECL wined3d_blend_state_decref (struct wined3d_blend_state *state)
 
void *CDECL wined3d_blend_state_get_parent (const struct wined3d_blend_state *state)
 
HRESULT CDECL wined3d_blend_state_create (struct wined3d_device *device, const struct wined3d_blend_state_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_blend_state **state)
 
ULONG CDECL wined3d_rasterizer_state_incref (struct wined3d_rasterizer_state *state)
 
static void wined3d_rasterizer_state_destroy_object (void *object)
 
ULONG CDECL wined3d_rasterizer_state_decref (struct wined3d_rasterizer_state *state)
 
void *CDECL wined3d_rasterizer_state_get_parent (const struct wined3d_rasterizer_state *state)
 
HRESULT CDECL wined3d_rasterizer_state_create (struct wined3d_device *device, const struct wined3d_rasterizer_state_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_rasterizer_state **state)
 
static void state_undefined (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
void state_nop (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_fillmode (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_lighting (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_zenable (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_cullmode (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
void state_shademode (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_ditherenable (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_zwriteenable (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
GLenum wined3d_gl_compare_func (enum wined3d_cmp_func f)
 
static void state_zfunc (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_ambient (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_blendop_w (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static GLenum gl_blend_op (const struct wined3d_gl_info *gl_info, enum wined3d_blend_op op)
 
static void state_blendop (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static GLenum gl_blend_factor (enum wined3d_blend factor, const struct wined3d_format *dst_format)
 
static void gl_blend_from_d3d (GLenum *src_blend, GLenum *dst_blend, enum wined3d_blend d3d_src_blend, enum wined3d_blend d3d_dst_blend, const struct wined3d_format *rt_format)
 
static void state_blend (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_blendfactor_w (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_blendfactor (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_blend_object (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
void state_alpha_test (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
void state_clipping (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_specularenable (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_texfactor (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void renderstate_stencil_twosided (struct wined3d_context *context, GLint face, GLint func, GLint ref, GLuint mask, GLint stencilFail, GLint depthFail, GLint stencilPass)
 
static GLenum gl_stencil_op (enum wined3d_stencil_op op)
 
static void state_stencil (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_stencilwrite2s (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_stencilwrite (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_fog_vertexpart (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
void state_fogstartend (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
void state_fog_fragpart (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
void state_fogcolor (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
void state_fogdensity (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_colormat (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_linepattern (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_linepattern_w (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_normalize (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_psizemin_w (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_psizemin_ext (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_psizemin_arb (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_pscale (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_debug_monitor (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_colorwrite (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void set_color_mask (const struct wined3d_gl_info *gl_info, UINT index, DWORD mask)
 
static void state_colorwrite_i (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_localviewer (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_lastpixel (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
void state_pointsprite_w (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
void state_pointsprite (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_wrap (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_msaa_w (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_msaa (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_line_antialias (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_scissor (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_depthbias (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_depthclip (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_depthclip_w (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_zvisible (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_stippledalpha (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_antialias (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_multisampmask (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_patchedgestyle (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_patchsegments (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_positiondegree (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_normaldegree (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_tessellation (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_nvdb (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_wrapu (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_wrapv (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_monoenable (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_rop2 (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_planemask (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_subpixel (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_subpixelx (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_stippleenable (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_mipmaplodbias (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_anisotropy (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_flushbatch (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_translucentsi (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_extents (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_ckeyblend (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_swvp (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void get_src_and_opr (DWORD arg, BOOL is_alpha, GLenum *source, GLenum *operand)
 
static void set_tex_op (const struct wined3d_gl_info *gl_info, const struct wined3d_state *state, BOOL isAlpha, int Stage, enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3)
 
static void tex_colorop (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
void tex_alphaop (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void transform_texture (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void unload_tex_coords (const struct wined3d_gl_info *gl_info)
 
static void load_tex_coords (const struct wined3d_context *context, const struct wined3d_stream_info *si, GLuint *curVBO, const struct wined3d_state *state)
 
static void tex_coordindex (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void sampler_texmatrix (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static enum wined3d_texture_address wined3d_texture_address_mode (const struct wined3d_texture *texture, enum wined3d_texture_address t)
 
static void wined3d_sampler_desc_from_sampler_states (struct wined3d_sampler_desc *desc, const struct wined3d_context *context, const DWORD *sampler_states, const struct wined3d_texture *texture)
 
static void sampler (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
void apply_pixelshader (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_compute_shader (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_shader (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void shader_bumpenv (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void transform_world (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
void clipplane (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void transform_worldex (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_vertexblend_w (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_vertexblend (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void transform_view (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void transform_projection (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void unload_vertex_data (const struct wined3d_gl_info *gl_info)
 
static void unload_numbered_array (struct wined3d_context *context, int i)
 
static void unload_numbered_arrays (struct wined3d_context *context)
 
static void load_numbered_arrays (struct wined3d_context *context, const struct wined3d_stream_info *stream_info, const struct wined3d_state *state)
 
static void load_vertex_data (struct wined3d_context *context, const struct wined3d_stream_info *si, const struct wined3d_state *state)
 
static void streamsrc (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void vdecl_miscpart (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void vertexdeclaration (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void get_viewport (struct wined3d_context *context, const struct wined3d_state *state, struct wined3d_viewport *viewport)
 
static void viewport_miscpart (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void viewport_miscpart_cc (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void viewport_vertexpart (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void light (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void scissorrect (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void indexbuffer (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void frontface (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void frontface_cc (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void psorigin_w (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void psorigin (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
void state_srgbwrite (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_cb (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_cb_warn (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_shader_resource_binding (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_cs_resource_binding (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_uav_binding (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_cs_uav_binding (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_uav_warn (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_so (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void state_so_warn (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void ffp_enable (const struct wined3d_gl_info *gl_info, BOOL enable)
 
static voidffp_alloc (const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv)
 
static void ffp_free (struct wined3d_device *device)
 
static void vp_ffp_get_caps (const struct wined3d_gl_info *gl_info, struct wined3d_vertex_caps *caps)
 
static DWORD vp_ffp_get_emul_mask (const struct wined3d_gl_info *gl_info)
 
static void ffp_fragment_get_caps (const struct wined3d_gl_info *gl_info, struct fragment_caps *caps)
 
static DWORD ffp_fragment_get_emul_mask (const struct wined3d_gl_info *gl_info)
 
static BOOL ffp_color_fixup_supported (struct color_fixup_desc fixup)
 
static BOOL ffp_none_context_alloc (struct wined3d_context *context)
 
static void ffp_none_context_free (struct wined3d_context *context)
 
static void none_enable (const struct wined3d_gl_info *gl_info, BOOL enable)
 
static voidnone_alloc (const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv)
 
static void none_free (struct wined3d_device *device)
 
static void vp_none_get_caps (const struct wined3d_gl_info *gl_info, struct wined3d_vertex_caps *caps)
 
static DWORD vp_none_get_emul_mask (const struct wined3d_gl_info *gl_info)
 
static void fp_none_get_caps (const struct wined3d_gl_info *gl_info, struct fragment_caps *caps)
 
static DWORD fp_none_get_emul_mask (const struct wined3d_gl_info *gl_info)
 
static BOOL fp_none_color_fixup_supported (struct color_fixup_desc fixup)
 
static unsigned int num_handlers (const APPLYSTATEFUNC *funcs)
 
static void multistate_apply_2 (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void multistate_apply_3 (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
static void prune_invalid_states (struct StateEntry *state_table, const struct wined3d_gl_info *gl_info, const struct wined3d_d3d_info *d3d_info)
 
static void validate_state_table (struct StateEntry *state_table)
 
HRESULT compile_state_table (struct StateEntry *StateTable, APPLYSTATEFUNC **dev_multistate_funcs, const struct wined3d_gl_info *gl_info, const struct wined3d_d3d_info *d3d_info, const struct wined3d_vertex_pipe_ops *vertex, const struct fragment_pipeline *fragment, const struct StateEntryTemplate *misc)
 

Variables

const struct StateEntryTemplate misc_state_template []
 
static const struct StateEntryTemplate vp_ffp_states []
 
static const struct StateEntryTemplate ffp_fragmentstate_template []
 
const struct wined3d_vertex_pipe_ops ffp_vertex_pipe
 
const struct fragment_pipeline ffp_fragment_pipeline
 
const struct wined3d_vertex_pipe_ops none_vertex_pipe
 
const struct fragment_pipeline none_fragment_pipe
 

Function Documentation

◆ apply_pixelshader()

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

Definition at line 3759 of file state.c.

3760{
3761 unsigned int i;
3762
3763 if (use_ps(state))
3764 {
3765 if (!context->last_was_pshader)
3766 {
3767 /* Former draw without a pixel shader, some samplers may be
3768 * disabled because of WINED3D_TSS_COLOR_OP = WINED3DTOP_DISABLE
3769 * make sure to enable them. */
3770 for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
3771 {
3774 }
3775 context->last_was_pshader = TRUE;
3776 }
3777 else
3778 {
3779 /* Otherwise all samplers were activated by the code above in
3780 * earlier draws, or by sampler() if a different texture was
3781 * bound. I don't have to do anything. */
3782 }
3783 }
3784 else
3785 {
3786 /* Disabled the pixel shader - color ops weren't applied while it was
3787 * enabled, so re-apply them. */
3788 for (i = 0; i < context->d3d_info->limits.ffp_blend_stages; ++i)
3789 {
3792 }
3793 context->last_was_pshader = FALSE;
3794 }
3795
3796 context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_PIXEL;
3797}
static int state
Definition: maze.c:121
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLuint sampler
Definition: glext.h:7283
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: http.c:7252
@ WINED3D_TSS_COLOR_OP
Definition: wined3d.h:575
static void context_apply_state(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
#define MAX_FRAGMENT_SAMPLERS
#define STATE_SAMPLER(num)
@ WINED3D_SHADER_TYPE_PIXEL
static BOOL use_ps(const struct wined3d_state *state)
#define STATE_TEXTURESTAGE(stage, num)
static BOOL isStateDirty(const struct wined3d_context *context, DWORD state)

◆ clipplane()

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

Definition at line 3836 of file state.c.

3837{
3838 const struct wined3d_gl_info *gl_info = context->gl_info;
3839 UINT index = state_id - STATE_CLIPPLANE(0);
3840 GLdouble plane[4];
3841
3842 if (isStateDirty(context, STATE_TRANSFORM(WINED3D_TS_VIEW)) || index >= gl_info->limits.user_clip_distances)
3843 return;
3844
3845 gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW);
3846 gl_info->gl_ops.gl.p_glPushMatrix();
3847
3848 /* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */
3849 if (!use_vs(state))
3850 gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_VIEW]._11);
3851 else
3852 /* With vertex shaders, clip planes are not transformed in Direct3D,
3853 * while in OpenGL they are still transformed by the model view matrix. */
3854 gl_info->gl_ops.gl.p_glLoadIdentity();
3855
3856 plane[0] = state->clip_planes[index].x;
3857 plane[1] = state->clip_planes[index].y;
3858 plane[2] = state->clip_planes[index].z;
3859 plane[3] = state->clip_planes[index].w;
3860
3861 TRACE("Clipplane [%.8e, %.8e, %.8e, %.8e]\n",
3862 plane[0], plane[1], plane[2], plane[3]);
3863 gl_info->gl_ops.gl.p_glClipPlane(GL_CLIP_PLANE0 + index, plane);
3864 checkGLcall("glClipPlane");
3865
3866 gl_info->gl_ops.gl.p_glPopMatrix();
3867}
#define index(s, c)
Definition: various.h:29
#define GL_CLIP_PLANE0
Definition: gl.h:346
double GLdouble
Definition: gl.h:163
#define GL_MODELVIEW
Definition: gl.h:245
GLuint index
Definition: glext.h:6031
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum GLint const GLfloat GLenum GLint const GLushort GLint GLint GLsizei GLsizei GLenum GLsizei GLsizei GLenum GLenum const GLvoid GLenum plane
Definition: glfuncs.h:270
unsigned int UINT
Definition: ndis.h:50
#define TRACE(s)
Definition: solgame.cpp:4
struct opengl_funcs gl_ops
struct wined3d_gl_limits limits
@ WINED3D_TS_VIEW
Definition: wined3d.h:648
#define STATE_CLIPPLANE(a)
#define STATE_TRANSFORM(a)
static BOOL use_vs(const struct wined3d_state *state)
#define checkGLcall(A)

Referenced by glsl_vertex_pipe_vdecl(), glsl_vertex_pipe_view(), transform_view(), and vertexdeclaration().

◆ compile_state_table()

HRESULT compile_state_table ( struct StateEntry StateTable,
APPLYSTATEFUNC **  dev_multistate_funcs,
const struct wined3d_gl_info gl_info,
const struct wined3d_d3d_info d3d_info,
const struct wined3d_vertex_pipe_ops vertex,
const struct fragment_pipeline fragment,
const struct StateEntryTemplate misc 
)

Definition at line 6142 of file state.c.

6146{
6147 unsigned int i, type, handlers;
6148 APPLYSTATEFUNC multistate_funcs[STATE_HIGHEST + 1][3];
6149 const struct StateEntryTemplate *cur;
6150 BOOL set[STATE_HIGHEST + 1];
6151
6152 memset(multistate_funcs, 0, sizeof(multistate_funcs));
6153
6154 for(i = 0; i < STATE_HIGHEST + 1; i++) {
6155 StateTable[i].representative = 0;
6156 StateTable[i].apply = state_undefined;
6157 }
6158
6159 for(type = 0; type < 3; type++) {
6160 /* This switch decides the order in which the states are applied */
6161 switch(type) {
6162 case 0: cur = misc; break;
6163 case 1: cur = fragment->states; break;
6164 case 2: cur = vertex->vp_states; break;
6165 default: cur = NULL; /* Stupid compiler */
6166 }
6167 if(!cur) continue;
6168
6169 /* GL extension filtering should not prevent multiple handlers being applied from different
6170 * pipeline parts
6171 */
6172 memset(set, 0, sizeof(set));
6173
6174 for(i = 0; cur[i].state; i++) {
6175 APPLYSTATEFUNC *funcs_array;
6176
6177 /* Only use the first matching state with the available extension from one template.
6178 * e.g.
6179 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func1}, XYZ_FANCY},
6180 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func2}, 0 }
6181 *
6182 * if GL_XYZ_fancy is supported, ignore the 2nd line
6183 */
6184 if(set[cur[i].state]) continue;
6185 /* Skip state lines depending on unsupported extensions */
6186 if (!gl_info->supported[cur[i].extension]) continue;
6187 set[cur[i].state] = TRUE;
6188 /* In some cases having an extension means that nothing has to be
6189 * done for a state, e.g. if GL_ARB_texture_non_power_of_two is
6190 * supported, the texture coordinate fixup can be ignored. If the
6191 * apply function is used, mark the state set(done above) to prevent
6192 * applying later lines, but do not record anything in the state
6193 * table
6194 */
6195 if (!cur[i].content.representative) continue;
6196
6197 handlers = num_handlers(multistate_funcs[cur[i].state]);
6198 multistate_funcs[cur[i].state][handlers] = cur[i].content.apply;
6199 switch(handlers) {
6200 case 0:
6201 StateTable[cur[i].state].apply = cur[i].content.apply;
6202 break;
6203 case 1:
6204 StateTable[cur[i].state].apply = multistate_apply_2;
6205 if (!(dev_multistate_funcs[cur[i].state] = heap_calloc(2, sizeof(**dev_multistate_funcs))))
6206 goto out_of_mem;
6207
6208 dev_multistate_funcs[cur[i].state][0] = multistate_funcs[cur[i].state][0];
6209 dev_multistate_funcs[cur[i].state][1] = multistate_funcs[cur[i].state][1];
6210 break;
6211 case 2:
6212 StateTable[cur[i].state].apply = multistate_apply_3;
6213 if (!(funcs_array = heap_realloc(dev_multistate_funcs[cur[i].state],
6214 sizeof(**dev_multistate_funcs) * 3)))
6215 goto out_of_mem;
6216
6217 dev_multistate_funcs[cur[i].state] = funcs_array;
6218 dev_multistate_funcs[cur[i].state][2] = multistate_funcs[cur[i].state][2];
6219 break;
6220 default:
6221 ERR("Unexpected amount of state handlers for state %u: %u\n",
6222 cur[i].state, handlers + 1);
6223 }
6224
6225 if (StateTable[cur[i].state].representative
6226 && StateTable[cur[i].state].representative != cur[i].content.representative)
6227 {
6228 FIXME("State %s (%#x) has different representatives in different pipeline parts.\n",
6230 }
6231 StateTable[cur[i].state].representative = cur[i].content.representative;
6232 }
6233 }
6234
6235 prune_invalid_states(StateTable, gl_info, d3d_info);
6236 validate_state_table(StateTable);
6237
6238 return WINED3D_OK;
6239
6240out_of_mem:
6241 for (i = 0; i <= STATE_HIGHEST; ++i)
6242 {
6243 heap_free(dev_multistate_funcs[i]);
6244 }
6245
6246 memset(dev_multistate_funcs, 0, (STATE_HIGHEST + 1)*sizeof(*dev_multistate_funcs));
6247
6248 return E_OUTOFMEMORY;
6249}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:71
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
Definition: _set.h:50
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
static void validate_state_table(struct StateEntry *state_table)
Definition: state.c:6040
static void multistate_apply_2(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
Definition: state.c:5997
static void state_undefined(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
Definition: state.c:168
static void multistate_apply_3(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
Definition: state.c:6003
static void prune_invalid_states(struct StateEntry *state_table, const struct wined3d_gl_info *gl_info, const struct wined3d_d3d_info *d3d_info)
Definition: state.c:6010
static unsigned int num_handlers(const APPLYSTATEFUNC *funcs)
Definition: state.c:5990
const char * debug_d3dstate(DWORD state)
Definition: utils.c:4676
content
Definition: atl_ax.c:994
static xmlCharEncodingHandlerPtr * handlers
Definition: encoding.c:1317
unsigned int BOOL
Definition: ntddk_ex.h:94
FxCollectionEntry * cur
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static void * heap_calloc(SIZE_T count, SIZE_T size)
Definition: heap.h:49
#define memset(x, y, z)
Definition: compat.h:39
APPLYSTATEFUNC apply
DWORD representative
const struct StateEntryTemplate * states
Definition: mesh.c:4558
BOOL supported[WINED3D_GL_EXT_COUNT]
#define WINED3D_OK
Definition: wined3d.h:37
#define STATE_HIGHEST
void(* APPLYSTATEFUNC)(struct wined3d_context *ctx, const struct wined3d_state *state, DWORD state_id)

Referenced by device_init().

◆ ffp_alloc()

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

Definition at line 5817 of file state.c.

5818{
5819 return shader_priv;
5820}

◆ ffp_color_fixup_supported()

static BOOL ffp_color_fixup_supported ( struct color_fixup_desc  fixup)
static

Definition at line 5906 of file state.c.

5907{
5908 /* We only support identity conversions. */
5909 return is_identity_fixup(fixup);
5910}
static BOOL is_identity_fixup(struct color_fixup_desc fixup)

◆ ffp_enable()

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

Definition at line 5815 of file state.c.

5815{}

◆ ffp_fragment_get_caps()

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

Definition at line 5860 of file state.c.

5861{
5862 caps->wined3d_caps = 0;
5863 caps->PrimitiveMiscCaps = 0;
5873
5877 {
5884 }
5887 {
5893 }
5894 if (gl_info->supported[ARB_TEXTURE_ENV_DOT3])
5896
5897 caps->MaxTextureBlendStages = gl_info->limits.textures;
5898 caps->MaxSimultaneousTextures = gl_info->limits.textures;
5899}
DWORD MaxSimultaneousTextures
DWORD MaxTextureBlendStages
#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_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_ADDSIGNED2X
Definition: wined3d.h:1153
#define WINED3DTEXOPCAPS_MODULATE4X
Definition: wined3d.h:1150
#define WINED3DTEXOPCAPS_ADDSMOOTH
Definition: wined3d.h:1155
#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_BLENDCURRENTALPHA
Definition: wined3d.h:1160
@ ARB_TEXTURE_ENV_COMBINE
Definition: wined3d_gl.h:115
@ NV_TEXTURE_ENV_COMBINE4
Definition: wined3d_gl.h:197
@ ATI_TEXTURE_ENV_COMBINE3
Definition: wined3d_gl.h:147
@ ARB_TEXTURE_ENV_DOT3
Definition: wined3d_gl.h:116
@ EXT_TEXTURE_ENV_COMBINE
Definition: wined3d_gl.h:175

◆ ffp_fragment_get_emul_mask()

static DWORD ffp_fragment_get_emul_mask ( const struct wined3d_gl_info gl_info)
static

Definition at line 5901 of file state.c.

5902{
5904}
#define GL_EXT_EMUL_EXT_FOG_COORD
#define GL_EXT_EMUL_ARB_MULTITEXTURE

◆ ffp_free()

static void ffp_free ( struct wined3d_device device)
static

Definition at line 5822 of file state.c.

5822{}

◆ ffp_none_context_alloc()

static BOOL ffp_none_context_alloc ( struct wined3d_context context)
static

Definition at line 5912 of file state.c.

5913{
5914 return TRUE;
5915}

◆ ffp_none_context_free()

static void ffp_none_context_free ( struct wined3d_context context)
static

Definition at line 5917 of file state.c.

5918{
5919}

◆ fp_none_color_fixup_supported()

static BOOL fp_none_color_fixup_supported ( struct color_fixup_desc  fixup)
static

Definition at line 5972 of file state.c.

5973{
5974 return is_identity_fixup(fixup);
5975}

◆ fp_none_get_caps()

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

Definition at line 5962 of file state.c.

5963{
5964 memset(caps, 0, sizeof(*caps));
5965}

◆ fp_none_get_emul_mask()

static DWORD fp_none_get_emul_mask ( const struct wined3d_gl_info gl_info)
static

Definition at line 5967 of file state.c.

5968{
5969 return 0;
5970}

◆ frontface()

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

Definition at line 4944 of file state.c.

4945{
4946 const struct wined3d_gl_info *gl_info = context->gl_info;
4947 GLenum mode;
4948
4949 mode = state->rasterizer_state && state->rasterizer_state->desc.front_ccw ? GL_CCW : GL_CW;
4950 if (context->render_offscreen)
4951 mode = (mode == GL_CW) ? GL_CCW : GL_CW;
4952
4953 gl_info->gl_ops.gl.p_glFrontFace(mode);
4954 checkGLcall("glFrontFace");
4955}
#define GL_CW
Definition: gl.h:268
unsigned int GLenum
Definition: gl.h:150
#define GL_CCW
Definition: gl.h:269
GLenum mode
Definition: glext.h:6217

◆ frontface_cc()

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

Definition at line 4957 of file state.c.

4958{
4959 const struct wined3d_gl_info *gl_info = context->gl_info;
4960 GLenum mode;
4961
4962 mode = state->rasterizer_state && state->rasterizer_state->desc.front_ccw ? GL_CCW : GL_CW;
4963
4964 gl_info->gl_ops.gl.p_glFrontFace(mode);
4965 checkGLcall("glFrontFace");
4966}

◆ get_src_and_opr()

static void get_src_and_opr ( DWORD  arg,
BOOL  is_alpha,
GLenum source,
GLenum operand 
)
static

Definition at line 2064 of file state.c.

2064 {
2065 /* The WINED3DTA_ALPHAREPLICATE flag specifies the alpha component of the
2066 * input should be used for all input components. The WINED3DTA_COMPLEMENT
2067 * flag specifies the complement of the input should be used. */
2068 BOOL from_alpha = is_alpha || arg & WINED3DTA_ALPHAREPLICATE;
2069 BOOL complement = arg & WINED3DTA_COMPLEMENT;
2070
2071 /* Calculate the operand */
2072 if (complement) {
2073 if (from_alpha) *operand = GL_ONE_MINUS_SRC_ALPHA;
2074 else *operand = GL_ONE_MINUS_SRC_COLOR;
2075 } else {
2076 if (from_alpha) *operand = GL_SRC_ALPHA;
2077 else *operand = GL_SRC_COLOR;
2078 }
2079
2080 /* Calculate the source */
2081 switch (arg & WINED3DTA_SELECTMASK) {
2084 case WINED3DTA_TEXTURE: *source = GL_TEXTURE; break;
2086 case WINED3DTA_SPECULAR:
2087 /*
2088 * According to the GL_ARB_texture_env_combine specs, SPECULAR is
2089 * 'Secondary color' and isn't supported until base GL supports it
2090 * There is no concept of temp registers as far as I can tell
2091 */
2092 FIXME("Unhandled texture arg WINED3DTA_SPECULAR\n");
2093 *source = GL_TEXTURE;
2094 break;
2095 default:
2096 FIXME("Unrecognized texture arg %#x\n", arg);
2097 *source = GL_TEXTURE;
2098 break;
2099 }
2100}
#define GL_TEXTURE
Definition: gl.h:247
#define GL_SRC_ALPHA
Definition: gl.h:378
#define GL_SRC_COLOR
Definition: gl.h:376
#define GL_ONE_MINUS_SRC_ALPHA
Definition: gl.h:379
#define GL_ONE_MINUS_SRC_COLOR
Definition: gl.h:377
#define GL_CONSTANT_EXT
Definition: glext.h:3235
#define GL_PRIMARY_COLOR_EXT
Definition: glext.h:3236
#define GL_PREVIOUS_EXT
Definition: glext.h:3237
#define is_alpha(c)
Definition: main.cpp:28
#define WINED3DTA_SPECULAR
Definition: wined3d.h:871
#define WINED3DTA_COMPLEMENT
Definition: wined3d.h:874
#define WINED3DTA_SELECTMASK
Definition: wined3d.h:866
#define WINED3DTA_TFACTOR
Definition: wined3d.h:870
#define WINED3DTA_CURRENT
Definition: wined3d.h:868
#define WINED3DTA_ALPHAREPLICATE
Definition: wined3d.h:875
#define WINED3DTA_DIFFUSE
Definition: wined3d.h:867
#define WINED3DTA_TEXTURE
Definition: wined3d.h:869

Referenced by set_tex_op().

◆ get_viewport()

static void get_viewport ( struct wined3d_context context,
const struct wined3d_state state,
struct wined3d_viewport viewport 
)
static

Definition at line 4688 of file state.c.

4690{
4691 const struct wined3d_rendertarget_view *depth_stencil = state->fb->depth_stencil;
4692 const struct wined3d_rendertarget_view *target = state->fb->render_targets[0];
4693 unsigned int width, height;
4694
4695 *viewport = state->viewport;
4696
4697 if (target)
4698 {
4699 if (context->d3d_info->wined3d_creation_flags & WINED3D_LIMIT_VIEWPORT)
4700 {
4701 if (viewport->width > target->width)
4702 viewport->width = target->width;
4703 if (viewport->height > target->height)
4704 viewport->height = target->height;
4705 }
4706 }
4707
4708 /*
4709 * Note: GL requires lower left, DirectX supplies upper left. This is
4710 * reversed when using offscreen rendering.
4711 */
4712 if (context->render_offscreen)
4713 return;
4714
4715 if (target)
4716 {
4718 }
4719 else if (depth_stencil)
4720 {
4721 height = depth_stencil->height;
4722 }
4723 else
4724 {
4725 FIXME("Could not get the height of render targets.\n");
4726 return;
4727 }
4728
4729 viewport->y = height - (viewport->y + viewport->height);
4730}
void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarget_view *view, const struct wined3d_context *context, unsigned int *width, unsigned int *height)
Definition: view.c:404
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLenum target
Definition: glext.h:7315
#define WINED3D_LIMIT_VIEWPORT
Definition: wined3d.h:1330

Referenced by viewport_miscpart(), and viewport_miscpart_cc().

◆ gl_blend_factor()

static GLenum gl_blend_factor ( enum wined3d_blend  factor,
const struct wined3d_format dst_format 
)
static

Definition at line 457 of file state.c.

458{
459 switch (factor)
460 {
462 return GL_ZERO;
464 return GL_ONE;
466 return GL_SRC_COLOR;
470 return GL_SRC_ALPHA;
474 return GL_DST_COLOR;
477 /* To compensate for the lack of format switching with backbuffer
478 * offscreen rendering, and with onscreen rendering, we modify the
479 * alpha test parameters for (INV)DESTALPHA if the render target
480 * doesn't support alpha blending. A nonexistent alpha channel
481 * returns 1.0, so WINED3D_BLEND_DESTALPHA becomes GL_ONE, and
482 * WINED3D_BLEND_INVDESTALPHA becomes GL_ZERO. */
484 return dst_format->alpha_size ? GL_DST_ALPHA : GL_ONE;
486 return dst_format->alpha_size ? GL_ONE_MINUS_DST_ALPHA : GL_ZERO;
494 return GL_SRC1_COLOR;
498 return GL_SRC1_ALPHA;
501 default:
502 if (!factor)
503 WARN("Unhandled blend factor %#x.\n", factor);
504 else
505 FIXME("Unhandled blend factor %#x.\n", factor);
506 return GL_NONE;
507 }
508}
#define WARN(fmt,...)
Definition: precomp.h:61
#define GL_NONE
Definition: gl.h:465
#define GL_SRC_ALPHA_SATURATE
Definition: gl.h:384
#define GL_ONE_MINUS_DST_ALPHA
Definition: gl.h:381
#define GL_ONE_MINUS_DST_COLOR
Definition: gl.h:383
#define GL_ZERO
Definition: gl.h:374
#define GL_ONE
Definition: gl.h:375
#define GL_DST_ALPHA
Definition: gl.h:380
#define GL_DST_COLOR
Definition: gl.h:382
#define GL_CONSTANT_COLOR_EXT
Definition: glext.h:2407
#define GL_SRC1_ALPHA
Definition: glext.h:381
#define GL_ONE_MINUS_CONSTANT_COLOR_EXT
Definition: glext.h:2408
#define GL_SRC1_COLOR
Definition: glext.h:2002
#define GL_ONE_MINUS_SRC1_COLOR
Definition: glext.h:2004
#define GL_ONE_MINUS_SRC1_ALPHA
Definition: glext.h:2005
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 factor
Definition: glfuncs.h:178
static const char * dst_format
Definition: dib.c:1133
@ WINED3D_BLEND_ONE
Definition: wined3d.h:411
@ WINED3D_BLEND_INVDESTCOLOR
Definition: wined3d.h:419
@ WINED3D_BLEND_DESTCOLOR
Definition: wined3d.h:418
@ WINED3D_BLEND_INVSRCALPHA
Definition: wined3d.h:415
@ WINED3D_BLEND_INVSRCCOLOR
Definition: wined3d.h:413
@ WINED3D_BLEND_INVDESTALPHA
Definition: wined3d.h:417
@ WINED3D_BLEND_INVBLENDFACTOR
Definition: wined3d.h:424
@ WINED3D_BLEND_INVSRC1COLOR
Definition: wined3d.h:426
@ WINED3D_BLEND_SRC1ALPHA
Definition: wined3d.h:427
@ WINED3D_BLEND_ZERO
Definition: wined3d.h:410
@ WINED3D_BLEND_SRC1COLOR
Definition: wined3d.h:425
@ WINED3D_BLEND_SRCALPHA
Definition: wined3d.h:414
@ WINED3D_BLEND_SRCALPHASAT
Definition: wined3d.h:420
@ WINED3D_BLEND_BLENDFACTOR
Definition: wined3d.h:423
@ WINED3D_BLEND_INVSRC1ALPHA
Definition: wined3d.h:428
@ WINED3D_BLEND_SRCCOLOR
Definition: wined3d.h:412
@ WINED3D_BLEND_DESTALPHA
Definition: wined3d.h:416

Referenced by gl_blend_from_d3d().

◆ gl_blend_from_d3d()

static void gl_blend_from_d3d ( GLenum src_blend,
GLenum dst_blend,
enum wined3d_blend  d3d_src_blend,
enum wined3d_blend  d3d_dst_blend,
const struct wined3d_format rt_format 
)
static

Definition at line 510 of file state.c.

513{
514 /* WINED3D_BLEND_BOTHSRCALPHA and WINED3D_BLEND_BOTHINVSRCALPHA are legacy
515 * source blending values which are still valid up to d3d9. They should
516 * not occur as dest blend values. */
517 if (d3d_src_blend == WINED3D_BLEND_BOTHSRCALPHA)
518 {
519 *src_blend = GL_SRC_ALPHA;
520 *dst_blend = GL_ONE_MINUS_SRC_ALPHA;
521 }
522 else if (d3d_src_blend == WINED3D_BLEND_BOTHINVSRCALPHA)
523 {
524 *src_blend = GL_ONE_MINUS_SRC_ALPHA;
525 *dst_blend = GL_SRC_ALPHA;
526 }
527 else
528 {
529 *src_blend = gl_blend_factor(d3d_src_blend, rt_format);
530 *dst_blend = gl_blend_factor(d3d_dst_blend, rt_format);
531 }
532}
static GLenum gl_blend_factor(enum wined3d_blend factor, const struct wined3d_format *dst_format)
Definition: state.c:457
@ WINED3D_BLEND_BOTHINVSRCALPHA
Definition: wined3d.h:422
@ WINED3D_BLEND_BOTHSRCALPHA
Definition: wined3d.h:421

Referenced by state_blend().

◆ gl_blend_op()

static GLenum gl_blend_op ( const struct wined3d_gl_info gl_info,
enum wined3d_blend_op  op 
)
static

Definition at line 404 of file state.c.

405{
406 switch (op)
407 {
409 return GL_FUNC_ADD;
415 return gl_info->supported[EXT_BLEND_MINMAX] ? GL_MIN : GL_FUNC_ADD;
417 return gl_info->supported[EXT_BLEND_MINMAX] ? GL_MAX : GL_FUNC_ADD;
418 default:
419 if (!op)
420 WARN("Unhandled blend op %#x.\n", op);
421 else
422 FIXME("Unhandled blend op %#x.\n", op);
423 return GL_FUNC_ADD;
424 }
425}
UINT op
Definition: effect.c:236
#define GL_FUNC_REVERSE_SUBTRACT
Definition: gl.h:1628
#define GL_MIN
Definition: gl.h:1624
#define GL_FUNC_SUBTRACT
Definition: gl.h:1627
#define GL_MAX
Definition: gl.h:1625
#define GL_FUNC_ADD
Definition: gl.h:1626
@ WINED3D_BLEND_OP_ADD
Definition: wined3d.h:433
@ WINED3D_BLEND_OP_MIN
Definition: wined3d.h:436
@ WINED3D_BLEND_OP_MAX
Definition: wined3d.h:437
@ WINED3D_BLEND_OP_SUBTRACT
Definition: wined3d.h:434
@ WINED3D_BLEND_OP_REVSUBTRACT
Definition: wined3d.h:435
@ EXT_BLEND_MINMAX
Definition: wined3d_gl.h:153
@ EXT_BLEND_SUBTRACT
Definition: wined3d_gl.h:154

Referenced by state_blendop().

◆ gl_stencil_op()

static GLenum gl_stencil_op ( enum wined3d_stencil_op  op)
static

Definition at line 880 of file state.c.

881{
882 switch (op)
883 {
885 return GL_KEEP;
887 return GL_ZERO;
889 return GL_REPLACE;
891 return GL_INCR;
893 return GL_DECR;
895 return GL_INVERT;
897 return GL_INCR_WRAP;
899 return GL_DECR_WRAP;
900 default:
901 if (!op)
902 WARN("Unrecognized stencil op %#x.\n", op);
903 else
904 FIXME("Unrecognized stencil op %#x.\n", op);
905 return GL_KEEP;
906 }
907}
#define GL_DECR
Definition: gl.h:462
#define GL_INCR
Definition: gl.h:461
#define GL_REPLACE
Definition: gl.h:460
#define GL_INVERT
Definition: gl.h:435
#define GL_KEEP
Definition: gl.h:459
#define GL_DECR_WRAP
Definition: glext.h:297
#define GL_INCR_WRAP
Definition: glext.h:296
@ WINED3D_STENCIL_OP_INCR
Definition: wined3d.h:506
@ WINED3D_STENCIL_OP_KEEP
Definition: wined3d.h:500
@ WINED3D_STENCIL_OP_REPLACE
Definition: wined3d.h:502
@ WINED3D_STENCIL_OP_INVERT
Definition: wined3d.h:505
@ WINED3D_STENCIL_OP_DECR_SAT
Definition: wined3d.h:504
@ WINED3D_STENCIL_OP_DECR
Definition: wined3d.h:507
@ WINED3D_STENCIL_OP_ZERO
Definition: wined3d.h:501
@ WINED3D_STENCIL_OP_INCR_SAT
Definition: wined3d.h:503

Referenced by state_stencil().

◆ indexbuffer()

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

Definition at line 4928 of file state.c.

4929{
4930 const struct wined3d_stream_info *stream_info = &context->stream_info;
4931 const struct wined3d_gl_info *gl_info = context->gl_info;
4932
4933 if (!state->index_buffer || !stream_info->all_vbo)
4934 {
4935 GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
4936 }
4937 else
4938 {
4939 struct wined3d_buffer *ib = state->index_buffer;
4941 }
4942}
#define GL_ELEMENT_ARRAY_BUFFER
Definition: glext.h:337
static void stream_info(IStream *stream, HGLOBAL *hmem, int *size, int *pos)
#define GL_EXTCALL(f)

◆ light()

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

Definition at line 4779 of file state.c.

4780{
4781 const struct wined3d_gl_info *gl_info = context->gl_info;
4782 UINT Index = state_id - STATE_ACTIVELIGHT(0);
4783 const struct wined3d_light_info *lightInfo = state->lights[Index];
4784
4785 if (!lightInfo)
4786 {
4787 gl_info->gl_ops.gl.p_glDisable(GL_LIGHT0 + Index);
4788 checkGLcall("glDisable(GL_LIGHT0 + Index)");
4789 }
4790 else
4791 {
4792 float quad_att;
4793 float colRGBA[] = {0.0f, 0.0f, 0.0f, 0.0f};
4794
4795 /* Light settings are affected by the model view in OpenGL, the View transform in direct3d*/
4796 gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW);
4797 gl_info->gl_ops.gl.p_glPushMatrix();
4798 gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_VIEW]._11);
4799
4800 /* Diffuse: */
4801 colRGBA[0] = lightInfo->OriginalParms.diffuse.r;
4802 colRGBA[1] = lightInfo->OriginalParms.diffuse.g;
4803 colRGBA[2] = lightInfo->OriginalParms.diffuse.b;
4804 colRGBA[3] = lightInfo->OriginalParms.diffuse.a;
4805 gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + Index, GL_DIFFUSE, colRGBA);
4806 checkGLcall("glLightfv");
4807
4808 /* Specular */
4809 colRGBA[0] = lightInfo->OriginalParms.specular.r;
4810 colRGBA[1] = lightInfo->OriginalParms.specular.g;
4811 colRGBA[2] = lightInfo->OriginalParms.specular.b;
4812 colRGBA[3] = lightInfo->OriginalParms.specular.a;
4813 gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + Index, GL_SPECULAR, colRGBA);
4814 checkGLcall("glLightfv");
4815
4816 /* Ambient */
4817 colRGBA[0] = lightInfo->OriginalParms.ambient.r;
4818 colRGBA[1] = lightInfo->OriginalParms.ambient.g;
4819 colRGBA[2] = lightInfo->OriginalParms.ambient.b;
4820 colRGBA[3] = lightInfo->OriginalParms.ambient.a;
4821 gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + Index, GL_AMBIENT, colRGBA);
4822 checkGLcall("glLightfv");
4823
4824 if ((lightInfo->OriginalParms.range * lightInfo->OriginalParms.range) >= FLT_MIN)
4825 quad_att = 1.4f / (lightInfo->OriginalParms.range * lightInfo->OriginalParms.range);
4826 else
4827 quad_att = 0.0f; /* 0 or MAX? (0 seems to be ok) */
4828
4829 /* Do not assign attenuation values for lights that do not use them. D3D apps are free to pass any junk,
4830 * but gl drivers use them and may crash due to bad Attenuation values. Need for Speed most wanted sets
4831 * Attenuation0 to NaN and crashes in the gl lib
4832 */
4833
4834 switch (lightInfo->OriginalParms.type)
4835 {
4837 /* Position */
4838 gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + Index, GL_POSITION, &lightInfo->position.x);
4839 checkGLcall("glLightfv");
4840 gl_info->gl_ops.gl.p_glLightf(GL_LIGHT0 + Index, GL_SPOT_CUTOFF, lightInfo->cutoff);
4841 checkGLcall("glLightf");
4842 gl_info->gl_ops.gl.p_glLightf(GL_LIGHT0 + Index, GL_CONSTANT_ATTENUATION,
4843 lightInfo->OriginalParms.attenuation0);
4844 checkGLcall("glLightf");
4845 gl_info->gl_ops.gl.p_glLightf(GL_LIGHT0 + Index, GL_LINEAR_ATTENUATION,
4846 lightInfo->OriginalParms.attenuation1);
4847 checkGLcall("glLightf");
4848 if (quad_att < lightInfo->OriginalParms.attenuation2)
4849 quad_att = lightInfo->OriginalParms.attenuation2;
4850 gl_info->gl_ops.gl.p_glLightf(GL_LIGHT0 + Index, GL_QUADRATIC_ATTENUATION, quad_att);
4851 checkGLcall("glLightf");
4852 /* FIXME: Range */
4853 break;
4854
4855 case WINED3D_LIGHT_SPOT:
4856 /* Position */
4857 gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + Index, GL_POSITION, &lightInfo->position.x);
4858 checkGLcall("glLightfv");
4859 /* Direction */
4860 gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + Index, GL_SPOT_DIRECTION, &lightInfo->direction.x);
4861 checkGLcall("glLightfv");
4862 gl_info->gl_ops.gl.p_glLightf(GL_LIGHT0 + Index, GL_SPOT_EXPONENT, lightInfo->exponent);
4863 checkGLcall("glLightf");
4864 gl_info->gl_ops.gl.p_glLightf(GL_LIGHT0 + Index, GL_SPOT_CUTOFF, lightInfo->cutoff);
4865 checkGLcall("glLightf");
4866 gl_info->gl_ops.gl.p_glLightf(GL_LIGHT0 + Index, GL_CONSTANT_ATTENUATION,
4867 lightInfo->OriginalParms.attenuation0);
4868 checkGLcall("glLightf");
4869 gl_info->gl_ops.gl.p_glLightf(GL_LIGHT0 + Index, GL_LINEAR_ATTENUATION,
4870 lightInfo->OriginalParms.attenuation1);
4871 checkGLcall("glLightf");
4872 if (quad_att < lightInfo->OriginalParms.attenuation2)
4873 quad_att = lightInfo->OriginalParms.attenuation2;
4874 gl_info->gl_ops.gl.p_glLightf(GL_LIGHT0 + Index, GL_QUADRATIC_ATTENUATION, quad_att);
4875 checkGLcall("glLightf");
4876 /* FIXME: Range */
4877 break;
4878
4880 /* Direction */
4881 /* Note GL uses w position of 0 for direction! */
4882 gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + Index, GL_POSITION, &lightInfo->direction.x);
4883 checkGLcall("glLightfv");
4884 gl_info->gl_ops.gl.p_glLightf(GL_LIGHT0 + Index, GL_SPOT_CUTOFF, lightInfo->cutoff);
4885 checkGLcall("glLightf");
4886 gl_info->gl_ops.gl.p_glLightf(GL_LIGHT0 + Index, GL_SPOT_EXPONENT, 0.0f);
4887 checkGLcall("glLightf");
4888 break;
4889
4890 default:
4891 FIXME("Unrecognized light type %#x.\n", lightInfo->OriginalParms.type);
4892 }
4893
4894 /* Restore the modelview matrix */
4895 gl_info->gl_ops.gl.p_glPopMatrix();
4896
4897 gl_info->gl_ops.gl.p_glEnable(GL_LIGHT0 + Index);
4898 checkGLcall("glEnable(GL_LIGHT0 + Index)");
4899 }
4900}
#define FLT_MIN
Definition: gcc_float.h:124
#define GL_DIFFUSE
Definition: gl.h:325
#define GL_POSITION
Definition: gl.h:329
#define GL_SPOT_EXPONENT
Definition: gl.h:319
#define GL_SPECULAR
Definition: gl.h:326
#define GL_QUADRATIC_ATTENUATION
Definition: gl.h:323
#define GL_AMBIENT
Definition: gl.h:324
#define GL_LINEAR_ATTENUATION
Definition: gl.h:322
#define GL_SPOT_DIRECTION
Definition: gl.h:330
#define GL_CONSTANT_ATTENUATION
Definition: gl.h:321
#define GL_SPOT_CUTOFF
Definition: gl.h:320
#define GL_LIGHT0
Definition: gl.h:311
struct wined3d_vec4 position
struct wined3d_light OriginalParms
struct wined3d_vec4 direction
_In_ WDFCOLLECTION _In_ ULONG Index
@ WINED3D_LIGHT_SPOT
Definition: wined3d.h:63
@ WINED3D_LIGHT_POINT
Definition: wined3d.h:62
@ WINED3D_LIGHT_DIRECTIONAL
Definition: wined3d.h:64
#define STATE_ACTIVELIGHT(a)

◆ load_numbered_arrays()

static void load_numbered_arrays ( struct wined3d_context context,
const struct wined3d_stream_info stream_info,
const struct wined3d_state state 
)
static

Definition at line 4077 of file state.c.

4079{
4080 const struct wined3d_shader *vs = state->shader[WINED3D_SHADER_TYPE_VERTEX];
4081 const struct wined3d_gl_info *gl_info = context->gl_info;
4082 GLuint curVBO = gl_info->supported[ARB_VERTEX_BUFFER_OBJECT] ? ~0U : 0;
4083 unsigned int i;
4084
4085 /* Default to no instancing */
4086 context->instance_count = 0;
4087
4088 for (i = 0; i < MAX_ATTRIBS; ++i)
4089 {
4090 const struct wined3d_stream_info_element *element = &stream_info->elements[i];
4091 const struct wined3d_stream_state *stream;
4092
4093 if (!(stream_info->use_map & (1u << i)))
4094 {
4095 if (context->numbered_array_mask & (1u << i))
4097 if (!use_vs(state) && i == WINED3D_FFP_DIFFUSE)
4098 GL_EXTCALL(glVertexAttrib4f(i, 1.0f, 1.0f, 1.0f, 1.0f));
4099 else
4100 GL_EXTCALL(glVertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 0.0f));
4101 continue;
4102 }
4103
4104 stream = &state->streams[element->stream_idx];
4105
4106 if ((stream->flags & WINED3DSTREAMSOURCE_INSTANCEDATA) && !context->instance_count)
4107 context->instance_count = state->streams[0].frequency ? state->streams[0].frequency : 1;
4108
4109 if (gl_info->supported[ARB_INSTANCED_ARRAYS])
4110 {
4111 GL_EXTCALL(glVertexAttribDivisor(i, element->divisor));
4112 }
4113 else if (element->divisor)
4114 {
4115 /* Unload instanced arrays, they will be loaded using
4116 * immediate mode instead. */
4117 if (context->numbered_array_mask & (1u << i))
4119 continue;
4120 }
4121
4122 TRACE_(d3d_shader)("Loading array %u [VBO=%u].\n", i, element->data.buffer_object);
4123
4124 if (element->stride)
4125 {
4126 if (curVBO != element->data.buffer_object)
4127 {
4128 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER, element->data.buffer_object));
4129 checkGLcall("glBindBuffer");
4130 curVBO = element->data.buffer_object;
4131 }
4132 /* Use the VBO to find out if a vertex buffer exists, not the vb
4133 * pointer. vb can point to a user pointer data blob. In that case
4134 * curVBO will be 0. If there is a vertex buffer but no vbo we
4135 * won't be load converted attributes anyway. */
4136 if (vs && vs->reg_maps.shader_version.major >= 4
4138 {
4139 GL_EXTCALL(glVertexAttribIPointer(i, element->format->gl_vtx_format, element->format->gl_vtx_type,
4140 element->stride, element->data.addr + state->load_base_vertex_index * element->stride));
4141 }
4142 else
4143 {
4144 GL_EXTCALL(glVertexAttribPointer(i, element->format->gl_vtx_format, element->format->gl_vtx_type,
4145 element->format->gl_normalized, element->stride,
4146 element->data.addr + state->load_base_vertex_index * element->stride));
4147 }
4148
4149 if (!(context->numbered_array_mask & (1u << i)))
4150 {
4151 GL_EXTCALL(glEnableVertexAttribArray(i));
4152 context->numbered_array_mask |= (1u << i);
4153 }
4154 }
4155 else
4156 {
4157 /* Stride = 0 means always the same values.
4158 * glVertexAttribPointer doesn't do that. Instead disable the
4159 * pointer and set up the attribute statically. But we have to
4160 * figure out the system memory address. */
4161 const BYTE *ptr = element->data.addr;
4162 if (element->data.buffer_object)
4164
4165 if (context->numbered_array_mask & (1u << i))
4167
4168 switch (element->format->id)
4169 {
4171 GL_EXTCALL(glVertexAttrib1fv(i, (const GLfloat *)ptr));
4172 break;
4174 GL_EXTCALL(glVertexAttrib2fv(i, (const GLfloat *)ptr));
4175 break;
4177 GL_EXTCALL(glVertexAttrib3fv(i, (const GLfloat *)ptr));
4178 break;
4180 GL_EXTCALL(glVertexAttrib4fv(i, (const GLfloat *)ptr));
4181 break;
4182
4184 GL_EXTCALL(glVertexAttrib4ubv(i, ptr));
4185 break;
4187 if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA])
4188 {
4189 const DWORD *src = (const DWORD *)ptr;
4190 DWORD c = *src & 0xff00ff00u;
4191 c |= (*src & 0xff0000u) >> 16;
4192 c |= (*src & 0xffu) << 16;
4193 GL_EXTCALL(glVertexAttrib4Nubv(i, (GLubyte *)&c));
4194 break;
4195 }
4196 /* else fallthrough */
4198 GL_EXTCALL(glVertexAttrib4Nubv(i, ptr));
4199 break;
4200
4202 GL_EXTCALL(glVertexAttrib2sv(i, (const GLshort *)ptr));
4203 break;
4205 GL_EXTCALL(glVertexAttrib4sv(i, (const GLshort *)ptr));
4206 break;
4207
4209 {
4210 const GLshort s[4] = {((const GLshort *)ptr)[0], ((const GLshort *)ptr)[1], 0, 1};
4211 GL_EXTCALL(glVertexAttrib4Nsv(i, s));
4212 break;
4213 }
4215 {
4216 const GLushort s[4] = {((const GLushort *)ptr)[0], ((const GLushort *)ptr)[1], 0, 1};
4217 GL_EXTCALL(glVertexAttrib4Nusv(i, s));
4218 break;
4219 }
4221 GL_EXTCALL(glVertexAttrib4Nsv(i, (const GLshort *)ptr));
4222 break;
4224 GL_EXTCALL(glVertexAttrib4Nusv(i, (const GLushort *)ptr));
4225 break;
4226
4228 FIXME("Unsure about WINED3DDECLTYPE_UDEC3.\n");
4229 /*glVertexAttrib3usvARB(i, (const GLushort *)ptr); Does not exist */
4230 break;
4232 FIXME("Unsure about WINED3DDECLTYPE_DEC3N.\n");
4233 /*glVertexAttrib3NusvARB(i, (const GLushort *)ptr); Does not exist */
4234 break;
4235
4237 if (gl_info->supported[NV_HALF_FLOAT] && gl_info->supported[NV_VERTEX_PROGRAM])
4238 {
4239 /* Not supported by GL_ARB_half_float_vertex. */
4240 GL_EXTCALL(glVertexAttrib2hvNV(i, (const GLhalfNV *)ptr));
4241 }
4242 else
4243 {
4244 float x = float_16_to_32(((const unsigned short *)ptr) + 0);
4245 float y = float_16_to_32(((const unsigned short *)ptr) + 1);
4246 GL_EXTCALL(glVertexAttrib2f(i, x, y));
4247 }
4248 break;
4250 if (gl_info->supported[NV_HALF_FLOAT] && gl_info->supported[NV_VERTEX_PROGRAM])
4251 {
4252 /* Not supported by GL_ARB_half_float_vertex. */
4253 GL_EXTCALL(glVertexAttrib4hvNV(i, (const GLhalfNV *)ptr));
4254 }
4255 else
4256 {
4257 float x = float_16_to_32(((const unsigned short *)ptr) + 0);
4258 float y = float_16_to_32(((const unsigned short *)ptr) + 1);
4259 float z = float_16_to_32(((const unsigned short *)ptr) + 2);
4260 float w = float_16_to_32(((const unsigned short *)ptr) + 3);
4261 GL_EXTCALL(glVertexAttrib4f(i, x, y, z, w));
4262 }
4263 break;
4264
4265 default:
4266 ERR("Unexpected declaration in stride 0 attributes.\n");
4267 break;
4268
4269 }
4270 }
4271 }
4272 checkGLcall("Loading numbered arrays");
4273}
#define U(x)
Definition: wordpad.c:45
float float_16_to_32(const unsigned short in) DECLSPEC_HIDDEN
Definition: math.c:2203
BYTE * wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context)
Definition: buffer.c:706
static void unload_numbered_array(struct wined3d_context *context, int i)
Definition: state.c:4053
#define TRACE_(x)
Definition: compat.h:76
#define ULONG_PTR
Definition: config.h:101
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char GLubyte
Definition: gl.h:157
short GLshort
Definition: gl.h:155
float GLfloat
Definition: gl.h:161
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble s
Definition: gl.h:2039
unsigned int GLuint
Definition: gl.h:159
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
unsigned short GLushort
Definition: gl.h:158
GLenum src
Definition: glext.h:6340
unsigned short GLhalfNV
Definition: glext.h:5520
const GLubyte * c
Definition: glext.h:8905
#define GL_ARRAY_BUFFER
Definition: glext.h:336
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLdouble GLdouble z
Definition: glext.h:5874
static PVOID ptr
Definition: dispmode.c:27
static vector_t * vs
Definition: server.c:127
Definition: parse.h:23
#define WINED3DSTREAMSOURCE_INSTANCEDATA
Definition: wined3d.h:1003
@ WINED3DFMT_R16G16_UNORM
Definition: wined3d.h:171
@ WINED3DFMT_R10G10B10X2_UINT
Definition: wined3d.h:124
@ WINED3DFMT_R32G32_FLOAT
Definition: wined3d.h:150
@ WINED3DFMT_R16G16_SNORM
Definition: wined3d.h:173
@ WINED3DFMT_B8G8R8A8_UNORM
Definition: wined3d.h:223
@ WINED3DFMT_R16G16B16A16_SINT
Definition: wined3d.h:148
@ WINED3DFMT_R32G32B32_FLOAT
Definition: wined3d.h:140
@ WINED3DFMT_R16G16B16A16_FLOAT
Definition: wined3d.h:144
@ WINED3DFMT_R8G8B8A8_UNORM
Definition: wined3d.h:164
@ WINED3DFMT_R16G16B16A16_UNORM
Definition: wined3d.h:145
@ WINED3DFMT_R32_FLOAT
Definition: wined3d.h:177
@ WINED3DFMT_R16G16_FLOAT
Definition: wined3d.h:170
@ WINED3DFMT_R8G8B8A8_UINT
Definition: wined3d.h:166
@ WINED3DFMT_R10G10B10X2_SNORM
Definition: wined3d.h:125
@ WINED3DFMT_R32G32B32A32_FLOAT
Definition: wined3d.h:136
@ WINED3DFMT_R16G16B16A16_SNORM
Definition: wined3d.h:147
@ WINED3DFMT_R16G16_SINT
Definition: wined3d.h:174
@ NV_HALF_FLOAT
Definition: wined3d_gl.h:191
@ ARB_VERTEX_BUFFER_OBJECT
Definition: wined3d_gl.h:138
@ ARB_INSTANCED_ARRAYS
Definition: wined3d_gl.h:79
@ NV_VERTEX_PROGRAM
Definition: wined3d_gl.h:200
@ ARB_VERTEX_ARRAY_BGRA
Definition: wined3d_gl.h:136
@ WINED3D_FFP_DIFFUSE
#define WINED3DFMT_FLAG_INTEGER
@ WINED3D_GL_RES_TYPE_BUFFER
@ WINED3D_SHADER_TYPE_VERTEX
#define MAX_ATTRIBS
unsigned char BYTE
Definition: xxhash.c:193

Referenced by streamsrc().

◆ load_tex_coords()

static void load_tex_coords ( const struct wined3d_context context,
const struct wined3d_stream_info si,
GLuint curVBO,
const struct wined3d_state state 
)
static

Definition at line 3351 of file state.c.

3353{
3354 const struct wined3d_gl_info *gl_info = context->gl_info;
3355 unsigned int mapped_stage = 0;
3356 unsigned int textureNo;
3357
3358 for (textureNo = 0; textureNo < context->d3d_info->limits.ffp_blend_stages; ++textureNo)
3359 {
3360 int coordIdx = state->texture_states[textureNo][WINED3D_TSS_TEXCOORD_INDEX];
3361
3362 mapped_stage = context->tex_unit_map[textureNo];
3363 if (mapped_stage == WINED3D_UNMAPPED_STAGE) continue;
3364
3365 if (mapped_stage >= gl_info->limits.texture_coords)
3366 {
3367 FIXME("Attempted to load unsupported texture coordinate %u\n", mapped_stage);
3368 continue;
3369 }
3370
3371 if (coordIdx < MAX_TEXTURES && (si->use_map & (1u << (WINED3D_FFP_TEXCOORD0 + coordIdx))))
3372 {
3373 const struct wined3d_stream_info_element *e = &si->elements[WINED3D_FFP_TEXCOORD0 + coordIdx];
3374
3375 TRACE("Setting up texture %u, idx %d, coordindx %u, data {%#x:%p}.\n",
3376 textureNo, mapped_stage, coordIdx, e->data.buffer_object, e->data.addr);
3377
3378 if (*curVBO != e->data.buffer_object)
3379 {
3380 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER, e->data.buffer_object));
3381 checkGLcall("glBindBuffer");
3382 *curVBO = e->data.buffer_object;
3383 }
3384
3386 checkGLcall("glClientActiveTextureARB");
3387
3388 /* The coords to supply depend completely on the fvf / vertex shader */
3389 gl_info->gl_ops.gl.p_glTexCoordPointer(e->format->gl_vtx_format, e->format->gl_vtx_type, e->stride,
3390 e->data.addr + state->load_base_vertex_index * e->stride);
3391 gl_info->gl_ops.gl.p_glEnableClientState(GL_TEXTURE_COORD_ARRAY);
3392 }
3393 else
3394 {
3395 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + mapped_stage, 0, 0, 0, 1));
3396 }
3397 }
3398 if (gl_info->supported[NV_REGISTER_COMBINERS])
3399 {
3400 /* The number of the mapped stages increases monotonically, so it's fine to use the last used one. */
3401 for (textureNo = mapped_stage + 1; textureNo < gl_info->limits.textures; ++textureNo)
3402 {
3403 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + textureNo, 0, 0, 0, 1));
3404 }
3405 }
3406
3407 checkGLcall("loadTexCoords");
3408}
#define GL_TEXTURE_COORD_ARRAY
Definition: gl.h:206
GLAPI void GLAPIENTRY glClientActiveTextureARB(GLenum texture)
#define GL_TEXTURE0_ARB
Definition: gl.h:1966
GLAPI void GLAPIENTRY glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
#define e
Definition: ke_i.h:82
struct wined3d_stream_info_element elements[MAX_ATTRIBS]
@ WINED3D_TSS_TEXCOORD_INDEX
Definition: wined3d.h:585
@ NV_REGISTER_COMBINERS
Definition: wined3d_gl.h:194
@ WINED3D_FFP_TEXCOORD0
#define MAX_TEXTURES
#define WINED3D_UNMAPPED_STAGE

Referenced by load_vertex_data(), and tex_coordindex().

◆ load_vertex_data()

static void load_vertex_data ( struct wined3d_context context,
const struct wined3d_stream_info si,
const struct wined3d_state state 
)
static

Definition at line 4275 of file state.c.

4277{
4278 const struct wined3d_gl_info *gl_info = context->gl_info;
4279 GLuint curVBO = gl_info->supported[ARB_VERTEX_BUFFER_OBJECT] ? ~0U : 0;
4280 const struct wined3d_stream_info_element *e;
4281
4282 TRACE("Using fast vertex array code\n");
4283
4284 /* This is fixed function pipeline only, and the fixed function pipeline doesn't do instancing */
4285 context->instance_count = 0;
4286
4287 /* Blend Data ---------------------------------------------- */
4288 if ((si->use_map & (1u << WINED3D_FFP_BLENDWEIGHT))
4289 || si->use_map & (1u << WINED3D_FFP_BLENDINDICES))
4290 {
4292
4293 if (gl_info->supported[ARB_VERTEX_BLEND])
4294 {
4295 TRACE("Blend %u %p %u\n", e->format->component_count,
4296 e->data.addr + state->load_base_vertex_index * e->stride, e->stride);
4297
4298 gl_info->gl_ops.gl.p_glEnableClientState(GL_WEIGHT_ARRAY_ARB);
4299 checkGLcall("glEnableClientState(GL_WEIGHT_ARRAY_ARB)");
4300
4301 GL_EXTCALL(glVertexBlendARB(e->format->component_count + 1));
4302
4303 if (curVBO != e->data.buffer_object)
4304 {
4305 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER, e->data.buffer_object));
4306 checkGLcall("glBindBuffer");
4307 curVBO = e->data.buffer_object;
4308 }
4309
4310 TRACE("glWeightPointerARB(%#x, %#x, %#x, %p);\n",
4311 e->format->gl_vtx_format,
4312 e->format->gl_vtx_type,
4313 e->stride,
4314 e->data.addr + state->load_base_vertex_index * e->stride);
4315 GL_EXTCALL(glWeightPointerARB(e->format->gl_vtx_format, e->format->gl_vtx_type, e->stride,
4316 e->data.addr + state->load_base_vertex_index * e->stride));
4317
4318 checkGLcall("glWeightPointerARB");
4319
4320 if (si->use_map & (1u << WINED3D_FFP_BLENDINDICES))
4321 {
4322 static BOOL warned;
4323 if (!warned)
4324 {
4325 FIXME("blendMatrixIndices support\n");
4326 warned = TRUE;
4327 }
4328 }
4329 }
4330 else
4331 {
4332 /* TODO: Support vertex blending in immediate mode draws. No need
4333 * to write a FIXME here, this is done after the general vertex
4334 * declaration decoding. */
4335 WARN("Vertex blending not supported.\n");
4336 }
4337 }
4338 else
4339 {
4340 if (gl_info->supported[ARB_VERTEX_BLEND])
4341 {
4342 static const GLbyte one = 1;
4343 GL_EXTCALL(glWeightbvARB(1, &one));
4344 checkGLcall("glWeightbvARB(gl_info->max_blends, weights)");
4345 }
4346 }
4347
4348 /* Point Size ----------------------------------------------*/
4349 if (si->use_map & (1u << WINED3D_FFP_PSIZE))
4350 {
4351 /* no such functionality in the fixed function GL pipeline */
4352 TRACE("Cannot change ptSize here in openGl\n");
4353 /* TODO: Implement this function in using shaders if they are available */
4354 }
4355
4356 /* Vertex Pointers -----------------------------------------*/
4357 if (si->use_map & (1u << WINED3D_FFP_POSITION))
4358 {
4360
4361 if (curVBO != e->data.buffer_object)
4362 {
4363 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER, e->data.buffer_object));
4364 checkGLcall("glBindBuffer");
4365 curVBO = e->data.buffer_object;
4366 }
4367
4368 TRACE("glVertexPointer(%#x, %#x, %#x, %p);\n",
4369 e->format->gl_vtx_format, e->format->gl_vtx_type, e->stride,
4370 e->data.addr + state->load_base_vertex_index * e->stride);
4371 gl_info->gl_ops.gl.p_glVertexPointer(e->format->gl_vtx_format, e->format->gl_vtx_type, e->stride,
4372 e->data.addr + state->load_base_vertex_index * e->stride);
4373 checkGLcall("glVertexPointer(...)");
4374 gl_info->gl_ops.gl.p_glEnableClientState(GL_VERTEX_ARRAY);
4375 checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
4376 }
4377
4378 /* Normals -------------------------------------------------*/
4379 if (si->use_map & (1u << WINED3D_FFP_NORMAL))
4380 {
4382
4383 if (curVBO != e->data.buffer_object)
4384 {
4385 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER, e->data.buffer_object));
4386 checkGLcall("glBindBuffer");
4387 curVBO = e->data.buffer_object;
4388 }
4389
4390 TRACE("glNormalPointer(%#x, %#x, %p);\n", e->format->gl_vtx_type, e->stride,
4391 e->data.addr + state->load_base_vertex_index * e->stride);
4392 gl_info->gl_ops.gl.p_glNormalPointer(e->format->gl_vtx_type, e->stride,
4393 e->data.addr + state->load_base_vertex_index * e->stride);
4394 checkGLcall("glNormalPointer(...)");
4395 gl_info->gl_ops.gl.p_glEnableClientState(GL_NORMAL_ARRAY);
4396 checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
4397
4398 }
4399 else
4400 {
4401 gl_info->gl_ops.gl.p_glNormal3f(0, 0, 0);
4402 checkGLcall("glNormal3f(0, 0, 0)");
4403 }
4404
4405 /* Diffuse Colour --------------------------------------------*/
4406 if (si->use_map & (1u << WINED3D_FFP_DIFFUSE))
4407 {
4409
4410 if (curVBO != e->data.buffer_object)
4411 {
4412 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER, e->data.buffer_object));
4413 checkGLcall("glBindBuffer");
4414 curVBO = e->data.buffer_object;
4415 }
4416
4417 TRACE("glColorPointer(%#x, %#x %#x, %p);\n",
4418 e->format->gl_vtx_format, e->format->gl_vtx_type, e->stride,
4419 e->data.addr + state->load_base_vertex_index * e->stride);
4420 gl_info->gl_ops.gl.p_glColorPointer(e->format->gl_vtx_format, e->format->gl_vtx_type, e->stride,
4421 e->data.addr + state->load_base_vertex_index * e->stride);
4422 checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
4423 gl_info->gl_ops.gl.p_glEnableClientState(GL_COLOR_ARRAY);
4424 checkGLcall("glEnableClientState(GL_COLOR_ARRAY)");
4425
4426 }
4427 else
4428 {
4429 gl_info->gl_ops.gl.p_glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
4430 checkGLcall("glColor4f(1, 1, 1, 1)");
4431 }
4432
4433 /* Specular Colour ------------------------------------------*/
4434 if (si->use_map & (1u << WINED3D_FFP_SPECULAR))
4435 {
4436 TRACE("setting specular colour\n");
4437
4439
4440 if (gl_info->supported[EXT_SECONDARY_COLOR])
4441 {
4442 GLenum type = e->format->gl_vtx_type;
4443 GLint format = e->format->gl_vtx_format;
4444
4445 if (curVBO != e->data.buffer_object)
4446 {
4447 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER, e->data.buffer_object));
4448 checkGLcall("glBindBuffer");
4449 curVBO = e->data.buffer_object;
4450 }
4451
4452 if (format != 4 || (gl_info->quirks & WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA))
4453 {
4454 /* Usually specular colors only allow 3 components, since they have no alpha. In D3D, the specular alpha
4455 * contains the fog coordinate, which is passed to GL with GL_EXT_fog_coord. However, the fixed function
4456 * vertex pipeline can pass the specular alpha through, and pixel shaders can read it. So it GL accepts
4457 * 4 component secondary colors use it
4458 */
4459 TRACE("glSecondaryColorPointer(%#x, %#x, %#x, %p);\n", format, type, e->stride,
4460 e->data.addr + state->load_base_vertex_index * e->stride);
4461 GL_EXTCALL(glSecondaryColorPointerEXT(format, type, e->stride,
4462 e->data.addr + state->load_base_vertex_index * e->stride));
4463 checkGLcall("glSecondaryColorPointerEXT(format, type, ...)");
4464 }
4465 else
4466 {
4467 switch(type)
4468 {
4469 case GL_UNSIGNED_BYTE:
4470 TRACE("glSecondaryColorPointer(3, GL_UNSIGNED_BYTE, %#x, %p);\n", e->stride,
4471 e->data.addr + state->load_base_vertex_index * e->stride);
4472 GL_EXTCALL(glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE, e->stride,
4473 e->data.addr + state->load_base_vertex_index * e->stride));
4474 checkGLcall("glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE, ...)");
4475 break;
4476
4477 default:
4478 FIXME("Add 4 component specular color pointers for type %x\n", type);
4479 /* Make sure that the right color component is dropped */
4480 TRACE("glSecondaryColorPointer(3, %#x, %#x, %p);\n", type, e->stride,
4481 e->data.addr + state->load_base_vertex_index * e->stride);
4482 GL_EXTCALL(glSecondaryColorPointerEXT(3, type, e->stride,
4483 e->data.addr + state->load_base_vertex_index * e->stride));
4484 checkGLcall("glSecondaryColorPointerEXT(3, type, ...)");
4485 }
4486 }
4487 gl_info->gl_ops.gl.p_glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
4488 checkGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
4489 }
4490 else
4491 {
4492 WARN("Specular colour is not supported in this GL implementation.\n");
4493 }
4494 }
4495 else
4496 {
4497 if (gl_info->supported[EXT_SECONDARY_COLOR])
4498 {
4499 GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
4500 checkGLcall("glSecondaryColor3fEXT(0, 0, 0)");
4501 }
4502 else
4503 {
4504 WARN("Specular colour is not supported in this GL implementation.\n");
4505 }
4506 }
4507
4508 /* Texture coords -------------------------------------------*/
4509 load_tex_coords(context, si, &curVBO, state);
4510}
static void load_tex_coords(const struct wined3d_context *context, const struct wined3d_stream_info *si, GLuint *curVBO, const struct wined3d_state *state)
Definition: state.c:3351
signed char GLbyte
Definition: gl.h:154
#define GL_COLOR_ARRAY
Definition: gl.h:204
#define GL_NORMAL_ARRAY
Definition: gl.h:203
#define GL_VERTEX_ARRAY
Definition: gl.h:202
#define GL_UNSIGNED_BYTE
Definition: gl.h:178
int GLint
Definition: gl.h:156
#define GL_WEIGHT_ARRAY_ARB
Definition: glext.h:1277
#define GL_SECONDARY_COLOR_ARRAY_EXT
Definition: glext.h:3184
int one
Definition: sehframes.cpp:28
Definition: format.c:58
@ EXT_SECONDARY_COLOR
Definition: wined3d_gl.h:168
@ ARB_VERTEX_BLEND
Definition: wined3d_gl.h:137
@ WINED3D_FFP_PSIZE
@ WINED3D_FFP_SPECULAR
@ WINED3D_FFP_POSITION
@ WINED3D_FFP_NORMAL
@ WINED3D_FFP_BLENDWEIGHT
@ WINED3D_FFP_BLENDINDICES
#define WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA

Referenced by streamsrc().

◆ multistate_apply_2()

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

Definition at line 5997 of file state.c.

5998{
5999 context->device->multistate_funcs[state_id][0](context, state, state_id);
6000 context->device->multistate_funcs[state_id][1](context, state, state_id);
6001}

Referenced by compile_state_table().

◆ multistate_apply_3()

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

Definition at line 6003 of file state.c.

6004{
6005 context->device->multistate_funcs[state_id][0](context, state, state_id);
6006 context->device->multistate_funcs[state_id][1](context, state, state_id);
6007 context->device->multistate_funcs[state_id][2](context, state, state_id);
6008}

Referenced by compile_state_table().

◆ none_alloc()

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

Definition at line 5935 of file state.c.

5936{
5937 return shader_priv;
5938}

◆ none_enable()

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

Definition at line 5933 of file state.c.

5933{}

◆ none_free()

static void none_free ( struct wined3d_device device)
static

Definition at line 5940 of file state.c.

5940{}

◆ num_handlers()

static unsigned int num_handlers ( const APPLYSTATEFUNC funcs)
static

Definition at line 5990 of file state.c.

5991{
5992 unsigned int i;
5993 for(i = 0; funcs[i]; i++);
5994 return i;
5995}
static struct __wine_debug_functions funcs
Definition: debug.c:59

Referenced by compile_state_table().

◆ prune_invalid_states()

static void prune_invalid_states ( struct StateEntry state_table,
const struct wined3d_gl_info gl_info,
const struct wined3d_d3d_info d3d_info 
)
static

Definition at line 6010 of file state.c.

6012{
6013 unsigned int start, last, i;
6014
6015 start = STATE_TEXTURESTAGE(d3d_info->limits.ffp_blend_stages, 0);
6017 for (i = start; i <= last; ++i)
6018 {
6019 state_table[i].representative = 0;
6020 state_table[i].apply = state_undefined;
6021 }
6022
6023 start = STATE_TRANSFORM(WINED3D_TS_TEXTURE0 + d3d_info->limits.ffp_blend_stages);
6025 for (i = start; i <= last; ++i)
6026 {
6027 state_table[i].representative = 0;
6028 state_table[i].apply = state_undefined;
6029 }
6030
6031 start = STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(d3d_info->limits.ffp_vertex_blend_matrices));
6033 for (i = start; i <= last; ++i)
6034 {
6035 state_table[i].representative = 0;
6036 state_table[i].apply = state_undefined;
6037 }
6038}
static const struct @243 state_table[]
GLuint start
Definition: gl.h:1545
static UINT UINT last
Definition: font.c:45
struct wined3d_d3d_limits limits
#define WINED3D_TS_WORLD_MATRIX(index)
Definition: wined3d.h:664
#define WINED3D_HIGHEST_TEXTURE_STATE
Definition: wined3d.h:595
@ WINED3D_TS_TEXTURE0
Definition: wined3d.h:650

Referenced by compile_state_table().

◆ psorigin()

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

Definition at line 4979 of file state.c.

4980{
4981 const struct wined3d_gl_info *gl_info = context->gl_info;
4982 GLint origin = context->render_offscreen ? GL_LOWER_LEFT : GL_UPPER_LEFT;
4983
4984 GL_EXTCALL(glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, origin));
4985 checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
4986}
#define GL_UPPER_LEFT
Definition: glext.h:462
#define GL_LOWER_LEFT
Definition: glext.h:461
#define GL_POINT_SPRITE_COORD_ORIGIN
Definition: glext.h:460
voidpf uLong int origin
Definition: ioapi.h:144

◆ psorigin_w()

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

Definition at line 4968 of file state.c.

4969{
4970 static BOOL warned;
4971
4972 if (!warned)
4973 {
4974 WARN("Point sprite coordinate origin switching not supported.\n");
4975 warned = TRUE;
4976 }
4977}

◆ renderstate_stencil_twosided()

static void renderstate_stencil_twosided ( struct wined3d_context context,
GLint  face,
GLint  func,
GLint  ref,
GLuint  mask,
GLint  stencilFail,
GLint  depthFail,
GLint  stencilPass 
)
static

Definition at line 865 of file state.c.

867{
868 const struct wined3d_gl_info *gl_info = context->gl_info;
869
870 gl_info->gl_ops.gl.p_glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
871 checkGLcall("glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
872 GL_EXTCALL(glActiveStencilFaceEXT(face));
873 checkGLcall("glActiveStencilFaceEXT(...)");
874 gl_info->gl_ops.gl.p_glStencilFunc(func, ref, mask);
875 checkGLcall("glStencilFunc(...)");
876 gl_info->gl_ops.gl.p_glStencilOp(stencilFail, depthFail, stencilPass);
877 checkGLcall("glStencilOp(...)");
878}
GLenum func
Definition: glext.h:6028
GLenum GLint GLuint mask
Definition: glext.h:6028
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define GL_STENCIL_TEST_TWO_SIDE_EXT
Definition: glext.h:4210
Definition: send.c:48

Referenced by state_stencil().

◆ sampler()

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

Definition at line 3691 of file state.c.

3692{
3693 DWORD sampler_idx = state_id - STATE_SAMPLER(0);
3694 DWORD mapped_stage = context->tex_unit_map[sampler_idx];
3695 const struct wined3d_gl_info *gl_info = context->gl_info;
3696
3697 TRACE("Sampler %u.\n", sampler_idx);
3698
3699 if (mapped_stage == WINED3D_UNMAPPED_STAGE)
3700 {
3701 TRACE("No sampler mapped to stage %u. Returning.\n", sampler_idx);
3702 return;
3703 }
3704
3705 if (mapped_stage >= gl_info->limits.graphics_samplers)
3706 return;
3707 context_active_texture(context, gl_info, mapped_stage);
3708
3709 if (state->textures[sampler_idx])
3710 {
3711 BOOL srgb = state->sampler_states[sampler_idx][WINED3D_SAMP_SRGB_TEXTURE];
3712 const DWORD *sampler_states = state->sampler_states[sampler_idx];
3713 struct wined3d_texture *texture = state->textures[sampler_idx];
3714 struct wined3d_device *device = context->device;
3716 struct wined3d_sampler *sampler;
3717 struct wine_rb_entry *entry;
3718
3720
3722
3723 if ((entry = wine_rb_get(&device->samplers, &desc)))
3724 {
3726 }
3727 else
3728 {
3730 {
3731 ERR("Failed to create sampler.\n");
3732 return;
3733 }
3734 if (wine_rb_put(&device->samplers, &desc, &sampler->entry) == -1)
3735 {
3736 ERR("Failed to insert sampler.\n");
3738 return;
3739 }
3740 }
3741
3743
3744 /* Trigger shader constant reloading (for NP2 texcoord fixup) */
3746 context->constant_update_mask |= WINED3D_SHADER_CONST_PS_NP2_FIXUP;
3747 }
3748 else
3749 {
3751 if (gl_info->supported[ARB_SAMPLER_OBJECTS])
3752 {
3753 GL_EXTCALL(glBindSampler(mapped_stage, 0));
3754 checkGLcall("glBindSampler");
3755 }
3756 }
3757}
void context_active_texture(struct wined3d_context *context, const struct wined3d_gl_info *gl_info, unsigned int unit)
Definition: context.c:2717
void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint name)
Definition: context.c:2734
static void wined3d_sampler_desc_from_sampler_states(struct wined3d_sampler_desc *desc, const struct wined3d_context *context, const DWORD *sampler_states, const struct wined3d_texture *texture)
Definition: state.c:3632
void wined3d_texture_bind(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:729
GLenum GLuint texture
Definition: glext.h:6295
#define FAILED(hr)
Definition: intsafe.h:51
uint32_t entry
Definition: isohybrid.c:63
static const WCHAR desc[]
Definition: protectdata.c:36
HRESULT CDECL wined3d_sampler_create(struct wined3d_device *device, const struct wined3d_sampler_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler)
Definition: sampler.c:130
void wined3d_sampler_bind(struct wined3d_sampler *sampler, unsigned int unit, struct wined3d_texture *texture, const struct wined3d_context *context)
Definition: sampler.c:184
ULONG CDECL wined3d_sampler_decref(struct wined3d_sampler *sampler)
Definition: sampler.c:53
#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: devices.h:37
Definition: rbtree.h:36
const struct wined3d_parent_ops wined3d_null_parent_ops
Definition: directx.c:6815
@ WINED3D_SAMP_SRGB_TEXTURE
Definition: wined3d.h:546
@ ARB_SAMPLER_OBJECTS
Definition: wined3d_gl.h:92
#define WINED3D_TEXTURE_POW2_MAT_IDENT
#define WINED3D_SHADER_CONST_PS_NP2_FIXUP

◆ sampler_texmatrix()

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

Definition at line 3585 of file state.c.

3586{
3587 const DWORD sampler = state_id - STATE_SAMPLER(0);
3588 const struct wined3d_texture *texture = state->textures[sampler];
3589
3590 TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id);
3591
3592 if (!texture)
3593 return;
3594
3595 /* The fixed function np2 texture emulation uses the texture matrix to fix up the coordinates
3596 * wined3d_texture_apply_state_changes() multiplies the set matrix with a fixup matrix. Before the
3597 * scaling is reapplied or removed, the texture matrix has to be reapplied.
3598 */
3599 if (sampler < MAX_TEXTURES)
3600 {
3601 const BOOL tex_is_pow2 = !(texture->flags & WINED3D_TEXTURE_POW2_MAT_IDENT);
3602
3603 if (tex_is_pow2 || (context->lastWasPow2Texture & (1u << sampler)))
3604 {
3605 if (tex_is_pow2)
3606 context->lastWasPow2Texture |= 1u << sampler;
3607 else
3608 context->lastWasPow2Texture &= ~(1u << sampler);
3609
3611 }
3612 }
3613}
static void transform_texture(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
Definition: state.c:3313
@ WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
Definition: wined3d.h:588

◆ scissorrect()

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

Definition at line 4902 of file state.c.

4903{
4904 const struct wined3d_gl_info *gl_info = context->gl_info;
4905 const RECT *r = &state->scissor_rect;
4906
4907 /* Warning: glScissor uses window coordinates, not viewport coordinates,
4908 * so our viewport correction does not apply. Warning2: Even in windowed
4909 * mode the coords are relative to the window, not the screen. */
4910 TRACE("Setting new scissor rect to %s.\n", wine_dbgstr_rect(r));
4911
4912 if (context->render_offscreen)
4913 {
4914 gl_info->gl_ops.gl.p_glScissor(r->left, r->top, r->right - r->left, r->bottom - r->top);
4915 }
4916 else
4917 {
4918 const struct wined3d_rendertarget_view *target = state->fb->render_targets[0];
4919 UINT height;
4920 UINT width;
4921
4923 gl_info->gl_ops.gl.p_glScissor(r->left, height - r->bottom, r->right - r->left, r->bottom - r->top);
4924 }
4925 checkGLcall("glScissor");
4926}
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
GLdouble GLdouble GLdouble r
Definition: gl.h:2055

◆ set_color_mask()

static void set_color_mask ( const struct wined3d_gl_info gl_info,
UINT  index,
DWORD  mask 
)
static

Definition at line 1588 of file state.c.

1589{
1590 GL_EXTCALL(glColorMaski(index,
1595 checkGLcall("glColorMaski");
1596}
#define GL_TRUE
Definition: gl.h:174
#define GL_FALSE
Definition: gl.h:173
#define WINED3DCOLORWRITEENABLE_RED
Definition: wined3d.h:852
#define WINED3DCOLORWRITEENABLE_BLUE
Definition: wined3d.h:854
#define WINED3DCOLORWRITEENABLE_ALPHA
Definition: wined3d.h:855
#define WINED3DCOLORWRITEENABLE_GREEN
Definition: wined3d.h:853

Referenced by state_colorwrite_i().

◆ set_tex_op()

static void set_tex_op ( const struct wined3d_gl_info gl_info,
const struct wined3d_state state,
BOOL  isAlpha,
int  Stage,
enum wined3d_texture_op  op,
DWORD  arg1,
DWORD  arg2,
DWORD  arg3 
)
static

Definition at line 2103 of file state.c.

2105{
2106 GLenum src1, src2, src3;
2107 GLenum opr1, opr2, opr3;
2108 GLenum comb_target;
2109 GLenum src0_target, src1_target, src2_target;
2110 GLenum opr0_target, opr1_target, opr2_target;
2111 GLenum scal_target;
2112 GLenum opr=0, invopr, src3_target, opr3_target;
2113 BOOL Handled = FALSE;
2114
2115 TRACE("Alpha?(%d), Stage:%d Op(%s), a1(%d), a2(%d), a3(%d)\n", isAlpha, Stage, debug_d3dtop(op), arg1, arg2, arg3);
2116
2117 /* Operations usually involve two args, src0 and src1 and are operations
2118 * of the form (a1 <operation> a2). However, some of the more complex
2119 * operations take 3 parameters. Instead of the (sensible) addition of a3,
2120 * Microsoft added in a third parameter called a0. Therefore these are
2121 * operations of the form a0 <operation> a1 <operation> a2. I.e., the new
2122 * parameter goes to the front.
2123 *
2124 * However, below we treat the new (a0) parameter as src2/opr2, so in the
2125 * actual functions below, expect their syntax to differ slightly to those
2126 * listed in the manuals. I.e., replace arg1 with arg3, arg2 with arg1 and
2127 * arg3 with arg2. This affects WINED3DTOP_MULTIPLYADD and WINED3DTOP_LERP. */
2128
2129 if (isAlpha)
2130 {
2131 comb_target = GL_COMBINE_ALPHA;
2132 src0_target = GL_SOURCE0_ALPHA;
2133 src1_target = GL_SOURCE1_ALPHA;
2134 src2_target = GL_SOURCE2_ALPHA;
2135 opr0_target = GL_OPERAND0_ALPHA;
2136 opr1_target = GL_OPERAND1_ALPHA;
2137 opr2_target = GL_OPERAND2_ALPHA;
2138 scal_target = GL_ALPHA_SCALE;
2139 }
2140 else
2141 {
2142 comb_target = GL_COMBINE_RGB;
2143 src0_target = GL_SOURCE0_RGB;
2144 src1_target = GL_SOURCE1_RGB;
2145 src2_target = GL_SOURCE2_RGB;
2146 opr0_target = GL_OPERAND0_RGB;
2147 opr1_target = GL_OPERAND1_RGB;
2148 opr2_target = GL_OPERAND2_RGB;
2149 scal_target = GL_RGB_SCALE;
2150 }
2151
2152 /* If a texture stage references an invalid texture unit the stage just
2153 * passes through the result from the previous stage */
2154 if (is_invalid_op(state, Stage, op, arg1, arg2, arg3))
2155 {
2158 }
2159
2160 if (isAlpha && !state->textures[Stage] && arg1 == WINED3DTA_TEXTURE)
2161 {
2162 get_src_and_opr(WINED3DTA_DIFFUSE, isAlpha, &src1, &opr1);
2163 } else {
2164 get_src_and_opr(arg1, isAlpha, &src1, &opr1);
2165 }
2166 get_src_and_opr(arg2, isAlpha, &src2, &opr2);
2167 get_src_and_opr(arg3, isAlpha, &src3, &opr3);
2168
2169 TRACE("ct(%x), 1:(%x,%x), 2:(%x,%x), 3:(%x,%x)\n", comb_target, src1, opr1, src2, opr2, src3, opr3);
2170
2171 Handled = TRUE; /* Assume will be handled */
2172
2173 /* Other texture operations require special extensions: */
2174 if (gl_info->supported[NV_TEXTURE_ENV_COMBINE4])
2175 {
2176 if (isAlpha) {
2177 opr = GL_SRC_ALPHA;
2178 invopr = GL_ONE_MINUS_SRC_ALPHA;
2179 src3_target = GL_SOURCE3_ALPHA_NV;
2180 opr3_target = GL_OPERAND3_ALPHA_NV;
2181 } else {
2182 opr = GL_SRC_COLOR;
2183 invopr = GL_ONE_MINUS_SRC_COLOR;
2184 src3_target = GL_SOURCE3_RGB_NV;
2185 opr3_target = GL_OPERAND3_RGB_NV;
2186 }
2187 switch (op)
2188 {
2189 case WINED3D_TOP_DISABLE: /* Only for alpha */
2190 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2191 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2192 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, GL_PREVIOUS_EXT);
2193 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2194 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA);
2195 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2196 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2197 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2198 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2199 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2200 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO);
2201 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2202 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
2203 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2204 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2205 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2206 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
2207 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2208 break;
2209
2210 case WINED3D_TOP_SELECT_ARG1: /* = a1 * 1 + 0 * 0 */
2211 case WINED3D_TOP_SELECT_ARG2: /* = a2 * 1 + 0 * 0 */
2212 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2213 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2215 {
2216 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2217 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2218 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2219 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2220 }
2221 else
2222 {
2223 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src2);
2224 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2225 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr2);
2226 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2227 }
2228 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2229 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2230 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2231 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2232 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO);
2233 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2234 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
2235 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2236 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2237 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2238 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
2239 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2240 break;
2241
2243 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2244 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2245 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2246 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2247 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2248 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2249 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2250 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2251 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2252 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2253 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO);
2254 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2255 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
2256 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2257 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2258 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2259 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
2260 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2261 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2262 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2263 break;
2265 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2266 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2267 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2268 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2269 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2270 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2271 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2272 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2273 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2274 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2275 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO);
2276 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2277 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
2278 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2279 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2280 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2281 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
2282 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2283 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 2);
2284 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2285 break;
2287 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2288 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2289 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2290 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2291 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2292 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2293 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2294 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2295 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2296 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2297 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO);
2298 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2299 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
2300 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2301 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2302 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2303 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
2304 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2305 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 4);
2306 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2307 break;
2308
2309 case WINED3D_TOP_ADD:
2310 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2311 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2312 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2313 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2314 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2315 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2316 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2317 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2318 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2319 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2320 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2321 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2322 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2323 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2324 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2325 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2326 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, invopr);
2327 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2328 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2329 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2330 break;
2331
2333 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED);
2334 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2335 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2336 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2337 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2338 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2339 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2340 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2341 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2342 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2343 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2344 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2345 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2346 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2347 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2348 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2349 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, invopr);
2350 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2351 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2352 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2353 break;
2354
2356 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED);
2357 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2358 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2359 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2360 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2361 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2362 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2363 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2364 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2365 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2366 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2367 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2368 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2369 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2370 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2371 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2372 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, invopr);
2373 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2374 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 2);
2375 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2376 break;
2377
2379 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2380 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2381 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2382 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2383 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2384 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2385 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2386 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2387 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2388 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2389 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2390 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2391 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2392 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2393 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, src1);
2394 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2395 switch (opr1) {
2396 case GL_SRC_COLOR: opr = GL_ONE_MINUS_SRC_COLOR; break;
2397 case GL_ONE_MINUS_SRC_COLOR: opr = GL_SRC_COLOR; break;
2398 case GL_SRC_ALPHA: opr = GL_ONE_MINUS_SRC_ALPHA; break;
2399 case GL_ONE_MINUS_SRC_ALPHA: opr = GL_SRC_ALPHA; break;
2400 }
2401 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
2402 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2403 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2404 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2405 break;
2406
2408 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2409 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2410 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2411 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2412 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2413 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2414 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_PRIMARY_COLOR);
2415 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_PRIMARY_COLOR");
2416 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2417 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2418 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2419 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2420 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2421 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2422 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_PRIMARY_COLOR);
2423 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_PRIMARY_COLOR");
2424 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA);
2425 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2426 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2427 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2428 break;
2430 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2431 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2432 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2433 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2434 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2435 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2436 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_TEXTURE);
2437 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_TEXTURE");
2438 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2439 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2440 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2441 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2442 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2443 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2444 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_TEXTURE);
2445 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2446 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA);
2447 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2448 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2449 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2450 break;
2452 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2453 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2454 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2455 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2456 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2457 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2458 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_CONSTANT);
2459 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_CONSTANT");
2460 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2461 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2462 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2463 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2464 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2465 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2466 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_CONSTANT);
2467 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_CONSTANT");
2468 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA);
2469 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2470 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2471 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2472 break;
2474 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2475 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2476 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2477 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2478 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2479 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2480 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2481 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2482 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2483 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2484 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2485 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2486 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2487 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2488 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_TEXTURE);
2489 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2490 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA);
2491 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2492 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2493 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2494 break;
2496 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2497 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2498 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1); /* a0 = src1/opr1 */
2499 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2500 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2501 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); /* a1 = 1 (see docs) */
2502 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2503 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2504 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2505 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2506 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2); /* a2 = arg2 */
2507 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2508 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2509 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2"); /* a3 = src1 alpha */
2510 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, src1);
2511 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2512 switch (opr) {
2513 case GL_SRC_COLOR: opr = GL_SRC_ALPHA; break;
2515 }
2516 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
2517 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2518 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2519 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2520 break;
2522 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2523 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2524 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2525 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2526 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2527 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2528 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2529 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2530 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2531 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2532 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src1);
2533 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2534 switch (opr1) {
2535 case GL_SRC_COLOR: opr = GL_SRC_ALPHA; break;
2537 }
2538 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
2539 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2540 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2541 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2542 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, invopr);
2543 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2544 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2545 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2546 break;
2548 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2549 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2550 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2551 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2552 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2553 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2554 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2555 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2556 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2557 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2558 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2559 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2560 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2561 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2562 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, src1);
2563 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2564 switch (opr1) {
2565 case GL_SRC_COLOR: opr = GL_ONE_MINUS_SRC_ALPHA; break;
2566 case GL_ONE_MINUS_SRC_COLOR: opr = GL_SRC_ALPHA; break;
2567 case GL_SRC_ALPHA: opr = GL_ONE_MINUS_SRC_ALPHA; break;
2568 case GL_ONE_MINUS_SRC_ALPHA: opr = GL_SRC_ALPHA; break;
2569 }
2570 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
2571 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2572 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2573 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2574 break;
2576 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2577 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2578 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2579 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2580 switch (opr1) {
2581 case GL_SRC_COLOR: opr = GL_ONE_MINUS_SRC_COLOR; break;
2582 case GL_ONE_MINUS_SRC_COLOR: opr = GL_SRC_COLOR; break;
2583 case GL_SRC_ALPHA: opr = GL_ONE_MINUS_SRC_ALPHA; break;
2584 case GL_ONE_MINUS_SRC_ALPHA: opr = GL_SRC_ALPHA; break;
2585 }
2586 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr);
2587 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2588 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2589 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2590 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2591 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2592 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src1);
2593 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2594 switch (opr1) {
2595 case GL_SRC_COLOR: opr = GL_SRC_ALPHA; break;
2597 }
2598 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
2599 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2600 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2601 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2602 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, invopr);
2603 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2604 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2605 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2606 break;
2608 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2609 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2610 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src3);
2611 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2612 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr3);
2613 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2614 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2615 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2616 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2617 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2618 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src1);
2619 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2620 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr1);
2621 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2622 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, src2);
2623 checkGLcall("GL_TEXTURE_ENV, src3_target, src3");
2624 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr2);
2625 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr3");
2626 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2627 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2628 break;
2629
2632 FIXME("Implement bump environment mapping in GL_NV_texture_env_combine4 path\n");
2633 Handled = FALSE;
2634 break;
2635
2636 default:
2637 Handled = FALSE;
2638 }
2639 if (Handled)
2640 {
2641 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
2642 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV");
2643
2644 return;
2645 }
2646 } /* GL_NV_texture_env_combine4 */
2647
2648 Handled = TRUE; /* Again, assume handled */
2649 switch (op) {
2650 case WINED3D_TOP_DISABLE: /* Only for alpha */
2651 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_REPLACE);
2652 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2653 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, GL_PREVIOUS_EXT);
2654 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_PREVIOUS_EXT");
2655 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA);
2656 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA");
2657 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2658 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2659 break;
2661 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_REPLACE);
2662 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2663 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2664 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2665 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2666 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2667 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2668 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2669 break;
2671 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_REPLACE);
2672 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2673 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src2);
2674 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2675 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr2);
2676 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2677 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2678 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2679 break;
2681 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE);
2682 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2683 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2684 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2685 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2686 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2687 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2688 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2689 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2690 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2691 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2692 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2693 break;
2695 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE);
2696 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2697 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2698 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2699 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2700 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2701 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2702 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2703 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2704 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2705 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 2);
2706 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2707 break;
2709 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE);
2710 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2711 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2712 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2713 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2714 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2715 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2716 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2717 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2718 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2719 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 4);
2720 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2721 break;
2722 case WINED3D_TOP_ADD:
2723 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2724 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2725 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2726 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2727 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2728 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2729 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2730 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2731 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2732 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2733 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2734 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2735 break;
2737 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED);
2738 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2739 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2740 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2741 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2742 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2743 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2744 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2745 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2746 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2747 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2748 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2749 break;
2751 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED);
2752 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2753 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2754 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2755 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2756 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2757 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2758 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2759 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2760 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2761 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 2);
2762 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2763 break;
2765 if (gl_info->supported[ARB_TEXTURE_ENV_COMBINE])
2766 {
2767 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_SUBTRACT);
2768 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_SUBTRACT");
2769 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2770 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2771 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2772 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2773 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2774 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2775 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2776 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2777 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2778 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2779 } else {
2780 FIXME("This version of opengl does not support GL_SUBTRACT\n");
2781 }
2782 break;
2783
2785 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE);
2786 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2787 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2788 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2789 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2790 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2791 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2792 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2793 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2794 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2795 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_PRIMARY_COLOR);
2796 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PRIMARY_COLOR");
2797 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA);
2798 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2799 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2800 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2801 break;
2803 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE);
2804 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2805 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2806 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2807 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2808 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2809 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2810 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2811 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2812 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2813 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_TEXTURE);
2814 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_TEXTURE");
2815 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA);
2816 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2817 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2818 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2819 break;
2821 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE);
2822 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2823 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2824 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2825 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2826 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2827 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2828 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2829 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2830 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2831 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_CONSTANT);
2832 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_CONSTANT");
2833 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA);
2834 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2835 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2836 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2837 break;
2839 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE);
2840 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2841 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2842 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2843 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2844 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2845 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2846 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2847 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2848 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2849 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_PREVIOUS);
2850 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PREVIOUS");
2851 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA);
2852 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2853 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2854 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2855 break;
2857 if (gl_info->supported[ARB_TEXTURE_ENV_DOT3])
2858 {
2859 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB);
2860 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB");
2861 }
2862 else if (gl_info->supported[EXT_TEXTURE_ENV_DOT3])
2863 {
2864 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_EXT);
2865 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_EXT");
2866 } else {
2867 FIXME("This version of opengl does not support GL_DOT3\n");
2868 }
2869 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2870 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2871 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2872 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2873 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2874 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2875 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2876 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2877 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2878 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2879 break;
2880 case WINED3D_TOP_LERP:
2881 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE);
2882 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2883 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2884 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2885 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2886 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2887 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2888 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2889 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2890 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2891 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src3);
2892 checkGLcall("GL_TEXTURE_ENV, src2_target, src3");
2893 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr3);
2894 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr3");
2895 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2896 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2897 break;
2899 if (gl_info->supported[ATI_TEXTURE_ENV_COMBINE3])
2900 {
2901 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI);
2902 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2903 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2904 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2905 switch (opr1) {
2906 case GL_SRC_COLOR: opr = GL_ONE_MINUS_SRC_COLOR; break;
2907 case GL_ONE_MINUS_SRC_COLOR: opr = GL_SRC_COLOR; break;
2908 case GL_SRC_ALPHA: opr = GL_ONE_MINUS_SRC_ALPHA; break;
2909 case GL_ONE_MINUS_SRC_ALPHA: opr = GL_SRC_ALPHA; break;
2910 }
2911 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr);
2912 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2913 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src1);
2914 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2915 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr1);
2916 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2917 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2918 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2919 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2920 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2921 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2922 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2923 } else
2924 Handled = FALSE;
2925 break;
2927 if (gl_info->supported[ATI_TEXTURE_ENV_COMBINE3])
2928 {
2929 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI);
2930 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2931 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, GL_TEXTURE);
2932 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_TEXTURE");
2933 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, GL_ONE_MINUS_SRC_ALPHA);
2934 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_ONE_MINUS_SRC_APHA");
2935 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src1);
2936 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2937 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr1);
2938 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2939 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2940 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2941 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2942 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2943 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2944 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2945 } else
2946 Handled = FALSE;
2947 break;
2949 if (gl_info->supported[ATI_TEXTURE_ENV_COMBINE3])
2950 {
2951 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI);
2952 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2953 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2954 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2955 switch (opr1) {
2956 case GL_SRC_COLOR: opr = GL_SRC_ALPHA; break;
2958 case GL_SRC_ALPHA: opr = GL_SRC_ALPHA; break;
2960 }
2961 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr);
2962 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2963 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src1);
2964 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2965 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr1);
2966 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2967 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2968 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2969 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2970 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2971 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2972 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2973 } else
2974 Handled = FALSE;
2975 break;
2977 if (gl_info->supported[ATI_TEXTURE_ENV_COMBINE3])
2978 {
2979 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI);
2980 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2981 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2982 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2983 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2984 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2985 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src1);
2986 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2987 switch (opr1) {
2988 case GL_SRC_COLOR: opr = GL_SRC_ALPHA; break;
2990 case GL_SRC_ALPHA: opr = GL_SRC_ALPHA; break;
2992 }
2993 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr);
2994 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
2995 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2996 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2997 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2998 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2999 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
3000 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
3001 } else
3002 Handled = FALSE;
3003 break;
3005 if (gl_info->supported[ATI_TEXTURE_ENV_COMBINE3])
3006 {
3007 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI);
3008 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
3009 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
3010 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
3011 switch (opr1) {
3012 case GL_SRC_COLOR: opr = GL_ONE_MINUS_SRC_ALPHA; break;
3013 case GL_ONE_MINUS_SRC_COLOR: opr = GL_SRC_ALPHA; break;
3014 case GL_SRC_ALPHA: opr = GL_ONE_MINUS_SRC_ALPHA; break;
3015 case GL_ONE_MINUS_SRC_ALPHA: opr = GL_SRC_ALPHA; break;
3016 }
3017 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr);
3018 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
3019 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src1);
3020 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
3021 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr1);
3022 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
3023 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
3024 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
3025 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
3026 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
3027 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
3028 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
3029 } else
3030 Handled = FALSE;
3031 break;
3033 if (gl_info->supported[ATI_TEXTURE_ENV_COMBINE3])
3034 {
3035 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI);
3036 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
3037 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
3038 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
3039 switch (opr1) {
3040 case GL_SRC_COLOR: opr = GL_ONE_MINUS_SRC_COLOR; break;
3041 case GL_ONE_MINUS_SRC_COLOR: opr = GL_SRC_COLOR; break;
3042 case GL_SRC_ALPHA: opr = GL_ONE_MINUS_SRC_ALPHA; break;
3043 case GL_ONE_MINUS_SRC_ALPHA: opr = GL_SRC_ALPHA; break;
3044 }
3045 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr);
3046 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
3047 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src1);
3048 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
3049 switch (opr1) {
3050 case GL_SRC_COLOR: opr = GL_SRC_ALPHA; break;
3052 case GL_SRC_ALPHA: opr = GL_SRC_ALPHA; break;
3054 }
3055 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr);
3056 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
3057 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
3058 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
3059 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
3060 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
3061 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
3062 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
3063 } else
3064 Handled = FALSE;
3065 break;
3067 if (gl_info->supported[ATI_TEXTURE_ENV_COMBINE3])
3068 {
3069 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI);
3070 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
3071 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
3072 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
3073 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
3074 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
3075 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src3);
3076 checkGLcall("GL_TEXTURE_ENV, src1_target, src3");
3077 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr3);
3078 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr3");
3079 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
3080 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
3081 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
3082 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
3083 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
3084 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
3085 } else
3086 Handled = FALSE;
3087 break;
3090 if (gl_info->supported[NV_TEXTURE_SHADER2])
3091 {
3092 /* Technically texture shader support without register combiners is possible, but not expected to occur
3093 * on real world cards, so for now a fixme should be enough
3094 */
3095 FIXME("Implement bump mapping with GL_NV_texture_shader in non register combiner path\n");
3096 }
3097 Handled = FALSE;
3098 break;
3099
3100 default:
3101 Handled = FALSE;
3102 }
3103
3104 if (Handled) {
3105 BOOL combineOK = TRUE;
3106 if (gl_info->supported[NV_TEXTURE_ENV_COMBINE4])
3107 {
3108 DWORD op2;
3109
3110 if (isAlpha)
3111 op2 = state->texture_states[Stage][WINED3D_TSS_COLOR_OP];
3112 else
3113 op2 = state->texture_states[Stage][WINED3D_TSS_ALPHA_OP];
3114
3115 /* Note: If COMBINE4 in effect can't go back to combine! */
3116 switch (op2)
3117 {
3125 /* Ignore those implemented in both cases */
3126 switch (op)
3127 {
3130 combineOK = FALSE;
3131 Handled = FALSE;
3132 break;
3133 default:
3134 FIXME("Can't use COMBINE4 and COMBINE together, thisop=%s, otherop=%s, isAlpha(%d)\n", debug_d3dtop(op), debug_d3dtop(op2), isAlpha);
3135 return;
3136 }
3137 }
3138 }
3139
3140 if (combineOK)
3141 {
3142 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
3143 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE");
3144
3145 return;
3146 }
3147 }
3148
3149 /* After all the extensions, if still unhandled, report fixme */
3150 FIXME("Unhandled texture operation %s\n", debug_d3dtop(op));
3151}
static void get_src_and_opr(DWORD arg, BOOL is_alpha, GLenum *source, GLenum *operand)
Definition: state.c:2064
BOOL is_invalid_op(const struct wined3d_state *state, int stage, enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3)
Definition: utils.c:4865
const char * debug_d3dtop(enum wined3d_texture_op d3dtop)
Definition: utils.c:4589
#define GL_OPERAND2_RGB
Definition: gl.h:1837