I think this is an improvement, but I don't feel too strongly about it.
From: Zebediah Figura zfigura@codeweavers.com
The entire rest of state.c is concerned with the GL fixed-function pipeline.
device.c seems the most fitting place for these, since they're associated with the device and stored in the device. device.c is also one of the few files that contains client-side code, which these functions are. --- dlls/wined3d/device.c | 228 ++++++++++++++++++++++++++++++++++++++++++ dlls/wined3d/state.c | 226 ----------------------------------------- 2 files changed, 228 insertions(+), 226 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 4aeade1d2de..1d6a6c78dca 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -8,6 +8,8 @@ * Copyright 2006-2008 Henri Verbeet * Copyright 2007 Andrew Riedi * Copyright 2009-2011 Henri Verbeet for CodeWeavers + * Copyright 2016, 2018 Józef Kucia for CodeWeavers + * Copyright 2020 Zebediah Figura * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -270,6 +272,232 @@ ULONG CDECL wined3d_device_decref(struct wined3d_device *device) return refcount; }
+ULONG CDECL wined3d_blend_state_incref(struct wined3d_blend_state *state) +{ + unsigned int refcount = InterlockedIncrement(&state->refcount); + + TRACE("%p increasing refcount to %u.\n", state, refcount); + + return refcount; +} + +static void wined3d_blend_state_destroy_object(void *object) +{ + TRACE("object %p.\n", object); + + heap_free(object); +} + +ULONG CDECL wined3d_blend_state_decref(struct wined3d_blend_state *state) +{ + unsigned int refcount = wined3d_atomic_decrement_mutex_lock(&state->refcount); + struct wined3d_device *device = state->device; + + TRACE("%p decreasing refcount to %u.\n", state, refcount); + + if (!refcount) + { + state->parent_ops->wined3d_object_destroyed(state->parent); + wined3d_cs_destroy_object(device->cs, wined3d_blend_state_destroy_object, state); + wined3d_mutex_unlock(); + } + + return refcount; +} + +void * CDECL wined3d_blend_state_get_parent(const struct wined3d_blend_state *state) +{ + TRACE("state %p.\n", state); + + return state->parent; +} + +static bool is_dual_source(enum wined3d_blend state) +{ + return state >= WINED3D_BLEND_SRC1COLOR && state <= WINED3D_BLEND_INVSRC1ALPHA; +} + +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) +{ + struct wined3d_blend_state *object; + + TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n", + device, desc, parent, parent_ops, state); + + if (!(object = heap_alloc_zero(sizeof(*object)))) + return E_OUTOFMEMORY; + + object->refcount = 1; + object->desc = *desc; + object->parent = parent; + object->parent_ops = parent_ops; + object->device = device; + + object->dual_source = desc->rt[0].enable + && (is_dual_source(desc->rt[0].src) + || is_dual_source(desc->rt[0].dst) + || is_dual_source(desc->rt[0].src_alpha) + || is_dual_source(desc->rt[0].dst_alpha)); + + TRACE("Created blend state %p.\n", object); + *state = object; + + return WINED3D_OK; +} + +ULONG CDECL wined3d_depth_stencil_state_incref(struct wined3d_depth_stencil_state *state) +{ + unsigned int refcount = InterlockedIncrement(&state->refcount); + + TRACE("%p increasing refcount to %u.\n", state, refcount); + + return refcount; +} + +static void wined3d_depth_stencil_state_destroy_object(void *object) +{ + TRACE("object %p.\n", object); + + heap_free(object); +} + +ULONG CDECL wined3d_depth_stencil_state_decref(struct wined3d_depth_stencil_state *state) +{ + unsigned int refcount = wined3d_atomic_decrement_mutex_lock(&state->refcount); + struct wined3d_device *device = state->device; + + TRACE("%p decreasing refcount to %u.\n", state, refcount); + + if (!refcount) + { + state->parent_ops->wined3d_object_destroyed(state->parent); + wined3d_cs_destroy_object(device->cs, wined3d_depth_stencil_state_destroy_object, state); + wined3d_mutex_unlock(); + } + + return refcount; +} + +void * CDECL wined3d_depth_stencil_state_get_parent(const struct wined3d_depth_stencil_state *state) +{ + TRACE("state %p.\n", state); + + return state->parent; +} + +static bool stencil_op_writes_ds(const struct wined3d_stencil_op_desc *desc) +{ + return desc->fail_op != WINED3D_STENCIL_OP_KEEP + || desc->depth_fail_op != WINED3D_STENCIL_OP_KEEP + || desc->pass_op != WINED3D_STENCIL_OP_KEEP; +} + +static bool depth_stencil_state_desc_writes_ds(const struct wined3d_depth_stencil_state_desc *desc) +{ + if (desc->depth && desc->depth_write) + return true; + + if (desc->stencil && desc->stencil_write_mask) + { + if (stencil_op_writes_ds(&desc->front) || stencil_op_writes_ds(&desc->back)) + return true; + } + + return false; +} + +HRESULT CDECL wined3d_depth_stencil_state_create(struct wined3d_device *device, + const struct wined3d_depth_stencil_state_desc *desc, void *parent, + const struct wined3d_parent_ops *parent_ops, struct wined3d_depth_stencil_state **state) +{ + struct wined3d_depth_stencil_state *object; + + TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n", + device, desc, parent, parent_ops, state); + + if (!(object = heap_alloc_zero(sizeof(*object)))) + return E_OUTOFMEMORY; + + object->refcount = 1; + object->desc = *desc; + object->parent = parent; + object->parent_ops = parent_ops; + object->device = device; + + object->writes_ds = depth_stencil_state_desc_writes_ds(desc); + + TRACE("Created depth/stencil state %p.\n", object); + *state = object; + + return WINED3D_OK; +} + +ULONG CDECL wined3d_rasterizer_state_incref(struct wined3d_rasterizer_state *state) +{ + unsigned int refcount = InterlockedIncrement(&state->refcount); + + TRACE("%p increasing refcount to %u.\n", state, refcount); + + return refcount; +} + +static void wined3d_rasterizer_state_destroy_object(void *object) +{ + TRACE("object %p.\n", object); + + heap_free(object); +} + +ULONG CDECL wined3d_rasterizer_state_decref(struct wined3d_rasterizer_state *state) +{ + unsigned int refcount = wined3d_atomic_decrement_mutex_lock(&state->refcount); + struct wined3d_device *device = state->device; + + TRACE("%p decreasing refcount to %u.\n", state, refcount); + + if (!refcount) + { + state->parent_ops->wined3d_object_destroyed(state->parent); + wined3d_cs_destroy_object(device->cs, wined3d_rasterizer_state_destroy_object, state); + wined3d_mutex_unlock(); + } + + return refcount; +} + +void * CDECL wined3d_rasterizer_state_get_parent(const struct wined3d_rasterizer_state *state) +{ + TRACE("rasterizer_state %p.\n", state); + + return state->parent; +} + +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) +{ + struct wined3d_rasterizer_state *object; + + TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n", + device, desc, parent, parent_ops, state); + + if (!(object = heap_alloc_zero(sizeof(*object)))) + return E_OUTOFMEMORY; + + object->refcount = 1; + object->desc = *desc; + object->parent = parent; + object->parent_ops = parent_ops; + object->device = device; + + TRACE("Created rasterizer state %p.\n", object); + *state = object; + + return WINED3D_OK; +} + UINT CDECL wined3d_device_get_swapchain_count(const struct wined3d_device *device) { TRACE("device %p.\n", device); diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 2fb75785daf..4183de6e638 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -32,232 +32,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
-ULONG CDECL wined3d_blend_state_incref(struct wined3d_blend_state *state) -{ - unsigned int refcount = InterlockedIncrement(&state->refcount); - - TRACE("%p increasing refcount to %u.\n", state, refcount); - - return refcount; -} - -static void wined3d_blend_state_destroy_object(void *object) -{ - TRACE("object %p.\n", object); - - heap_free(object); -} - -ULONG CDECL wined3d_blend_state_decref(struct wined3d_blend_state *state) -{ - unsigned int refcount = wined3d_atomic_decrement_mutex_lock(&state->refcount); - struct wined3d_device *device = state->device; - - TRACE("%p decreasing refcount to %u.\n", state, refcount); - - if (!refcount) - { - state->parent_ops->wined3d_object_destroyed(state->parent); - wined3d_cs_destroy_object(device->cs, wined3d_blend_state_destroy_object, state); - wined3d_mutex_unlock(); - } - - return refcount; -} - -void * CDECL wined3d_blend_state_get_parent(const struct wined3d_blend_state *state) -{ - TRACE("state %p.\n", state); - - return state->parent; -} - -static BOOL is_dual_source(enum wined3d_blend state) -{ - return state >= WINED3D_BLEND_SRC1COLOR && state <= WINED3D_BLEND_INVSRC1ALPHA; -} - -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) -{ - struct wined3d_blend_state *object; - - TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n", - device, desc, parent, parent_ops, state); - - if (!(object = heap_alloc_zero(sizeof(*object)))) - return E_OUTOFMEMORY; - - object->refcount = 1; - object->desc = *desc; - object->parent = parent; - object->parent_ops = parent_ops; - object->device = device; - - object->dual_source = desc->rt[0].enable - && (is_dual_source(desc->rt[0].src) - || is_dual_source(desc->rt[0].dst) - || is_dual_source(desc->rt[0].src_alpha) - || is_dual_source(desc->rt[0].dst_alpha)); - - TRACE("Created blend state %p.\n", object); - *state = object; - - return WINED3D_OK; -} - -ULONG CDECL wined3d_depth_stencil_state_incref(struct wined3d_depth_stencil_state *state) -{ - unsigned int refcount = InterlockedIncrement(&state->refcount); - - TRACE("%p increasing refcount to %u.\n", state, refcount); - - return refcount; -} - -static void wined3d_depth_stencil_state_destroy_object(void *object) -{ - TRACE("object %p.\n", object); - - heap_free(object); -} - -ULONG CDECL wined3d_depth_stencil_state_decref(struct wined3d_depth_stencil_state *state) -{ - unsigned int refcount = wined3d_atomic_decrement_mutex_lock(&state->refcount); - struct wined3d_device *device = state->device; - - TRACE("%p decreasing refcount to %u.\n", state, refcount); - - if (!refcount) - { - state->parent_ops->wined3d_object_destroyed(state->parent); - wined3d_cs_destroy_object(device->cs, wined3d_depth_stencil_state_destroy_object, state); - wined3d_mutex_unlock(); - } - - return refcount; -} - -void * CDECL wined3d_depth_stencil_state_get_parent(const struct wined3d_depth_stencil_state *state) -{ - TRACE("state %p.\n", state); - - return state->parent; -} - -static bool stencil_op_writes_ds(const struct wined3d_stencil_op_desc *desc) -{ - return desc->fail_op != WINED3D_STENCIL_OP_KEEP - || desc->depth_fail_op != WINED3D_STENCIL_OP_KEEP - || desc->pass_op != WINED3D_STENCIL_OP_KEEP; -} - -static bool depth_stencil_state_desc_writes_ds(const struct wined3d_depth_stencil_state_desc *desc) -{ - if (desc->depth && desc->depth_write) - return true; - - if (desc->stencil && desc->stencil_write_mask) - { - if (stencil_op_writes_ds(&desc->front) || stencil_op_writes_ds(&desc->back)) - return true; - } - - return false; -} - -HRESULT CDECL wined3d_depth_stencil_state_create(struct wined3d_device *device, - const struct wined3d_depth_stencil_state_desc *desc, void *parent, - const struct wined3d_parent_ops *parent_ops, struct wined3d_depth_stencil_state **state) -{ - struct wined3d_depth_stencil_state *object; - - TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n", - device, desc, parent, parent_ops, state); - - if (!(object = heap_alloc_zero(sizeof(*object)))) - return E_OUTOFMEMORY; - - object->refcount = 1; - object->desc = *desc; - object->parent = parent; - object->parent_ops = parent_ops; - object->device = device; - - object->writes_ds = depth_stencil_state_desc_writes_ds(desc); - - TRACE("Created depth/stencil state %p.\n", object); - *state = object; - - return WINED3D_OK; -} - -ULONG CDECL wined3d_rasterizer_state_incref(struct wined3d_rasterizer_state *state) -{ - unsigned int refcount = InterlockedIncrement(&state->refcount); - - TRACE("%p increasing refcount to %u.\n", state, refcount); - - return refcount; -} - -static void wined3d_rasterizer_state_destroy_object(void *object) -{ - TRACE("object %p.\n", object); - - heap_free(object); -} - -ULONG CDECL wined3d_rasterizer_state_decref(struct wined3d_rasterizer_state *state) -{ - unsigned int refcount = wined3d_atomic_decrement_mutex_lock(&state->refcount); - struct wined3d_device *device = state->device; - - TRACE("%p decreasing refcount to %u.\n", state, refcount); - - if (!refcount) - { - state->parent_ops->wined3d_object_destroyed(state->parent); - wined3d_cs_destroy_object(device->cs, wined3d_rasterizer_state_destroy_object, state); - wined3d_mutex_unlock(); - } - - return refcount; -} - -void * CDECL wined3d_rasterizer_state_get_parent(const struct wined3d_rasterizer_state *state) -{ - TRACE("rasterizer_state %p.\n", state); - - return state->parent; -} - -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) -{ - struct wined3d_rasterizer_state *object; - - TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n", - device, desc, parent, parent_ops, state); - - if (!(object = heap_alloc_zero(sizeof(*object)))) - return E_OUTOFMEMORY; - - object->refcount = 1; - object->desc = *desc; - object->parent = parent; - object->parent_ops = parent_ops; - object->device = device; - - TRACE("Created rasterizer state %p.\n", object); - *state = object; - - return WINED3D_OK; -} - /* Context activation for state handler is done by the caller. */
static void state_undefined(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
From: Zebediah Figura zfigura@codeweavers.com
Better reflect its contents.
There is still a small amount of code in this file not directly related to the FFP:
- compile_state_table(), which should eventually go away;
- states like state_so() and indexbuffer(), which should eventually be moved to context_gl.c with the rest of the resource loading/binding code. --- dlls/wined3d/Makefile.in | 2 +- dlls/wined3d/{state.c => ffp_gl.c} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename dlls/wined3d/{state.c => ffp_gl.c} (99%)
diff --git a/dlls/wined3d/Makefile.in b/dlls/wined3d/Makefile.in index 35de4aec8da..9223ecd77c9 100644 --- a/dlls/wined3d/Makefile.in +++ b/dlls/wined3d/Makefile.in @@ -15,6 +15,7 @@ SOURCES = \ cs.c \ device.c \ directx.c \ + ffp_gl.c \ gl_compat.c \ glsl_shader.c \ nvidia_texture_shader.c \ @@ -26,7 +27,6 @@ SOURCES = \ shader_sm1.c \ shader_sm4.c \ shader_spirv.c \ - state.c \ stateblock.c \ surface.c \ swapchain.c \ diff --git a/dlls/wined3d/state.c b/dlls/wined3d/ffp_gl.c similarity index 99% rename from dlls/wined3d/state.c rename to dlls/wined3d/ffp_gl.c index 4183de6e638..de350241b05 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/ffp_gl.c @@ -1,5 +1,5 @@ /* - * Direct3D state management + * GL fixed-function pipeline * * Copyright 2002 Lionel Ulmer * Copyright 2002-2005 Jason Edmeades
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/wined3d/ffp_gl.c | 115 ++++++++++++++++++++++++++++++++++++++++++ dlls/wined3d/utils.c | 112 ---------------------------------------- 2 files changed, 115 insertions(+), 112 deletions(-)
diff --git a/dlls/wined3d/ffp_gl.c b/dlls/wined3d/ffp_gl.c index de350241b05..d52d198e545 100644 --- a/dlls/wined3d/ffp_gl.c +++ b/dlls/wined3d/ffp_gl.c @@ -1314,6 +1314,121 @@ void state_fogdensity(struct wined3d_context *context, const struct wined3d_stat checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)"); }
+/* Activates the texture dimension according to the bound D3D texture. Does + * not care for the colorop or correct gl texture unit (when using nvrc). + * Requires the caller to activate the correct unit. */ +/* Context activation is done by the caller (state handler). */ +void texture_activate_dimensions(struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info) +{ + if (texture) + { + switch (wined3d_texture_gl(texture)->target) + { + case GL_TEXTURE_2D: + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); + checkGLcall("glDisable(GL_TEXTURE_3D)"); + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB); + checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); + } + if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) + { + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB); + checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); + } + gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_2D); + checkGLcall("glEnable(GL_TEXTURE_2D)"); + break; + + case GL_TEXTURE_RECTANGLE_ARB: + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); + checkGLcall("glDisable(GL_TEXTURE_2D)"); + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); + checkGLcall("glDisable(GL_TEXTURE_3D)"); + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB); + checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); + } + gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_RECTANGLE_ARB); + checkGLcall("glEnable(GL_TEXTURE_RECTANGLE_ARB)"); + break; + + case GL_TEXTURE_3D: + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB); + checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); + } + if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) + { + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB); + checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); + } + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); + checkGLcall("glDisable(GL_TEXTURE_2D)"); + gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_3D); + checkGLcall("glEnable(GL_TEXTURE_3D)"); + break; + + case GL_TEXTURE_CUBE_MAP_ARB: + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); + checkGLcall("glDisable(GL_TEXTURE_2D)"); + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); + checkGLcall("glDisable(GL_TEXTURE_3D)"); + if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) + { + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB); + checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); + } + gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_CUBE_MAP_ARB); + checkGLcall("glEnable(GL_TEXTURE_CUBE_MAP_ARB)"); + break; + } + } + else + { + gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_2D); + checkGLcall("glEnable(GL_TEXTURE_2D)"); + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); + checkGLcall("glDisable(GL_TEXTURE_3D)"); + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB); + checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); + } + if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) + { + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB); + checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); + } + /* Binding textures is done by samplers. A dummy texture will be bound. */ + } +} + +/* Context activation is done by the caller (state handler). */ +void sampler_texdim(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) +{ + struct wined3d_context_gl *context_gl = wined3d_context_gl(context); + unsigned int sampler = state_id - STATE_SAMPLER(0); + unsigned int mapped_stage; + + /* No need to enable / disable anything here for unused samplers. The + * tex_colorop handler takes care. Also no action is needed with pixel + * shaders, or if tex_colorop will take care of this business. */ + mapped_stage = context_gl->tex_unit_map[sampler]; + if (mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= context_gl->gl_info->limits.ffp_textures) + return; + if (sampler >= context->lowest_disabled_stage) + return; + if (isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3D_TSS_COLOR_OP))) + return; + + wined3d_context_gl_active_texture(context_gl, context_gl->gl_info, sampler); + texture_activate_dimensions(wined3d_state_get_ffp_texture(state, sampler), context_gl->gl_info); +} + static void state_colormat(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { struct wined3d_context_gl *context_gl = wined3d_context_gl(context); diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index a46a4c7257d..9e493ba120a 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6703,118 +6703,6 @@ void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *des } }
-/* Activates the texture dimension according to the bound D3D texture. Does - * not care for the colorop or correct gl texture unit (when using nvrc). - * Requires the caller to activate the correct unit. */ -/* Context activation is done by the caller (state handler). */ -void texture_activate_dimensions(struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info) -{ - if (texture) - { - switch (wined3d_texture_gl(texture)->target) - { - case GL_TEXTURE_2D: - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); - checkGLcall("glDisable(GL_TEXTURE_3D)"); - if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) - { - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB); - checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); - } - if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) - { - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB); - checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); - } - gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_2D); - checkGLcall("glEnable(GL_TEXTURE_2D)"); - break; - case GL_TEXTURE_RECTANGLE_ARB: - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); - checkGLcall("glDisable(GL_TEXTURE_2D)"); - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); - checkGLcall("glDisable(GL_TEXTURE_3D)"); - if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) - { - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB); - checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); - } - gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_RECTANGLE_ARB); - checkGLcall("glEnable(GL_TEXTURE_RECTANGLE_ARB)"); - break; - case GL_TEXTURE_3D: - if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) - { - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB); - checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); - } - if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) - { - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB); - checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); - } - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); - checkGLcall("glDisable(GL_TEXTURE_2D)"); - gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_3D); - checkGLcall("glEnable(GL_TEXTURE_3D)"); - break; - case GL_TEXTURE_CUBE_MAP_ARB: - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); - checkGLcall("glDisable(GL_TEXTURE_2D)"); - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); - checkGLcall("glDisable(GL_TEXTURE_3D)"); - if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) - { - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB); - checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); - } - gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_CUBE_MAP_ARB); - checkGLcall("glEnable(GL_TEXTURE_CUBE_MAP_ARB)"); - break; - } - } - else - { - gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_2D); - checkGLcall("glEnable(GL_TEXTURE_2D)"); - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); - checkGLcall("glDisable(GL_TEXTURE_3D)"); - if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) - { - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB); - checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); - } - if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) - { - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB); - checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); - } - /* Binding textures is done by samplers. A dummy texture will be bound */ - } -} - -/* Context activation is done by the caller (state handler). */ -void sampler_texdim(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) -{ - struct wined3d_context_gl *context_gl = wined3d_context_gl(context); - unsigned int sampler = state_id - STATE_SAMPLER(0); - unsigned int mapped_stage; - - /* No need to enable / disable anything here for unused samplers. The - * tex_colorop handler takes care. Also no action is needed with pixel - * shaders, or if tex_colorop will take care of this business. */ - mapped_stage = context_gl->tex_unit_map[sampler]; - if (mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= context_gl->gl_info->limits.ffp_textures) - return; - if (sampler >= context->lowest_disabled_stage) - return; - if (isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3D_TSS_COLOR_OP))) - return; - - wined3d_context_gl_active_texture(context_gl, context_gl->gl_info, sampler); - texture_activate_dimensions(wined3d_state_get_ffp_texture(state, sampler), context_gl->gl_info); -} - int wined3d_ffp_frag_program_key_compare(const void *key, const struct wine_rb_entry *entry) { const struct ffp_frag_settings *ka = key;
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=142478
Your paranoid android.
=== debian11 (build log) ===
collect2: error: ld returned 1 exit status Task: The win32 Wine build failed
=== debian11b (build log) ===
collect2: error: ld returned 1 exit status Task: The wow64 Wine build failed
Mostly for context, the long term plan was to move the fixed-function GL bits out of state.c, either into context_gl.c/adapter_gl.c or their own file, rather than moving the actual state objects out. (Or rename state.c to ffp_gl.c, and then move state objects from ffp_gl.c to a "new" file state.c, if you like.) The idea was also that this would happen naturally as part of other long term state management changes, like e.g. getting rid of the state tables.
I suppose moving state objects to device.c works, although it feels somewhat arbitrary to move state objects there and not everything else, like e.g. sampler objects or views. (In fact, I'm inclined to argue for moving things out of device.c where possible; it sometimes feels like a collection of miscellaneous functionality that actually belongs elsewhere to me.)
Mostly for context, the long term plan was to move the fixed-function GL bits out of state.c, either into context_gl.c/adapter_gl.c or their own file, rather than moving the actual state objects out. (Or rename state.c to ffp_gl.c, and then move state objects from ffp_gl.c to a "new" file state.c, if you like.) The idea was also that this would happen naturally as part of other long term state management changes, like e.g. getting rid of the state tables.
The second one was basically what I was trying to do here.
I suppose I didn't see a particularly salient time to do the rename. I guess we could gradually move things to a new file, instead, but I suspect this is a little better, because we can still broadly keep many of the state callbacks by turning them into helpers, so that can preserve history.
I suppose moving state objects to device.c works, although it feels somewhat arbitrary to move state objects there and not everything else, like e.g. sampler objects or views. (In fact, I'm inclined to argue for moving things out of device.c where possible; it sometimes feels like a collection of miscellaneous functionality that actually belongs elsewhere to me.)
The thing is, by itself it's 228 lines of code, which seems a little too small to deserve its own file. That was the only reason I didn't do that.
I'd love to be able to split device.c but I'm not really sure how...
This merge request was approved by Jan Sikorski.