These functions should be usable for Vulkan as well.
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/wined3d/shader.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 1f0fe13402c..611402ba9a7 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -26,7 +26,6 @@ #include <string.h>
#include "wined3d_private.h" -#include "wined3d_gl.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
@@ -2841,6 +2840,8 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3 { for (i = 0; i < shader->limits->sampler; ++i) { + enum wined3d_shader_tex_types type = WINED3D_SHADER_TEX_2D; + if (!shader->reg_maps.resource_info[i].type) continue;
@@ -2851,20 +2852,24 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3 continue; texture = texture_from_resource(view->resource);
- switch (wined3d_texture_gl(texture)->target) + switch (texture->resource.type) { - /* RECT textures are distinguished from 2D textures via np2_fixup */ - default: + case WINED3D_RTYPE_NONE: + case WINED3D_RTYPE_BUFFER: + case WINED3D_RTYPE_TEXTURE_1D: + assert(0); + + case WINED3D_RTYPE_TEXTURE_2D: + if (texture->resource.usage & WINED3DUSAGE_LEGACY_CUBEMAP) + type = WINED3D_SHADER_TEX_CUBE; break;
- case GL_TEXTURE_3D: - args->tex_types |= WINED3D_SHADER_TEX_3D << i * WINED3D_PSARGS_TEXTYPE_SHIFT; - break; - - case GL_TEXTURE_CUBE_MAP_ARB: - args->tex_types |= WINED3D_SHADER_TEX_CUBE << i * WINED3D_PSARGS_TEXTYPE_SHIFT; + case WINED3D_RTYPE_TEXTURE_3D: + type = WINED3D_SHADER_TEX_3D; break; } + + args->tex_types |= (type << (i * WINED3D_PSARGS_TEXTYPE_SHIFT)); } } else if (shader->reg_maps.shader_version.major <= 3)
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/wined3d/utils.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index a46a4c7257d..cda31374c93 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6437,30 +6437,9 @@ void wined3d_ffp_get_fs_settings(const struct wined3d_context *context, const st else settings->op[i].color_fixup = texture->resource.format->color_fixup; if (ignore_textype) - { settings->op[i].tex_type = WINED3D_GL_RES_TYPE_TEX_1D; - } else - { - switch (wined3d_texture_gl(texture)->target) - { - case GL_TEXTURE_1D: - settings->op[i].tex_type = WINED3D_GL_RES_TYPE_TEX_1D; - break; - case GL_TEXTURE_2D: - settings->op[i].tex_type = WINED3D_GL_RES_TYPE_TEX_2D; - break; - case GL_TEXTURE_3D: - settings->op[i].tex_type = WINED3D_GL_RES_TYPE_TEX_3D; - break; - case GL_TEXTURE_CUBE_MAP_ARB: - settings->op[i].tex_type = WINED3D_GL_RES_TYPE_TEX_CUBE; - break; - case GL_TEXTURE_RECTANGLE_ARB: - settings->op[i].tex_type = WINED3D_GL_RES_TYPE_TEX_RECT; - break; - } - } + settings->op[i].tex_type = texture->resource.gl_type; } else { settings->op[i].color_fixup = COLOR_FIXUP_IDENTITY; settings->op[i].tex_type = WINED3D_GL_RES_TYPE_TEX_1D;
From: Zebediah Figura zfigura@codeweavers.com
This check was introduced in 4640be8dc834. At that point the only way for that condition to be false was for a cube map texture.
It's not clear why cube maps are relevant here; we have no tests for this, but it seems most expedient to just preserve the intent of the check. --- dlls/wined3d/utils.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index cda31374c93..a0b1fded9f5 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6479,11 +6479,7 @@ void wined3d_ffp_get_fs_settings(const struct wined3d_context *context, const st
if (!i && texture && state->render_states[WINED3D_RS_COLORKEYENABLE]) { - GLenum texture_dimensions; - - texture_dimensions = wined3d_texture_gl(texture)->target; - - if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB) + if (!(texture->resource.usage & WINED3DUSAGE_LEGACY_CUBEMAP)) { if (texture->async.color_key_flags & WINED3D_CKEY_SRC_BLT && !texture->resource.format->alpha_size) {
This check was introduced in 4640be8dc834. At that point the only way for that condition to be false was for a cube map texture.
It reads to me like it's specifically checking for a 2D texture instead of "not a cube texture", but the distinction may be somewhat moot: WINED3D_CKEY_SRC_BLT implies ddraw, and that means we either have a cube texture or a 2D texture.
Note that constructs like ```c if (a) { if (b) { if (c) { [...] } } } ``` can often be rewritten as ```c if (a && b && c) { [...] } ``` without readability being reduced.
It reads to me like it's specifically checking for a 2D texture instead of "not a cube texture", but the distinction may be somewhat moot: WINED3D_CKEY_SRC_BLT implies ddraw, and that means we either have a cube texture or a 2D texture.
Yeah, it could be unnecessarily defensive coding as well. It's not really obvious to me why cube textures or 2D textures would matter for the purposes of GL, though. [I don't suppose you, or someone else more knowledgeable about early GL, has an idea?]
Note that constructs like
<snip> can often be rewritten as <snip> without readability being reduced.
True. I might do that in a separate patch just so the diff is clear.