Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- 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 9b6c19e..fc97205 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 = 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; } + 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; + 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 b12aa21..021c274 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) {