From 4678dac730e4349525c5b0cb422e48109aad4d98 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Wed, 21 Feb 2018 10:25:28 +0330 Subject: [PATCH] wined3d: Introduce a helper to retrieve the texture target in context_set_fbo_key_for_render_target(). Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/context.c | 14 ++++---------- dlls/wined3d/wined3d_private.h | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 9b6c19ef654..fc972053f5b 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -454,17 +454,11 @@ static inline void context_set_fbo_key_for_render_target(const struct wined3d_co key->rb_namespace |= 1 << idx; return; } + } + key->objects[idx].target = wined3d_texture_get_sub_resource_target(texture, sub_resource_idx); + key->objects[idx].level = sub_resource_idx % texture->level_count; + key->objects[idx].layer = sub_resource_idx / texture->level_count; - key->objects[idx].target = surface->texture_target; - key->objects[idx].level = surface->texture_level; - key->objects[idx].layer = surface->texture_layer; - } - else - { - key->objects[idx].target = texture->target; - key->objects[idx].level = sub_resource_idx % texture->level_count; - key->objects[idx].layer = sub_resource_idx / texture->level_count; - } if (render_target->layer_count != 1) key->objects[idx].layer = WINED3D_ALL_LAYERS; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index b12aa21f8dd..021c27402c6 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3179,6 +3179,23 @@ static inline struct wined3d_texture *texture_from_resource(struct wined3d_resou return CONTAINING_RECORD(resource, struct wined3d_texture, resource); } +static inline GLenum wined3d_texture_get_sub_resource_target(const struct wined3d_texture *texture, + unsigned int sub_resource_idx) +{ + static const GLenum cube_targets[] = + { + GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, + GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, + GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, + }; + + return texture->resource.usage & WINED3DUSAGE_LEGACY_CUBEMAP + ? cube_targets[sub_resource_idx / texture->level_count] : texture->target; +} + static inline struct gl_texture *wined3d_texture_get_gl_texture(struct wined3d_texture *texture, BOOL srgb) {