rasterizer_cache: Fix texture cube blitting

* The target was GL_TEXTURE_2D instead of GL_TEXTURE_CUBE_MAP_*
This commit is contained in:
emufan4568
2022-09-11 12:31:32 +03:00
committed by GPUCode
parent 3619bd33b1
commit 98a4a18201
7 changed files with 27 additions and 14 deletions

View File

@ -116,6 +116,7 @@ public:
QSurfaceFormat format; QSurfaceFormat format;
format.setVersion(4, 4); format.setVersion(4, 4);
format.setProfile(QSurfaceFormat::CoreProfile); format.setProfile(QSurfaceFormat::CoreProfile);
format.setOption(QSurfaceFormat::DebugContext);
// TODO: expose a setting for buffer value (ie default/single/double/triple) // TODO: expose a setting for buffer value (ie default/single/double/triple)
format.setSwapBehavior(QSurfaceFormat::DefaultSwapBehavior); format.setSwapBehavior(QSurfaceFormat::DefaultSwapBehavior);
format.setSwapInterval(0); format.setSwapInterval(0);

View File

@ -2426,14 +2426,6 @@ int main(int argc, char* argv[]) {
QCoreApplication::setOrganizationName(QStringLiteral("Citra team")); QCoreApplication::setOrganizationName(QStringLiteral("Citra team"));
QCoreApplication::setApplicationName(QStringLiteral("Citra")); QCoreApplication::setApplicationName(QStringLiteral("Citra"));
QSurfaceFormat format;
format.setVersion(4, 3);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setSwapInterval(0);
// TODO: expose a setting for buffer value (ie default/single/double/triple)
format.setSwapBehavior(QSurfaceFormat::DefaultSwapBehavior);
QSurfaceFormat::setDefaultFormat(format);
#ifdef __APPLE__ #ifdef __APPLE__
std::string bin_path = FileUtil::GetBundleDirectory() + DIR_SEP + ".."; std::string bin_path = FileUtil::GetBundleDirectory() + DIR_SEP + "..";
chdir(bin_path.c_str()); chdir(bin_path.c_str());

View File

@ -83,6 +83,8 @@ void RasterizerCache::CopySurface(const Surface& src_surface, const Surface& dst
.surface_type = src_surface->type, .surface_type = src_surface->type,
.src_level = 0, .src_level = 0,
.dst_level = 0, .dst_level = 0,
.src_layer = 0,
.dst_layer = 0,
.src_region = Region2D{ .src_region = Region2D{
.start = {src_rect.left, src_rect.bottom}, .start = {src_rect.left, src_rect.bottom},
.end = {src_rect.right, src_rect.top} .end = {src_rect.right, src_rect.top}
@ -227,6 +229,8 @@ bool RasterizerCache::BlitSurfaces(const Surface& src_surface,
.surface_type = src_surface->type, .surface_type = src_surface->type,
.src_level = 0, .src_level = 0,
.dst_level = 0, .dst_level = 0,
.src_layer = 0,
.dst_layer = 0,
.src_region = Region2D{ .src_region = Region2D{
.start = {src_rect.left, src_rect.bottom}, .start = {src_rect.left, src_rect.bottom},
.end = {src_rect.right, src_rect.top} .end = {src_rect.right, src_rect.top}
@ -463,6 +467,8 @@ Surface RasterizerCache::GetTextureSurface(const Pica::Texture::TextureInfo& inf
.surface_type = surface->type, .surface_type = surface->type,
.src_level = 0, .src_level = 0,
.dst_level = level, .dst_level = level,
.src_layer = 0,
.dst_layer = 0,
.src_region = Region2D{ .src_region = Region2D{
.start = {src_rect.left, src_rect.bottom}, .start = {src_rect.left, src_rect.bottom},
.end = {src_rect.right, src_rect.top} .end = {src_rect.right, src_rect.top}
@ -552,9 +558,11 @@ const CachedTextureCube& RasterizerCache::GetTextureCube(const TextureCubeConfig
const auto src_rect = surface->GetScaledRect(); const auto src_rect = surface->GetScaledRect();
const TextureBlit texture_blit = { const TextureBlit texture_blit = {
.surface_type = surface->type, .surface_type = SurfaceType::Color,
.src_level = 0, .src_level = 0,
.dst_level = 0, .dst_level = 0,
.src_layer = 0,
.dst_layer = static_cast<u32>(i),
.src_region = Region2D{ .src_region = Region2D{
.start = {src_rect.left, src_rect.bottom}, .start = {src_rect.left, src_rect.bottom},
.end = {src_rect.right, src_rect.top} .end = {src_rect.right, src_rect.top}
@ -885,6 +893,8 @@ bool RasterizerCache::ValidateByReinterpretation(const Surface& surface,
.surface_type = type, .surface_type = type,
.src_level = 0, .src_level = 0,
.dst_level = 0, .dst_level = 0,
.src_layer = 0,
.dst_layer = 0,
.src_region = Region2D{ .src_region = Region2D{
.start = {0, 0}, .start = {0, 0},
.end = {width, height} .end = {width, height}

View File

@ -148,9 +148,14 @@ bool TextureRuntime::BlitTextures(OGLTexture& source, OGLTexture& dest, const Te
state.draw.draw_framebuffer = draw_fbo.handle; state.draw.draw_framebuffer = draw_fbo.handle;
state.Apply(); state.Apply();
auto BindAttachment = [&blit](GLenum target, u32 src_tex, u32 dst_tex) -> void { auto BindAttachment = [&blit, &source, &dest](GLenum attachment, u32 src_tex, u32 dst_tex) -> void {
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, target, GL_TEXTURE_2D, src_tex, blit.src_level); const GLenum src_target = source.target == GL_TEXTURE_CUBE_MAP ?
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, target, GL_TEXTURE_2D, dst_tex, blit.dst_level); GL_TEXTURE_CUBE_MAP_POSITIVE_X + blit.src_layer : source.target;
const GLenum dst_target = dest.target == GL_TEXTURE_CUBE_MAP ?
GL_TEXTURE_CUBE_MAP_POSITIVE_X + blit.dst_layer : dest.target;
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, attachment, src_target, src_tex, blit.src_level);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, dst_target, dst_tex, blit.dst_level);
}; };
switch (blit.surface_type) { switch (blit.surface_type) {

View File

@ -65,6 +65,8 @@ struct TextureBlit {
SurfaceType surface_type; SurfaceType surface_type;
u32 src_level; u32 src_level;
u32 dst_level; u32 dst_level;
u32 src_layer;
u32 dst_layer;
Region2D src_region; Region2D src_region;
Region2D dst_region; Region2D dst_region;
}; };

View File

@ -52,8 +52,10 @@ void OGLTexture::Release() {
handle = 0; handle = 0;
} }
void OGLTexture::Allocate(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, void OGLTexture::Allocate(GLenum _target, GLsizei levels, GLenum internalformat, GLsizei width,
GLsizei height, GLsizei depth) { GLsizei height, GLsizei depth) {
target = _target;
GLuint old_tex = OpenGLState::GetCurState().texture_units[0].texture_2d; GLuint old_tex = OpenGLState::GetCurState().texture_units[0].texture_2d;
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(target, handle); glBindTexture(target, handle);
@ -80,7 +82,7 @@ void OGLTexture::Allocate(GLenum target, GLsizei levels, GLenum internalformat,
glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_2D, old_tex); glBindTexture(target, old_tex);
} }
void OGLTexture::CopyFrom(const OGLTexture& other, GLenum target, GLsizei levels, GLsizei width, void OGLTexture::CopyFrom(const OGLTexture& other, GLenum target, GLsizei levels, GLsizei width,

View File

@ -65,6 +65,7 @@ public:
GLsizei height); GLsizei height);
GLuint handle = 0; GLuint handle = 0;
GLenum target = GL_TEXTURE_2D;
}; };
class OGLSampler : private NonCopyable { class OGLSampler : private NonCopyable {