diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.h b/rpcs3/Emu/RSX/Common/TextureUtils.h index 0481ded4f2..243240bce1 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.h +++ b/rpcs3/Emu/RSX/Common/TextureUtils.h @@ -119,7 +119,8 @@ namespace rsx RSX_FORMAT_CLASS_DEPTH24_UNORM_X8_PACK32 = 8, RSX_FORMAT_CLASS_DEPTH24_FLOAT_X8_PACK32 = 16, - RSX_FORMAT_CLASS_DEPTH_FLOAT_MASK = (RSX_FORMAT_CLASS_DEPTH16_FLOAT | RSX_FORMAT_CLASS_DEPTH24_FLOAT_X8_PACK32) + RSX_FORMAT_CLASS_DEPTH_FLOAT_MASK = (RSX_FORMAT_CLASS_DEPTH16_FLOAT | RSX_FORMAT_CLASS_DEPTH24_FLOAT_X8_PACK32), + RSX_FORMAT_CLASS_DONT_CARE = RSX_FORMAT_CLASS_UNDEFINED, }; } diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index 08322d54a2..5026fda9b3 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -229,13 +229,13 @@ void GLGSRender::on_init_thread() // Array stream buffer { - m_gl_persistent_stream_buffer = std::make_unique(GL_TEXTURE_BUFFER, 0, 0, 0, 0, 0, GL_R8UI); + m_gl_persistent_stream_buffer = std::make_unique(GL_TEXTURE_BUFFER, 0, 0, 0, 0, 0, GL_R8UI, RSX_FORMAT_CLASS_DONT_CARE); gl_state.bind_texture(GL_STREAM_BUFFER_START + 0, GL_TEXTURE_BUFFER, m_gl_persistent_stream_buffer->id()); } // Register stream buffer { - m_gl_volatile_stream_buffer = std::make_unique(GL_TEXTURE_BUFFER, 0, 0, 0, 0, 0, GL_R8UI); + m_gl_volatile_stream_buffer = std::make_unique(GL_TEXTURE_BUFFER, 0, 0, 0, 0, 0, GL_R8UI, RSX_FORMAT_CLASS_DONT_CARE); gl_state.bind_texture(GL_STREAM_BUFFER_START + 1, GL_TEXTURE_BUFFER, m_gl_volatile_stream_buffer->id()); } @@ -244,19 +244,19 @@ void GLGSRender::on_init_thread() std::array pixeldata = { 0, 0, 0, 0, 0, 0, 0, 0 }; // 1D - auto tex1D = std::make_unique(GL_TEXTURE_1D, 1, 1, 1, 1, 1, GL_RGBA8); + auto tex1D = std::make_unique(GL_TEXTURE_1D, 1, 1, 1, 1, 1, GL_RGBA8, RSX_FORMAT_CLASS_COLOR); tex1D->copy_from(pixeldata.data(), gl::texture::format::rgba, gl::texture::type::uint_8_8_8_8, {}); // 2D - auto tex2D = std::make_unique(GL_TEXTURE_2D, 1, 1, 1, 1, 1, GL_RGBA8); + auto tex2D = std::make_unique(GL_TEXTURE_2D, 1, 1, 1, 1, 1, GL_RGBA8, RSX_FORMAT_CLASS_COLOR); tex2D->copy_from(pixeldata.data(), gl::texture::format::rgba, gl::texture::type::uint_8_8_8_8, {}); // 3D - auto tex3D = std::make_unique(GL_TEXTURE_3D, 1, 1, 1, 1, 1, GL_RGBA8); + auto tex3D = std::make_unique(GL_TEXTURE_3D, 1, 1, 1, 1, 1, GL_RGBA8, RSX_FORMAT_CLASS_COLOR); tex3D->copy_from(pixeldata.data(), gl::texture::format::rgba, gl::texture::type::uint_8_8_8_8, {}); // CUBE - auto texCUBE = std::make_unique(GL_TEXTURE_CUBE_MAP, 1, 1, 1, 1, 1, GL_RGBA8); + auto texCUBE = std::make_unique(GL_TEXTURE_CUBE_MAP, 1, 1, 1, 1, 1, GL_RGBA8, RSX_FORMAT_CLASS_COLOR); texCUBE->copy_from(pixeldata.data(), gl::texture::format::rgba, gl::texture::type::uint_8_8_8_8, {}); m_null_textures[GL_TEXTURE_1D] = std::move(tex1D); diff --git a/rpcs3/Emu/RSX/GL/GLOverlays.cpp b/rpcs3/Emu/RSX/GL/GLOverlays.cpp index 5d37a2ca24..401dc6b0e4 100644 --- a/rpcs3/Emu/RSX/GL/GLOverlays.cpp +++ b/rpcs3/Emu/RSX/GL/GLOverlays.cpp @@ -216,7 +216,7 @@ namespace gl gl::texture_view* ui_overlay_renderer::load_simple_image(rsx::overlays::image_info* desc, bool temp_resource, u32 owner_uid) { - auto tex = std::make_unique(GL_TEXTURE_2D, desc->w, desc->h, 1, 1, 1, GL_RGBA8); + auto tex = std::make_unique(GL_TEXTURE_2D, desc->w, desc->h, 1, 1, 1, GL_RGBA8, RSX_FORMAT_CLASS_COLOR); tex->copy_from(desc->get_data(), gl::texture::format::rgba, gl::texture::type::uint_8_8_8_8, {}); GLenum remap[] = { GL_RED, GL_ALPHA, GL_BLUE, GL_GREEN }; @@ -301,7 +301,7 @@ namespace gl // Create font file const std::vector glyph_data = font->get_glyph_data(); - auto tex = std::make_unique(GL_TEXTURE_2D_ARRAY, font_size.width, font_size.height, font_size.depth, 1, 1, GL_R8); + auto tex = std::make_unique(GL_TEXTURE_2D_ARRAY, font_size.width, font_size.height, font_size.depth, 1, 1, GL_R8, RSX_FORMAT_CLASS_COLOR); tex->copy_from(glyph_data.data(), gl::texture::format::r, gl::texture::type::ubyte, {}); GLenum remap[] = { GL_RED, GL_RED, GL_RED, GL_RED }; diff --git a/rpcs3/Emu/RSX/GL/GLPresent.cpp b/rpcs3/Emu/RSX/GL/GLPresent.cpp index 62bfc9e3d5..2decb52c97 100644 --- a/rpcs3/Emu/RSX/GL/GLPresent.cpp +++ b/rpcs3/Emu/RSX/GL/GLPresent.cpp @@ -26,7 +26,7 @@ namespace gl { const auto target = static_cast(visual->get_target()); const auto ifmt = static_cast(visual->get_internal_format()); - g_vis_texture.reset(new texture(target, visual->width(), visual->height(), 1, 1, ifmt, visual->format_class())); + g_vis_texture.reset(new texture(target, visual->width(), visual->height(), 1, 1, 1, ifmt, visual->format_class())); glCopyImageSubData(visual->id(), target, 0, 0, 0, 0, g_vis_texture->id(), target, 0, 0, 0, 0, visual->width(), visual->height(), 1); } } @@ -115,7 +115,7 @@ gl::texture* GLGSRender::get_present_source(gl::present_surface_info* info, cons { if (!flip_image || flip_image->size2D() != sizeu{ info->width, info->height }) { - flip_image = std::make_unique(GL_TEXTURE_2D, info->width, info->height, 1, 1, 1, expected_format); + flip_image = std::make_unique(GL_TEXTURE_2D, info->width, info->height, 1, 1, 1, expected_format, RSX_FORMAT_CLASS_COLOR); } }; diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp index a17c1c39bf..78fa7e0b82 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp @@ -466,6 +466,8 @@ void gl::render_target::load_memory(gl::command_context& cmd) msaa_flags = rsx::surface_state_flags::require_unresolve; } } + + state_flags &= ~rsx::surface_state_flags::erase_bkgnd; } void gl::render_target::initialize_memory(gl::command_context& cmd, rsx::surface_access access) diff --git a/rpcs3/Emu/RSX/GL/GLTexture.cpp b/rpcs3/Emu/RSX/GL/GLTexture.cpp index c39f7ba2f7..0bc4e3cb97 100644 --- a/rpcs3/Emu/RSX/GL/GLTexture.cpp +++ b/rpcs3/Emu/RSX/GL/GLTexture.cpp @@ -576,7 +576,7 @@ namespace gl const GLenum internal_format = get_sized_internal_format(gcm_format); const auto format_class = rsx::classify_format(gcm_format); - return new gl::viewable_image(target, width, height, depth, mipmaps, internal_format, format_class); + return new gl::viewable_image(target, width, height, depth, mipmaps, 1, internal_format, format_class); } void fill_texture(gl::command_context& cmd, texture* dst, int format, diff --git a/rpcs3/Emu/RSX/GL/GLTextureCache.cpp b/rpcs3/Emu/RSX/GL/GLTextureCache.cpp index 9ab5b7da2e..a3a06de4f5 100644 --- a/rpcs3/Emu/RSX/GL/GLTextureCache.cpp +++ b/rpcs3/Emu/RSX/GL/GLTextureCache.cpp @@ -149,7 +149,7 @@ namespace gl if (!dst) { - std::unique_ptr data = std::make_unique(dst_target, width, height, depth, mipmaps, sized_internal_fmt, rsx::classify_format(gcm_format)); + std::unique_ptr data = std::make_unique(dst_target, width, height, depth, mipmaps, 1, sized_internal_fmt, rsx::classify_format(gcm_format)); dst = data.get(); dst->properties_encoding = match_key; m_temporary_surfaces.emplace_back(std::move(data)); @@ -223,7 +223,12 @@ namespace gl { const auto src_bpp = slice.src->pitch() / slice.src->width(); const u16 convert_w = u16(slice.src->width() * src_bpp) / dst_bpp; - tmp = std::make_unique(GL_TEXTURE_2D, convert_w, slice.src->height(), 1, 1, static_cast(dst_image->get_internal_format()), dst_image->format_class()); + tmp = std::make_unique( + GL_TEXTURE_2D, + convert_w, slice.src->height(), + 1, 1, 1, + static_cast(dst_image->get_internal_format()), + dst_image->format_class()); src_image = tmp.get(); @@ -264,9 +269,17 @@ namespace gl const areai dst_rect = { slice.dst_x, slice.dst_y, slice.dst_x + slice.dst_w, slice.dst_y + slice.dst_h }; gl::texture* _dst = dst_image; - if (src_image->get_internal_format() != dst_image->get_internal_format() || slice.level != 0 || slice.dst_z != 0) [[ unlikely ]] + if (src_image->get_internal_format() != dst_image->get_internal_format() || + slice.level != 0 || + slice.dst_z != 0) [[ unlikely ]] { - tmp = std::make_unique(GL_TEXTURE_2D, dst_rect.x2, dst_rect.y2, 1, 1, 1, static_cast(slice.src->get_internal_format())); + tmp = std::make_unique( + GL_TEXTURE_2D, + dst_rect.x2, dst_rect.y2, + 1, 1, 1, + static_cast(slice.src->get_internal_format()), + slice.src->format_class()); + _dst = tmp.get(); } diff --git a/rpcs3/Emu/RSX/GL/GLTextureCache.h b/rpcs3/Emu/RSX/GL/GLTextureCache.h index 0681813a31..6bc2182de5 100644 --- a/rpcs3/Emu/RSX/GL/GLTextureCache.h +++ b/rpcs3/Emu/RSX/GL/GLTextureCache.h @@ -305,7 +305,7 @@ namespace gl if (!scaled_texture) { - scaled_texture = std::make_unique(GL_TEXTURE_2D, real_width, real_height, 1, 1, 1, static_cast(ifmt)); + scaled_texture = std::make_unique(GL_TEXTURE_2D, real_width, real_height, 1, 1, 1, static_cast(ifmt), vram_texture->format_class()); } const bool linear_interp = is_depth_texture() ? false : true; diff --git a/rpcs3/Emu/RSX/GL/glutils/blitter.cpp b/rpcs3/Emu/RSX/GL/glutils/blitter.cpp index 11798e46ed..e7ca554e0e 100644 --- a/rpcs3/Emu/RSX/GL/glutils/blitter.cpp +++ b/rpcs3/Emu/RSX/GL/glutils/blitter.cpp @@ -67,7 +67,7 @@ namespace gl if (static_cast(internal_fmt) != src->get_internal_format()) { const u16 internal_width = static_cast(src->width() * xfer_info.src_scaling_hint); - typeless_src = std::make_unique(GL_TEXTURE_2D, internal_width, src->height(), 1, 1, 1, internal_fmt); + typeless_src = std::make_unique(GL_TEXTURE_2D, internal_width, src->height(), 1, 1, 1, internal_fmt, RSX_FORMAT_CLASS_DONT_CARE); copy_typeless(cmd, typeless_src.get(), src); real_src = typeless_src.get(); @@ -85,7 +85,7 @@ namespace gl if (static_cast(internal_fmt) != dst->get_internal_format()) { const auto internal_width = static_cast(dst->width() * xfer_info.dst_scaling_hint); - typeless_dst = std::make_unique(GL_TEXTURE_2D, internal_width, dst->height(), 1, 1, 1, internal_fmt); + typeless_dst = std::make_unique(GL_TEXTURE_2D, internal_width, dst->height(), 1, 1, 1, internal_fmt, RSX_FORMAT_CLASS_DONT_CARE); copy_typeless(cmd, typeless_dst.get(), dst); real_dst = typeless_dst.get(); diff --git a/rpcs3/Emu/RSX/GL/glutils/image.cpp b/rpcs3/Emu/RSX/GL/glutils/image.cpp index 6d9e0b2b80..bbba4b6de2 100644 --- a/rpcs3/Emu/RSX/GL/glutils/image.cpp +++ b/rpcs3/Emu/RSX/GL/glutils/image.cpp @@ -174,7 +174,7 @@ namespace gl void texture::copy_from(const void* src, texture::format format, texture::type type, int level, const coord3u region, const pixel_unpack_settings& pixel_settings) { - ensure(m_samples == 1, "Transfer operations are unsupported on multisampled textures."); + ensure(m_samples <= 1, "Transfer operations are unsupported on multisampled textures."); pixel_settings.apply(); @@ -220,7 +220,7 @@ namespace gl void texture::copy_from(buffer& buf, u32 gl_format_type, u32 offset, u32 length) { - ensure(m_samples == 1, "Transfer operations are unsupported on multisampled textures."); + ensure(m_samples <= 1, "Transfer operations are unsupported on multisampled textures."); if (get_target() != target::textureBuffer) fmt::throw_exception("OpenGL error: texture cannot copy from buffer"); @@ -235,7 +235,7 @@ namespace gl void texture::copy_to(void* dst, texture::format format, texture::type type, int level, const coord3u& region, const pixel_pack_settings& pixel_settings) const { - ensure(m_samples == 1, "Transfer operations are unsupported on multisampled textures."); + ensure(m_samples <= 1, "Transfer operations are unsupported on multisampled textures."); pixel_settings.apply(); const auto& caps = get_driver_caps(); @@ -257,7 +257,7 @@ namespace gl { // Worst case scenario. For some reason, EXT_dsa does not have glGetTextureSubImage const auto target_ = static_cast(m_target); - texture tmp{ target_, region.width, region.height, region.depth, 1, 1, static_cast(m_internal_format) }; + texture tmp{ target_, region.width, region.height, region.depth, 1, 1, static_cast(m_internal_format), m_format_class }; glCopyImageSubData(m_id, target_, level, region.x, region.y, region.z, tmp.id(), target_, 0, 0, 0, 0, region.width, region.height, region.depth); diff --git a/rpcs3/Emu/RSX/GL/glutils/image.h b/rpcs3/Emu/RSX/GL/glutils/image.h index d36cf26ea5..be4277faa4 100644 --- a/rpcs3/Emu/RSX/GL/glutils/image.h +++ b/rpcs3/Emu/RSX/GL/glutils/image.h @@ -199,7 +199,7 @@ namespace gl texture(const texture&) = delete; texture(texture&& texture_) = delete; - texture(GLenum target, GLuint width, GLuint height, GLuint depth, GLuint mipmaps, GLubyte samples, GLenum sized_format, rsx::format_class format_class = rsx::RSX_FORMAT_CLASS_UNDEFINED); + texture(GLenum target, GLuint width, GLuint height, GLuint depth, GLuint mipmaps, GLubyte samples, GLenum sized_format, rsx::format_class format_class); virtual ~texture(); // Getters/setters diff --git a/rpcs3/Emu/RSX/GL/upscalers/fsr1/fsr_pass.cpp b/rpcs3/Emu/RSX/GL/upscalers/fsr1/fsr_pass.cpp index adf25b3f12..940de27d89 100644 --- a/rpcs3/Emu/RSX/GL/upscalers/fsr1/fsr_pass.cpp +++ b/rpcs3/Emu/RSX/GL/upscalers/fsr1/fsr_pass.cpp @@ -177,7 +177,7 @@ namespace gl { return std::make_unique( GL_TEXTURE_2D, - output_w, output_h, 1, 1, + output_w, output_h, 1, 1, 1, GL_RGBA8, RSX_FORMAT_CLASS_COLOR); };