ReactOS  0.4.14-dev-98-gb0d4763
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)
 
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 3756 of file state.c.

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

◆ clipplane()

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

Definition at line 3833 of file state.c.

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

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 6139 of file state.c.

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

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 5814 of file state.c.

5815 {
5816  return shader_priv;
5817 }

◆ ffp_color_fixup_supported()

static BOOL ffp_color_fixup_supported ( struct color_fixup_desc  fixup)
static

Definition at line 5903 of file state.c.

5904 {
5905  /* We only support identity conversions. */
5906  return is_identity_fixup(fixup);
5907 }
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 5812 of file state.c.

5812 {}

◆ 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 5857 of file state.c.

5858 {
5859  caps->wined3d_caps = 0;
5860  caps->PrimitiveMiscCaps = 0;
5870 
5871  if (gl_info->supported[ARB_TEXTURE_ENV_COMBINE]
5872  || gl_info->supported[EXT_TEXTURE_ENV_COMBINE]
5873  || gl_info->supported[NV_TEXTURE_ENV_COMBINE4])
5874  {
5881  }
5882  if (gl_info->supported[ATI_TEXTURE_ENV_COMBINE3]
5883  || gl_info->supported[NV_TEXTURE_ENV_COMBINE4])
5884  {
5890  }
5891  if (gl_info->supported[ARB_TEXTURE_ENV_DOT3])
5893 
5894  caps->MaxTextureBlendStages = gl_info->limits.textures;
5895  caps->MaxSimultaneousTextures = gl_info->limits.textures;
5896 }
DWORD MaxTextureBlendStages
#define WINED3DTEXOPCAPS_DISABLE
Definition: wined3d.h:1145
#define WINED3DTEXOPCAPS_BLENDCURRENTALPHA
Definition: wined3d.h:1160
#define WINED3DTEXOPCAPS_ADDSIGNED
Definition: wined3d.h:1152
#define WINED3DTEXOPCAPS_MODULATE
Definition: wined3d.h:1148
#define WINED3DTEXOPCAPS_ADDSIGNED2X
Definition: wined3d.h:1153
#define WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA
Definition: wined3d.h:1156
#define WINED3DTEXOPCAPS_ADDSMOOTH
Definition: wined3d.h:1155
#define WINED3DTEXOPCAPS_SELECTARG2
Definition: wined3d.h:1147
#define WINED3DTEXOPCAPS_LERP
Definition: wined3d.h:1170
#define WINED3DTEXOPCAPS_BLENDFACTORALPHA
Definition: wined3d.h:1158
BOOL supported[WINED3D_GL_EXT_COUNT]
#define WINED3DTEXOPCAPS_DOTPRODUCT3
Definition: wined3d.h:1168
#define WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM
Definition: wined3d.h:1159
#define WINED3DTEXOPCAPS_MODULATE4X
Definition: wined3d.h:1150
#define WINED3DTEXOPCAPS_SELECTARG1
Definition: wined3d.h:1146
#define WINED3DTEXOPCAPS_MULTIPLYADD
Definition: wined3d.h:1169
DWORD MaxSimultaneousTextures
#define WINED3DTEXOPCAPS_MODULATE2X
Definition: wined3d.h:1149
#define WINED3DTEXOPCAPS_SUBTRACT
Definition: wined3d.h:1154
#define WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
Definition: wined3d.h:1163
struct wined3d_gl_limits limits
#define WINED3DTEXOPCAPS_BLENDTEXTUREALPHA
Definition: wined3d.h:1157
#define WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
Definition: wined3d.h:1162
#define WINED3DTEXOPCAPS_ADD
Definition: wined3d.h:1151

◆ ffp_fragment_get_emul_mask()

static DWORD ffp_fragment_get_emul_mask ( const struct wined3d_gl_info gl_info)
static

Definition at line 5898 of file state.c.

5899 {
5901 }
#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 5819 of file state.c.

5819 {}

◆ ffp_none_context_alloc()

static BOOL ffp_none_context_alloc ( struct wined3d_context context)
static

Definition at line 5909 of file state.c.

5910 {
5911  return TRUE;
5912 }
#define TRUE
Definition: types.h:120

◆ ffp_none_context_free()

static void ffp_none_context_free ( struct wined3d_context context)
static

Definition at line 5914 of file state.c.

5915 {
5916 }

◆ fp_none_color_fixup_supported()

static BOOL fp_none_color_fixup_supported ( struct color_fixup_desc  fixup)
static

Definition at line 5969 of file state.c.

5970 {
5971  return is_identity_fixup(fixup);
5972 }
static BOOL is_identity_fixup(struct color_fixup_desc fixup)

◆ 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 5959 of file state.c.

5960 {
5961  memset(caps, 0, sizeof(*caps));
5962 }
#define memset(x, y, z)
Definition: compat.h:39

◆ fp_none_get_emul_mask()

static DWORD fp_none_get_emul_mask ( const struct wined3d_gl_info gl_info)
static

Definition at line 5964 of file state.c.

5965 {
5966  return 0;
5967 }

◆ frontface()

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

Definition at line 4941 of file state.c.

4942 {
4943  const struct wined3d_gl_info *gl_info = context->gl_info;
4944  GLenum mode;
4945 
4946  mode = state->rasterizer_state && state->rasterizer_state->desc.front_ccw ? GL_CCW : GL_CW;
4947  if (context->render_offscreen)
4948  mode = (mode == GL_CW) ? GL_CCW : GL_CW;
4949 
4950  gl_info->gl_ops.gl.p_glFrontFace(mode);
4951  checkGLcall("glFrontFace");
4952 }
struct opengl_funcs gl_ops
Definition: http.c:6587
#define GL_CCW
Definition: gl.h:269
static int state
Definition: maze.c:121
unsigned int GLenum
Definition: gl.h:150
GLenum mode
Definition: glext.h:6217
#define checkGLcall(A)
#define GL_CW
Definition: gl.h:268

◆ frontface_cc()

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

Definition at line 4954 of file state.c.

