mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-27 12:04:16 +01:00
renderer_opengl: Address cubemap related errors (#6158)
This commit is contained in:
parent
1759e2afc2
commit
b05b5b3bd8
@ -559,7 +559,8 @@ const CachedTextureCube& RasterizerCacheOpenGL::GetTextureCube(const TextureCube
|
||||
|
||||
u32 scaled_size = cube.res_scale * config.width;
|
||||
|
||||
for (const Face& face : faces) {
|
||||
for (std::size_t i = 0; i < faces.size(); i++) {
|
||||
const Face& face = faces[i];
|
||||
if (face.watcher && !face.watcher->IsValid()) {
|
||||
auto surface = face.watcher->Get();
|
||||
if (!surface->invalid_regions.empty()) {
|
||||
@ -570,7 +571,7 @@ const CachedTextureCube& RasterizerCacheOpenGL::GetTextureCube(const TextureCube
|
||||
const auto dst_rect = Common::Rectangle<u32>{0, scaled_size, scaled_size, 0};
|
||||
const Aspect aspect = ToAspect(surface->type);
|
||||
runtime.BlitTextures(surface->texture, {aspect, src_rect}, cube.texture,
|
||||
{aspect, dst_rect});
|
||||
{aspect, dst_rect, 0, static_cast<u32>(i)}, true);
|
||||
|
||||
face.watcher->Validate();
|
||||
}
|
||||
|
@ -127,7 +127,8 @@ bool TextureRuntime::CopyTextures(const OGLTexture& src_tex, Subresource src_sub
|
||||
}
|
||||
|
||||
bool TextureRuntime::BlitTextures(const OGLTexture& src_tex, Subresource src_subresource,
|
||||
const OGLTexture& dst_tex, Subresource dst_subresource) {
|
||||
const OGLTexture& dst_tex, Subresource dst_subresource,
|
||||
bool dst_cube) {
|
||||
OpenGLState prev_state = OpenGLState::GetCurState();
|
||||
SCOPE_EXIT({ prev_state.Apply(); });
|
||||
|
||||
@ -136,10 +137,12 @@ bool TextureRuntime::BlitTextures(const OGLTexture& src_tex, Subresource src_sub
|
||||
state.draw.draw_framebuffer = draw_fbo.handle;
|
||||
state.Apply();
|
||||
|
||||
auto BindAttachment = [src_level = src_subresource.level, dst_level = dst_subresource.level](
|
||||
GLenum target, u32 src_tex, u32 dst_tex) -> void {
|
||||
auto BindAttachment =
|
||||
[dst_cube, src_level = src_subresource.level, dst_level = dst_subresource.level,
|
||||
dst_layer = dst_subresource.layer](GLenum target, u32 src_tex, u32 dst_tex) -> void {
|
||||
GLenum dst_target = dst_cube ? GL_TEXTURE_CUBE_MAP_POSITIVE_X + dst_layer : GL_TEXTURE_2D;
|
||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, target, GL_TEXTURE_2D, src_tex, src_level);
|
||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, target, GL_TEXTURE_2D, dst_tex, dst_level);
|
||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, target, dst_target, dst_tex, dst_level);
|
||||
};
|
||||
|
||||
// Sanity check; Can't blit a color texture to a depth buffer
|
||||
|
@ -57,7 +57,8 @@ public:
|
||||
// Copies a rectangle of src_tex to another rectange of dst_rect performing
|
||||
// scaling and format conversions
|
||||
bool BlitTextures(const OGLTexture& src_tex, Subresource src_subresource,
|
||||
const OGLTexture& dst_tex, Subresource dst_subresource);
|
||||
const OGLTexture& dst_tex, Subresource dst_subresource,
|
||||
bool dst_cube = false);
|
||||
|
||||
// Generates mipmaps for all the available levels of the texture
|
||||
void GenerateMipmaps(const OGLTexture& tex, u32 max_level);
|
||||
|
@ -56,7 +56,7 @@ void OGLTexture::Allocate(GLenum target, GLsizei levels, GLenum internalformat,
|
||||
GLsizei height, GLsizei depth) {
|
||||
GLuint old_tex = OpenGLState::GetCurState().texture_units[0].texture_2d;
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, handle);
|
||||
glBindTexture(target, handle);
|
||||
|
||||
switch (target) {
|
||||
case GL_TEXTURE_1D:
|
||||
@ -76,9 +76,9 @@ void OGLTexture::Allocate(GLenum target, GLsizei levels, GLenum internalformat,
|
||||
break;
|
||||
}
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, old_tex);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user