4955 {
4956  const struct wined3d_gl_info *gl_info = context->gl_info;
4957  GLenum mode;
4958 
4959  mode = state->rasterizer_state && state->rasterizer_state->desc.front_ccw ? GL_CCW : GL_CW;
4960 
4961  gl_info->gl_ops.gl.p_glFrontFace(mode);
4962  checkGLcall("glFrontFace");
4963 }
struct opengl_funcs gl_ops
Definition: http.c:6587
#define GL_CCW
Definition: gl.h:269
static int state
Definition: maze.c:121
unsigned int GLenum
Definition: gl.h:150
GLenum mode
Definition: glext.h:6217
#define checkGLcall(A)
#define GL_CW
Definition: gl.h:268

◆ get_src_and_opr()

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

Definition at line 2061 of file state.c.

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

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 4685 of file state.c.

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

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 454 of file state.c.

455 {
456  switch (factor)
457  {
458  case WINED3D_BLEND_ZERO:
459  return GL_ZERO;
460  case WINED3D_BLEND_ONE:
461  return GL_ONE;
463  return GL_SRC_COLOR;
465  return GL_ONE_MINUS_SRC_COLOR;
467  return GL_SRC_ALPHA;
469  return GL_ONE_MINUS_SRC_ALPHA;
471  return GL_DST_COLOR;
473  return GL_ONE_MINUS_DST_COLOR;
474  /* To compensate for the lack of format switching with backbuffer
475  * offscreen rendering, and with onscreen rendering, we modify the
476  * alpha test parameters for (INV)DESTALPHA if the render target
477  * doesn't support alpha blending. A nonexistent alpha channel
478  * returns 1.0, so WINED3D_BLEND_DESTALPHA becomes GL_ONE, and
479  * WINED3D_BLEND_INVDESTALPHA becomes GL_ZERO. */
481  return dst_format->alpha_size ? GL_DST_ALPHA : GL_ONE;
483  return dst_format->alpha_size ? GL_ONE_MINUS_DST_ALPHA : GL_ZERO;
485  return GL_SRC_ALPHA_SATURATE;
487  return GL_CONSTANT_COLOR_EXT;
491  return GL_SRC1_COLOR;
495  return GL_SRC1_ALPHA;
498  default:
499  if (!factor)
500  WARN("Unhandled blend factor %#x.\n", factor);
501  else
502  FIXME("Unhandled blend factor %#x.\n", factor);
503  return GL_NONE;
504  }
505 }
#define GL_DST_COLOR
Definition: gl.h:382
#define GL_ONE_MINUS_DST_ALPHA
Definition: gl.h:381
#define GL_ONE
Definition: gl.h:375
static const char * dst_format
Definition: dib.c:1133
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
#define WARN(fmt,...)
Definition: debug.h:111
#define GL_ONE_MINUS_SRC1_ALPHA
Definition: glext.h:2005
#define GL_ZERO
Definition: gl.h:374
#define FIXME(fmt,...)
Definition: debug.h:110
#define GL_ONE_MINUS_SRC_COLOR
Definition: gl.h:377
#define GL_ONE_MINUS_CONSTANT_COLOR_EXT
Definition: glext.h:2408
#define GL_NONE
Definition: gl.h:465
#define GL_DST_ALPHA
Definition: gl.h:380
#define GL_CONSTANT_COLOR_EXT
Definition: glext.h:2407
#define GL_ONE_MINUS_SRC_ALPHA
Definition: gl.h:379
#define GL_SRC_COLOR
Definition: gl.h:376
#define GL_SRC_ALPHA
Definition: gl.h:378
#define GL_ONE_MINUS_DST_COLOR
Definition: gl.h:383
#define GL_ONE_MINUS_SRC1_COLOR
Definition: glext.h:2004
#define GL_SRC1_COLOR
Definition: glext.h:2002
#define GL_SRC1_ALPHA
Definition: glext.h:381
#define GL_SRC_ALPHA_SATURATE
Definition: gl.h:384

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 507 of file state.c.

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

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 401 of file state.c.

402 {
403  switch (op)
404  {
406  return GL_FUNC_ADD;
412  return gl_info->supported[EXT_BLEND_MINMAX] ? GL_MIN : GL_FUNC_ADD;
414  return gl_info->supported[EXT_BLEND_MINMAX] ? GL_MAX : GL_FUNC_ADD;
415  default:
416  if (!op)
417  WARN("Unhandled blend op %#x.\n", op);
418  else
419  FIXME("Unhandled blend op %#x.\n", op);
420  return GL_FUNC_ADD;
421  }
422 }
#define GL_FUNC_REVERSE_SUBTRACT
Definition: gl.h:1628
#define WARN(fmt,...)
Definition: debug.h:111
#define GL_MIN
Definition: gl.h:1624
#define GL_FUNC_ADD
Definition: gl.h:1626
#define FIXME(fmt,...)
Definition: debug.h:110
BOOL supported[WINED3D_GL_EXT_COUNT]
#define GL_MAX
Definition: gl.h:1625
#define GL_FUNC_SUBTRACT
Definition: gl.h:1627
UINT op
Definition: effect.c:223

Referenced by state_blendop().

◆ gl_stencil_op()

static GLenum gl_stencil_op ( enum wined3d_stencil_op  op)
static

Definition at line 877 of file state.c.

878 {
879  switch (op)
880  {
882  return GL_KEEP;
884  return GL_ZERO;
886  return GL_REPLACE;
888  return GL_INCR;
890  return GL_DECR;
892  return GL_INVERT;
894  return GL_INCR_WRAP;
896  return GL_DECR_WRAP;
897  default:
898  if (!op)
899  WARN("Unrecognized stencil op %#x.\n", op);
900  else
901  FIXME("Unrecognized stencil op %#x.\n", op);
902  return GL_KEEP;
903  }
904 }
#define WARN(fmt,...)
Definition: debug.h:111
#define GL_INCR
Definition: gl.h:461
#define GL_ZERO
Definition: gl.h:374
#define FIXME(fmt,...)
Definition: debug.h:110
#define GL_INVERT
Definition: gl.h:435
#define GL_REPLACE
Definition: gl.h:460
#define GL_DECR_WRAP
Definition: glext.h:297
#define GL_KEEP
Definition: gl.h:459
#define GL_INCR_WRAP
Definition: glext.h:296
UINT op
Definition: effect.c:223
#define GL_DECR
Definition: gl.h:462

Referenced by state_stencil().

◆ indexbuffer()

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

Definition at line 4925 of file state.c.

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

◆ light()

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

Definition at line 4776 of file state.c.

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

Referenced by transform_view().

◆ 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 4074 of file state.c.

4076 {
4077  const struct wined3d_shader *vs = state->shader[WINED3D_SHADER_TYPE_VERTEX];
4078  const struct wined3d_gl_info *gl_info = context->gl_info;
4079  GLuint curVBO = gl_info->supported[ARB_VERTEX_BUFFER_OBJECT] ? ~0U : 0;
4080  unsigned int i;
4081 
4082  /* Default to no instancing */
4083  context->instance_count = 0;
4084 
4085  for (i = 0; i < MAX_ATTRIBS; ++i)
4086  {
4087  const struct wined3d_stream_info_element *element = &stream_info->elements[i];
4088  const struct wined3d_stream_state *stream;
4089 
4090  if (!(stream_info->use_map & (1u << i)))
4091  {
4092  if (context->numbered_array_mask & (1u << i))
4094  if (!use_vs(state) && i == WINED3D_FFP_DIFFUSE)
4095  GL_EXTCALL(glVertexAttrib4f(i, 1.0f, 1.0f, 1.0f, 1.0f));
4096  else
4097  GL_EXTCALL(glVertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 0.0f));
4098  continue;
4099  }
4100 
4101  stream = &state->streams[element->stream_idx];
4102 
4103  if ((stream->flags & WINED3DSTREAMSOURCE_INSTANCEDATA) && !context->instance_count)
4104  context->instance_count = state->streams[0].frequency ? state->streams[0].frequency : 1;
4105 
4106  if (gl_info->supported[ARB_INSTANCED_ARRAYS])
4107  {
4108  GL_EXTCALL(glVertexAttribDivisor(i, element->divisor));
4109  }
4110  else if (element->divisor)
4111  {
4112  /* Unload instanced arrays, they will be loaded using
4113  * immediate mode instead. */
4114  if (context->numbered_array_mask & (1u << i))
4116  continue;
4117  }
4118 
4119  TRACE_(d3d_shader)("Loading array %u [VBO=%u].\n", i, element->data.buffer_object);
4120 
4121  if (element->stride)
4122  {
4123  if (curVBO != element->data.buffer_object)
4124  {
4125  GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER, element->data.buffer_object));
4126  checkGLcall("glBindBuffer");
4127  curVBO = element->data.buffer_object;
4128  }
4129  /* Use the VBO to find out if a vertex buffer exists, not the vb
4130  * pointer. vb can point to a user pointer data blob. In that case
4131  * curVBO will be 0. If there is a vertex buffer but no vbo we
4132  * won't be load converted attributes anyway. */
4133  if (vs && vs->reg_maps.shader_version.major >= 4
4135  {
4136  GL_EXTCALL(glVertexAttribIPointer(i, element->format->gl_vtx_format, element->format->gl_vtx_type,
4137  element->stride, element->data.addr + state->load_base_vertex_index * element->stride));
4138  }
4139  else
4140  {
4141  GL_EXTCALL(glVertexAttribPointer(i, element->format->gl_vtx_format, element->format->gl_vtx_type,
4142  element->format->gl_normalized, element->stride,
4143  element->data.addr + state->load_base_vertex_index * element->stride));
4144  }
4145 
4146  if (!(context->numbered_array_mask & (1u << i)))
4147  {
4148  GL_EXTCALL(glEnableVertexAttribArray(i));
4149  context->numbered_array_mask |= (1u << i);
4150  }
4151  }
4152  else
4153  {
4154  /* Stride = 0 means always the same values.
4155  * glVertexAttribPointer doesn't do that. Instead disable the
4156  * pointer and set up the attribute statically. But we have to
4157  * figure out the system memory address. */
4158  const BYTE *ptr = element->data.addr;
4159  if (element->data.buffer_object)
4161 
4162  if (context->numbered_array_mask & (1u << i))
4164 
4165  switch (element->format->id)
4166  {
4167  case WINED3DFMT_R32_FLOAT:
4168  GL_EXTCALL(glVertexAttrib1fv(i, (const GLfloat *)ptr));
4169  break;
4171  GL_EXTCALL(glVertexAttrib2fv(i, (const GLfloat *)ptr));
4172  break;
4174  GL_EXTCALL(glVertexAttrib3fv(i, (const GLfloat *)ptr));
4175  break;
4177  GL_EXTCALL(glVertexAttrib4fv(i, (const GLfloat *)ptr));
4178  break;
4179 
4181  GL_EXTCALL(glVertexAttrib4ubv(i, ptr));
4182  break;
4184  if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA])
4185  {
4186  const DWORD *src = (const DWORD *)ptr;
4187  DWORD c = *src & 0xff00ff00u;
4188  c |= (*src & 0xff0000u) >> 16;
4189  c |= (*src & 0xffu) << 16;
4190  GL_EXTCALL(glVertexAttrib4Nubv(i, (GLubyte *)&c));
4191  break;
4192  }
4193  /* else fallthrough */
4195  GL_EXTCALL(glVertexAttrib4Nubv(i, ptr));
4196  break;
4197 
4199  GL_EXTCALL(glVertexAttrib2sv(i, (const GLshort *)ptr));
4200  break;
4202  GL_EXTCALL(glVertexAttrib4sv(i, (const GLshort *)ptr));
4203  break;
4204 
4206  {
4207  const GLshort s[4] = {((const GLshort *)ptr)[0], ((const GLshort *)ptr)[1], 0, 1};
4208  GL_EXTCALL(glVertexAttrib4Nsv(i, s));
4209  break;
4210  }
4212  {
4213  const GLushort s[4] = {((const GLushort *)ptr)[0], ((const GLushort *)ptr)[1], 0, 1};
4214  GL_EXTCALL(glVertexAttrib4Nusv(i, s));
4215  break;
4216  }
4218  GL_EXTCALL(glVertexAttrib4Nsv(i, (const GLshort *)ptr));
4219  break;
4221  GL_EXTCALL(glVertexAttrib4Nusv(i, (const GLushort *)ptr));
4222  break;
4223 
4225  FIXME("Unsure about WINED3DDECLTYPE_UDEC3.\n");
4226  /*glVertexAttrib3usvARB(i, (const GLushort *)ptr); Does not exist */
4227  break;
4229  FIXME("Unsure about WINED3DDECLTYPE_DEC3N.\n");
4230  /*glVertexAttrib3NusvARB(i, (const GLushort *)ptr); Does not exist */
4231  break;
4232 
4234  if (gl_info->supported[NV_HALF_FLOAT] && gl_info->supported[NV_VERTEX_PROGRAM])
4235  {
4236  /* Not supported by GL_ARB_half_float_vertex. */
4237  GL_EXTCALL(glVertexAttrib2hvNV(i, (const GLhalfNV *)ptr));
4238  }
4239  else
4240  {
4241  float x = float_16_to_32(((const unsigned short *)ptr) + 0);
4242  float y = float_16_to_32(((const unsigned short *)ptr) + 1);
4243  GL_EXTCALL(glVertexAttrib2f(i, x, y));
4244  }
4245  break;
4247  if (gl_info->supported[NV_HALF_FLOAT] && gl_info->supported[NV_VERTEX_PROGRAM])
4248  {
4249  /* Not supported by GL_ARB_half_float_vertex. */
4250  GL_EXTCALL(glVertexAttrib4hvNV(i, (const GLhalfNV *)ptr));
4251  }
4252  else
4253  {
4254  float x = float_16_to_32(((const unsigned short *)ptr) + 0);
4255  float y = float_16_to_32(((const unsigned short *)ptr) + 1);
4256  float z = float_16_to_32(((const unsigned short *)ptr) + 2);
4257  float w = float_16_to_32(((const unsigned short *)ptr) + 3);
4258  GL_EXTCALL(glVertexAttrib4f(i, x, y, z, w));
4259  }
4260  break;
4261 
4262  default:
4263  ERR("Unexpected declaration in stride 0 attributes.\n");
4264  break;
4265 
4266  }
4267  }
4268  }
4269  checkGLcall("Loading numbered arrays");
4270 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
BYTE * wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context)
Definition: buffer.c:706
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
Definition: http.c:6587
unsigned char GLubyte
Definition: gl.h:157
struct wined3d_shader_reg_maps reg_maps
#define WINED3DSTREAMSOURCE_INSTANCEDATA
Definition: wined3d.h:1003
#define U(x)
Definition: wordpad.c:44
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static void unload_numbered_array(struct wined3d_context *context, int i)
Definition: state.c:4050
static void stream_info(IStream *stream, HGLOBAL *hmem, int *size, int *pos)
#define WINED3DFMT_FLAG_INTEGER
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FIXME(fmt,...)
Definition: debug.h:110
static PVOID ptr
Definition: dispmode.c:27
BOOL supported[WINED3D_GL_EXT_COUNT]
GLdouble GLdouble z
Definition: glext.h:5874
unsigned short GLhalfNV
Definition: glext.h:5520
struct wined3d_vertex_shader vs
#define TRACE_(x)
Definition: compat.h:66
#define GL_EXTCALL(f)
GLfloat f
Definition: glext.h:7540
float float_16_to_32(const unsigned short in) DECLSPEC_HIDDEN
Definition: math.c:2247
const GLubyte * c
Definition: glext.h:8905
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
static int state
Definition: maze.c:121
unsigned char BYTE
Definition: mem.h:68
GLdouble s
Definition: gl.h:2039
GLenum src
Definition: glext.h:6340
#define ERR(fmt,...)
Definition: debug.h:109
short GLshort
Definition: gl.h:155
unsigned int GLuint
Definition: gl.h:159
#define checkGLcall(A)
#define GL_ARRAY_BUFFER
Definition: glext.h:336
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
float GLfloat
Definition: gl.h:161
#define MAX_ATTRIBS
#define ULONG_PTR
Definition: config.h:101
static BOOL use_vs(const struct wined3d_state *state)
unsigned short GLushort
Definition: gl.h:158

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 3348 of file state.c.

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

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 4272 of file state.c.

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

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 5994 of file state.c.

5995 {
5996  context->device->multistate_funcs[state_id][0](context, state, state_id);
5997  context->device->multistate_funcs[state_id][1](context, state, state_id);
5998 }
Definition: http.c:6587
static int state
Definition: maze.c:121

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 6000 of file state.c.

6001 {
6002  context->device->multistate_funcs[state_id][0](context, state, state_id);
6003  context->device->multistate_funcs[state_id][1](context, state, state_id);
6004  context->device->multistate_funcs[state_id][2](context, state, state_id);
6005 }
Definition: http.c:6587
static int state
Definition: maze.c:121

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 5932 of file state.c.

5933 {
5934  return shader_priv;
5935 }

◆ none_enable()

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

Definition at line 5930 of file state.c.

5930 {}

◆ none_free()

static void none_free ( struct wined3d_device device)
static

Definition at line 5937 of file state.c.

5937 {}

◆ num_handlers()

static unsigned int num_handlers ( const APPLYSTATEFUNC funcs)
static

Definition at line 5987 of file state.c.

5988 {
5989  unsigned int i;
5990  for(i = 0; funcs[i]; i++);
5991  return i;
5992 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static 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 6007 of file state.c.

6009 {
6010  unsigned int start, last, i;
6011 
6012  start = STATE_TEXTURESTAGE(d3d_info->limits.ffp_blend_stages, 0);
6014  for (i = start; i <= last; ++i)
6015  {
6016  state_table[i].representative = 0;
6017  state_table[i].apply = state_undefined;
6018  }
6019 
6020  start = STATE_TRANSFORM(WINED3D_TS_TEXTURE0 + d3d_info->limits.ffp_blend_stages);
6022  for (i = start; i <= last; ++i)
6023  {
6024  state_table[i].representative = 0;
6025  state_table[i].apply = state_undefined;
6026  }
6027 
6028  start = STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(d3d_info->limits.ffp_vertex_blend_matrices));
6030  for (i = start; i <= last; ++i)
6031  {
6032  state_table[i].representative = 0;
6033  state_table[i].apply = state_undefined;
6034  }
6035 }
#define STATE_TEXTURESTAGE(stage, num)
#define WINED3D_TS_WORLD_MATRIX(index)
Definition: wined3d.h:664
#define MAX_TEXTURES
POINT last
Definition: font.c:46
static const struct @239 state_table[]
#define STATE_TRANSFORM(a)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static void state_undefined(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
Definition: state.c:165
struct wined3d_d3d_limits limits
GLuint start
Definition: gl.h:1545
#define WINED3D_HIGHEST_TEXTURE_STATE
Definition: wined3d.h:595

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 4976 of file state.c.

4977 {
4978  const struct wined3d_gl_info *gl_info = context->gl_info;
4979  GLint origin = context->render_offscreen ? GL_LOWER_LEFT : GL_UPPER_LEFT;
4980 
4981  GL_EXTCALL(glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, origin));
4982  checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
4983 }
#define GL_POINT_SPRITE_COORD_ORIGIN
Definition: glext.h:460
Definition: http.c:6587
voidpf uLong int origin
Definition: ioapi.h:142
#define GL_LOWER_LEFT
Definition: glext.h:461
#define GL_UPPER_LEFT
Definition: glext.h:462
#define GL_EXTCALL(f)
#define checkGLcall(A)
int GLint
Definition: gl.h:156

◆ psorigin_w()

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

Definition at line 4965 of file state.c.

4966 {
4967  static BOOL warned;
4968 
4969  if (!warned)
4970  {
4971  WARN("Point sprite coordinate origin switching not supported.\n");
4972  warned = TRUE;
4973  }
4974 }
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:111
unsigned int BOOL
Definition: ntddk_ex.h:94

◆ 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 862 of file state.c.

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

Referenced by state_stencil().

◆ sampler()

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

Definition at line 3688 of file state.c.

3689 {
3690  DWORD sampler_idx = state_id - STATE_SAMPLER(0);
3691  DWORD mapped_stage = context->tex_unit_map[sampler_idx];
3692  const struct wined3d_gl_info *gl_info = context->gl_info;
3693 
3694  TRACE("Sampler %u.\n", sampler_idx);
3695 
3696  if (mapped_stage == WINED3D_UNMAPPED_STAGE)
3697  {
3698  TRACE("No sampler mapped to stage %u. Returning.\n", sampler_idx);
3699  return;
3700  }
3701 
3702  if (mapped_stage >= gl_info->limits.graphics_samplers)
3703  return;
3704  context_active_texture(context, gl_info, mapped_stage);
3705 
3706  if (state->textures[sampler_idx])
3707  {
3708  BOOL srgb = state->sampler_states[sampler_idx][WINED3D_SAMP_SRGB_TEXTURE];
3709  const DWORD *sampler_states = state->sampler_states[sampler_idx];
3710  struct wined3d_texture *texture = state->textures[sampler_idx];
3711  struct wined3d_device *device = context->device;
3712  struct wined3d_sampler_desc desc;
3713  struct wined3d_sampler *sampler;
3714  struct wine_rb_entry *entry;
3715 
3717 
3719 
3720  if ((entry = wine_rb_get(&device->samplers, &desc)))
3721  {
3723  }
3724  else
3725  {
3727  {
3728  ERR("Failed to create sampler.\n");
3729  return;
3730  }
3731  if (wine_rb_put(&device->samplers, &desc, &sampler->entry) == -1)
3732  {
3733  ERR("Failed to insert sampler.\n");
3735  return;
3736  }
3737  }
3738 
3739  wined3d_sampler_bind(sampler, mapped_stage, texture, context);
3740 
3741  /* Trigger shader constant reloading (for NP2 texcoord fixup) */
3742  if (!(texture->flags & WINED3D_TEXTURE_POW2_MAT_IDENT))
3743  context->constant_update_mask |= WINED3D_SHADER_CONST_PS_NP2_FIXUP;
3744  }
3745  else
3746  {
3748  if (gl_info->supported[ARB_SAMPLER_OBJECTS])
3749  {
3750  GL_EXTCALL(glBindSampler(mapped_stage, 0));
3751  checkGLcall("glBindSampler");
3752  }
3753  }
3754 }
Definition: http.c:6587
void context_active_texture(struct wined3d_context *context, const struct wined3d_gl_info *gl_info, unsigned int unit)
Definition: context.c:2717
#define WINED3D_TEXTURE_POW2_MAT_IDENT
void wined3d_sampler_bind(struct wined3d_sampler *sampler, unsigned int unit, struct wined3d_texture *texture, const struct wined3d_context *context)
Definition: sampler.c:184
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 context_bind_texture(struct wined3d_context *context, GLenum target, GLuint name)
Definition: context.c:2734
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
BOOL supported[WINED3D_GL_EXT_COUNT]
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
smooth NULL
Definition: ftsmooth.c:416
#define GL_EXTCALL(f)
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
#define WINE_RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:31
#define WINED3D_SHADER_CONST_PS_NP2_FIXUP
ULONG CDECL wined3d_sampler_decref(struct wined3d_sampler *sampler)
Definition: sampler.c:53
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GL_NONE
Definition: gl.h:465
static int state
Definition: maze.c:121
uint32_t entry
Definition: isohybrid.c:63
#define WINED3D_UNMAPPED_STAGE
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:3629
#define STATE_SAMPLER(num)
#define ERR(fmt,...)
Definition: debug.h:109
Definition: rbtree.h:35
const struct wined3d_parent_ops wined3d_null_parent_ops
Definition: directx.c:6815
static int wine_rb_put(struct wine_rb_tree *tree, const void *key, struct wine_rb_entry *entry)
Definition: rbtree.h:215
#define checkGLcall(A)
static struct wine_rb_entry * wine_rb_get(const struct wine_rb_tree *tree, const void *key)
Definition: rbtree.h:203
static void sampler(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
Definition: state.c:3688
void wined3d_texture_bind(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:729
struct wined3d_gl_limits limits
GLuint sampler
Definition: glext.h:7283

Referenced by apply_pixelshader(), and sampler_texmatrix().

◆ sampler_texmatrix()

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

Definition at line 3582 of file state.c.

3583 {
3584  const DWORD sampler = state_id - STATE_SAMPLER(0);
3585  const struct wined3d_texture *texture = state->textures[sampler];
3586 
3587  TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id);
3588 
3589  if (!texture)
3590  return;
3591 
3592  /* The fixed function np2 texture emulation uses the texture matrix to fix up the coordinates
3593  * wined3d_texture_apply_state_changes() multiplies the set matrix with a fixup matrix. Before the
3594  * scaling is reapplied or removed, the texture matrix has to be reapplied.
3595  */
3596  if (sampler < MAX_TEXTURES)
3597  {
3598  const BOOL tex_is_pow2 = !(texture->flags & WINED3D_TEXTURE_POW2_MAT_IDENT);
3599 
3600  if (tex_is_pow2 || (context->lastWasPow2Texture & (1u << sampler)))
3601  {
3602  if (tex_is_pow2)
3603  context->lastWasPow2Texture |= 1u << sampler;
3604  else
3605  context->lastWasPow2Texture &= ~(1u << sampler);
3606 
3608  }
3609  }
3610 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define STATE_TEXTURESTAGE(stage, num)
#define MAX_TEXTURES
Definition: http.c:6587
#define WINED3D_TEXTURE_POW2_MAT_IDENT
static void transform_texture(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
Definition: state.c:3310
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
unsigned long DWORD
Definition: ntddk_ex.h:95
static int state
Definition: maze.c:121
#define STATE_SAMPLER(num)
static void sampler(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
Definition: state.c:3688
GLuint sampler
Definition: glext.h:7283

◆ scissorrect()

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

Definition at line 4899 of file state.c.

4900 {
4901  const struct wined3d_gl_info *gl_info = context->gl_info;
4902  const RECT *r = &state->scissor_rect;
4903 
4904  /* Warning: glScissor uses window coordinates, not viewport coordinates,
4905  * so our viewport correction does not apply. Warning2: Even in windowed
4906  * mode the coords are relative to the window, not the screen. */
4907  TRACE("Setting new scissor rect to %s.\n", wine_dbgstr_rect(r));
4908 
4909  if (context->render_offscreen)
4910  {
4911  gl_info->gl_ops.gl.p_glScissor(r->left, r->top, r->right - r->left, r->bottom - r->top);
4912  }
4913  else
4914  {
4915  const struct wined3d_rendertarget_view *target = state->fb->render_targets[0];
4916  UINT height;
4917  UINT width;
4918 
4920  gl_info->gl_ops.gl.p_glScissor(r->left, height - r->bottom, r->right - r->left, r->bottom - r->top);
4921  }
4922  checkGLcall("glScissor");
4923 }
GLint GLint GLsizei width
Definition: gl.h:1546
struct opengl_funcs gl_ops
Definition: http.c:6587
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
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
#define TRACE(s)
Definition: solgame.cpp:4
const char * wine_dbgstr_rect(const RECT *rect)
static int state
Definition: maze.c:121
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define checkGLcall(A)
unsigned int UINT
Definition: ndis.h:50
GLenum target
Definition: glext.h:7315

◆ set_color_mask()

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

Definition at line 1585 of file state.c.

1586 {
1587  GL_EXTCALL(glColorMaski(index,
1592  checkGLcall("glColorMaski");
1593 }
#define GL_FALSE
Definition: gl.h:173
#define WINED3DCOLORWRITEENABLE_ALPHA
Definition: wined3d.h:855
GLenum GLint GLuint mask
Definition: glext.h:6028
#define WINED3DCOLORWRITEENABLE_RED
Definition: wined3d.h:852
#define WINED3DCOLORWRITEENABLE_GREEN
Definition: wined3d.h:853
GLuint index
Definition: glext.h:6031
#define GL_EXTCALL(f)
#define WINED3DCOLORWRITEENABLE_BLUE
Definition: wined3d.h:854
#define GL_TRUE
Definition: gl.h:174
#define checkGLcall(A)

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 2100 of file state.c.

2102 {
2103  GLenum src1, src2, src3;
2104  GLenum opr1, opr2, opr3;
2105  GLenum comb_target;
2106  GLenum src0_target, src1_target, src2_target;
2107  GLenum opr0_target, opr1_target, opr2_target;
2108  GLenum scal_target;
2109  GLenum opr=0, invopr, src3_target, opr3_target;
2110  BOOL Handled = FALSE;
2111 
2112  TRACE("Alpha?(%d), Stage:%d Op(%s), a1(%d), a2(%d), a3(%d)\n", isAlpha, Stage, debug_d3dtop(op), arg1, arg2, arg3);
2113 
2114  /* Operations usually involve two args, src0 and src1 and are operations
2115  * of the form (a1 <operation> a2). However, some of the more complex
2116  * operations take 3 parameters. Instead of the (sensible) addition of a3,
2117  * Microsoft added in a third parameter called a0. Therefore these are
2118  * operations of the form a0 <operation> a1 <operation> a2. I.e., the new
2119  * parameter goes to the front.
2120  *
2121  * However, below we treat the new (a0) parameter as src2/opr2, so in the
2122  * actual functions below, expect their syntax to differ slightly to those
2123  * listed in the manuals. I.e., replace arg1 with arg3, arg2 with arg1 and
2124  * arg3 with arg2. This affects WINED3DTOP_MULTIPLYADD and WINED3DTOP_LERP. */
2125 
2126  if (isAlpha)
2127  {
2128  comb_target = GL_COMBINE_ALPHA;
2129  src0_target = GL_SOURCE0_ALPHA;
2130  src1_target = GL_SOURCE1_ALPHA;
2131  src2_target = GL_SOURCE2_ALPHA;
2132  opr0_target = GL_OPERAND0_ALPHA;
2133  opr1_target = GL_OPERAND1_ALPHA;
2134  opr2_target = GL_OPERAND2_ALPHA;
2135  scal_target = GL_ALPHA_SCALE;
2136  }
2137  else
2138  {
2139  comb_target = GL_COMBINE_RGB;
2140  src0_target = GL_SOURCE0_RGB;
2141  src1_target = GL_SOURCE1_RGB;
2142  src2_target = GL_SOURCE2_RGB;
2143  opr0_target = GL_OPERAND0_RGB;
2144  opr1_target = GL_OPERAND1_RGB;
2145  opr2_target = GL_OPERAND2_RGB;
2146  scal_target = GL_RGB_SCALE;
2147  }
2148 
2149  /* If a texture stage references an invalid texture unit the stage just
2150  * passes through the result from the previous stage */
2151  if (is_invalid_op(state, Stage, op, arg1, arg2, arg3))
2152  {
2155  }
2156 
2157  if (isAlpha && !state->textures[Stage] && arg1 == WINED3DTA_TEXTURE)
2158  {
2159  get_src_and_opr(WINED3DTA_DIFFUSE, isAlpha, &src1, &opr1);
2160  } else {
2161  get_src_and_opr(arg1, isAlpha, &src1, &opr1);
2162  }
2163  get_src_and_opr(arg2, isAlpha, &src2, &opr2);
2164  get_src_and_opr(arg3, isAlpha, &src3, &opr3);
2165 
2166  TRACE("ct(%x), 1:(%x,%x), 2:(%x,%x), 3:(%x,%x)\n", comb_target, src1, opr1, src2, opr2, src3, opr3);
2167 
2168  Handled = TRUE; /* Assume will be handled */
2169 
2170  /* Other texture operations require special extensions: */
2171  if (gl_info->supported[NV_TEXTURE_ENV_COMBINE4])
2172  {
2173  if (isAlpha) {
2174  opr = GL_SRC_ALPHA;
2175  invopr = GL_ONE_MINUS_SRC_ALPHA;
2176  src3_target = GL_SOURCE3_ALPHA_NV;
2177  opr3_target = GL_OPERAND3_ALPHA_NV;
2178  } else {
2179  opr = GL_SRC_COLOR;
2180  invopr = GL_ONE_MINUS_SRC_COLOR;
2181  src3_target = GL_SOURCE3_RGB_NV;
2182  opr3_target = GL_OPERAND3_RGB_NV;
2183  }
2184  switch (op)
2185  {
2186  case WINED3D_TOP_DISABLE: /* Only for alpha */
2187  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2188  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2189  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, GL_PREVIOUS_EXT);
2190  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2191  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA);
2192  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2193  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2194  checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2195  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2196  checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2197  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO);
2198  checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2199  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
2200  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2201  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2202  checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2203  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
2204  checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2205  break;
2206 
2207  case WINED3D_TOP_SELECT_ARG1: /* = a1 * 1 + 0 * 0 */
2208  case WINED3D_TOP_SELECT_ARG2: /* = a2 * 1 + 0 * 0 */
2209  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2210  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2211  if (op == WINED3D_TOP_SELECT_ARG1)
2212  {
2213  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2214  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2215  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2216  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2217  }
2218  else
2219  {
2220  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src2);
2221  checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2222  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr2);
2223  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2224  }
2225  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2226  checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2227  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2228  checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2229  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO);
2230  checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2231  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
2232  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2233  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2234  checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2235  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
2236  checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2237  break;
2238 
2239  case WINED3D_TOP_MODULATE:
2240  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2241  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2242  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2243  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2244  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2245  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2246  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2247  checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2248  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2249  checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2250  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO);
2251  checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2252  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
2253  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2254  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2255  checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2256  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
2257  checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2258  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2259  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2260  break;
2262  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2263  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2264  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2265  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2266  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2267  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2268  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2269  checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2270  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2271  checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2272  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO);
2273  checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2274  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
2275  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2276  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2277  checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2278  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
2279  checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2280  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 2);
2281  checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2282  break;
2284  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2285  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2286  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2287  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2288  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2289  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2290  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2291  checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2292  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2293  checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2294  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO);
2295  checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2296  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
2297  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2298  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2299  checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2300  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
2301  checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2302  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 4);
2303  checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2304  break;
2305 
2306  case WINED3D_TOP_ADD:
2307  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2308  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2309  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2310  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2311  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2312  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2313  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2314  checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2315  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2316  checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2317  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2318  checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2319  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2320  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2321  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2322  checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2323  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, invopr);
2324  checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2325  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2326  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2327  break;
2328 
2330  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED);
2331  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2332  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2333  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2334  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2335  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2336  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2337  checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2338  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2339  checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2340  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2341  checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2342  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2343  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2344  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2345  checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2346  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, invopr);
2347  checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2348  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2349  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2350  break;
2351 
2353  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED);
2354  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2355  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2356  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2357  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2358  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2359  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2360  checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2361  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2362  checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2363  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2364  checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2365  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2366  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2367  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2368  checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2369  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, invopr);
2370  checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2371  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 2);
2372  checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2373  break;
2374 
2376  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2377  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2378  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2379  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2380  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2381  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2382  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2383  checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2384  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2385  checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2386  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2387  checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2388  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2389  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2390  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, src1);
2391  checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2392  switch (opr1) {
2393  case GL_SRC_COLOR: opr = GL_ONE_MINUS_SRC_COLOR; break;
2394  case GL_ONE_MINUS_SRC_COLOR: opr = GL_SRC_COLOR; break;
2395  case GL_SRC_ALPHA: opr = GL_ONE_MINUS_SRC_ALPHA; break;
2396  case GL_ONE_MINUS_SRC_ALPHA: opr = GL_SRC_ALPHA; break;
2397  }
2398  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
2399  checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2400  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2401  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2402  break;
2403 
2405  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2406  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2407  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2408  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2409  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2410  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2411  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_PRIMARY_COLOR);
2412  checkGLcall("GL_TEXTURE_ENV, src1_target, GL_PRIMARY_COLOR");
2413  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2414  checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2415  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2416  checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2417  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2418  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2419  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_PRIMARY_COLOR);
2420  checkGLcall("GL_TEXTURE_ENV, src3_target, GL_PRIMARY_COLOR");
2421  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA);
2422  checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2423  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2424  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2425  break;
2427  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2428  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2429  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2430  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2431  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2432  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2433  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_TEXTURE);
2434  checkGLcall("GL_TEXTURE_ENV, src1_target, GL_TEXTURE");
2435  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2436  checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2437  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2438  checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2439  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2440  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2441  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_TEXTURE);
2442  checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2443  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA);
2444  checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2445  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2446  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2447  break;
2449  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2450  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2451  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2452  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2453  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2454  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2455  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_CONSTANT);
2456  checkGLcall("GL_TEXTURE_ENV, src1_target, GL_CONSTANT");
2457  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2458  checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2459  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2460  checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2461  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2462  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2463  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_CONSTANT);
2464  checkGLcall("GL_TEXTURE_ENV, src3_target, GL_CONSTANT");
2465  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA);
2466  checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2467  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2468  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2469  break;
2471  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2472  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2473  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2474  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2475  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2476  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2477  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2478  checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2479  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2480  checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2481  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2482  checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2483  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2484  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2485  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_TEXTURE);
2486  checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2487  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA);
2488  checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2489  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2490  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2491  break;
2493  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2494  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2495  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1); /* a0 = src1/opr1 */
2496  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2497  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2498  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); /* a1 = 1 (see docs) */
2499  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2500  checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2501  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2502  checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2503  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2); /* a2 = arg2 */
2504  checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2505  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2506  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2"); /* a3 = src1 alpha */
2507  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, src1);
2508  checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2509  switch (opr) {
2510  case GL_SRC_COLOR: opr = GL_SRC_ALPHA; break;
2512  }
2513  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
2514  checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2515  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2516  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2517  break;
2519  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2520  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2521  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2522  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2523  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2524  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2525  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2526  checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2527  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2528  checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2529  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src1);
2530  checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2531  switch (opr1) {
2532  case GL_SRC_COLOR: opr = GL_SRC_ALPHA; break;
2534  }
2535  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
2536  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2537  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2538  checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2539  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, invopr);
2540  checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2541  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2542  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2543  break;
2545  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2546  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2547  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2548  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2549  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2550  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2551  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2552  checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2553  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2554  checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2555  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
2556  checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2557  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
2558  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2559  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, src1);
2560  checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2561  switch (opr1) {
2562  case GL_SRC_COLOR: opr = GL_ONE_MINUS_SRC_ALPHA; break;
2563  case GL_ONE_MINUS_SRC_COLOR: opr = GL_SRC_ALPHA; break;
2564  case GL_SRC_ALPHA: opr = GL_ONE_MINUS_SRC_ALPHA; break;
2565  case GL_ONE_MINUS_SRC_ALPHA: opr = GL_SRC_ALPHA; break;
2566  }
2567  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
2568  checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2569  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2570  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2571  break;
2573  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2574  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2575  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2576  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2577  switch (opr1) {
2578  case GL_SRC_COLOR: opr = GL_ONE_MINUS_SRC_COLOR; break;
2579  case GL_ONE_MINUS_SRC_COLOR: opr = GL_SRC_COLOR; break;
2580  case GL_SRC_ALPHA: opr = GL_ONE_MINUS_SRC_ALPHA; break;
2581  case GL_ONE_MINUS_SRC_ALPHA: opr = GL_SRC_ALPHA; break;
2582  }
2583  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr);
2584  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2585  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2586  checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2587  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2588  checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2589  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src1);
2590  checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2591  switch (opr1) {
2592  case GL_SRC_COLOR: opr = GL_SRC_ALPHA; break;
2594  }
2595  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
2596  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2597  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
2598  checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2599  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, invopr);
2600  checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2601  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2602  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2603  break;
2605  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2606  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2607  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src3);
2608  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2609  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr3);
2610  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2611  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
2612  checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2613  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
2614  checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2615  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, src1);
2616  checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2617  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr1);
2618  checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2619  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src3_target, src2);
2620  checkGLcall("GL_TEXTURE_ENV, src3_target, src3");
2621  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr2);
2622  checkGLcall("GL_TEXTURE_ENV, opr3_target, opr3");
2623  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2624  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2625  break;
2626 
2629  FIXME("Implement bump environment mapping in GL_NV_texture_env_combine4 path\n");
2630  Handled = FALSE;
2631  break;
2632 
2633  default:
2634  Handled = FALSE;
2635  }
2636  if (Handled)
2637  {
2638  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
2639  checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV");
2640 
2641  return;
2642  }
2643  } /* GL_NV_texture_env_combine4 */
2644 
2645  Handled = TRUE; /* Again, assume handled */
2646  switch (op) {
2647  case WINED3D_TOP_DISABLE: /* Only for alpha */
2648  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_REPLACE);
2649  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2650  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, GL_PREVIOUS_EXT);
2651  checkGLcall("GL_TEXTURE_ENV, src0_target, GL_PREVIOUS_EXT");
2652  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA);
2653  checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA");
2654  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2655  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2656  break;
2658  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_REPLACE);
2659  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2660  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2661  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2662  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2663  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2664  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2665  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2666  break;
2668  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_REPLACE);
2669  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2670  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src2);
2671  checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2672  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr2);
2673  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2674  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2675  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2676  break;
2677  case WINED3D_TOP_MODULATE:
2678  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE);
2679  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2680  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2681  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2682  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2683  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2684  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2685  checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2686  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2687  checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2688  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2689  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2690  break;
2692  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE);
2693  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2694  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2695  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2696  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2697  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2698  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2699  checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2700  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2701  checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2702  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 2);
2703  checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2704  break;
2706  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE);
2707  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2708  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2709  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2710  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2711  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2712  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2713  checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2714  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2715  checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2716  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 4);
2717  checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2718  break;
2719  case WINED3D_TOP_ADD:
2720  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
2721  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2722  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2723  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2724  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2725  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2726  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2727  checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2728  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2729  checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2730  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2731  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2732  break;
2734  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED);
2735  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2736  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2737  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2738  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2739  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2740  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2741  checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2742  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2743  checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2744  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2745  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2746  break;
2748  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED);
2749  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2750  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2751  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2752  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2753  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2754  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2755  checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2756  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2757  checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2758  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 2);
2759  checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2760  break;
2761  case WINED3D_TOP_SUBTRACT:
2762  if (gl_info->supported[ARB_TEXTURE_ENV_COMBINE])
2763  {
2764  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_SUBTRACT);
2765  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_SUBTRACT");
2766  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2767  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2768  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2769  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2770  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2771  checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2772  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2773  checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2774  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
2775  checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2776  } else {
2777  FIXME("This version of opengl does not support GL_SUBTRACT\n");
2778  }
2779  break;
2780 
2782  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE);
2783  checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2784  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
2785  checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2786  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
2787  checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2788  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
2789  checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2790  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
2791  checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2792  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_PRIMARY_COLOR);
2793  checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PRIMARY_COLOR");
2794  gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA);