diff options
Diffstat (limited to 'src/video_core/renderer_opengl')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.h | 9 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/util_shaders.cpp | 33 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/util_shaders.h | 5 |
4 files changed, 53 insertions, 2 deletions
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index 9f7ce7414..eb6e43a08 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp | |||
| @@ -557,6 +557,14 @@ void TextureCacheRuntime::CopyImage(Image& dst_image, Image& src_image, | |||
| 557 | } | 557 | } |
| 558 | } | 558 | } |
| 559 | 559 | ||
| 560 | void TextureCacheRuntime::CopyImageMSAA(Image& dst_image, Image& src_image, | ||
| 561 | std::span<const VideoCommon::ImageCopy> copies) { | ||
| 562 | LOG_DEBUG(Render_OpenGL, "Copying from {} samples to {} samples", src_image.info.num_samples, | ||
| 563 | dst_image.info.num_samples); | ||
| 564 | // TODO: Leverage the format conversion pass if possible/accurate. | ||
| 565 | util_shaders.CopyMSAA(dst_image, src_image, copies); | ||
| 566 | } | ||
| 567 | |||
| 560 | void TextureCacheRuntime::ReinterpretImage(Image& dst, Image& src, | 568 | void TextureCacheRuntime::ReinterpretImage(Image& dst, Image& src, |
| 561 | std::span<const VideoCommon::ImageCopy> copies) { | 569 | std::span<const VideoCommon::ImageCopy> copies) { |
| 562 | LOG_DEBUG(Render_OpenGL, "Converting {} to {}", src.info.format, dst.info.format); | 570 | LOG_DEBUG(Render_OpenGL, "Converting {} to {}", src.info.format, dst.info.format); |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index 5d9d370f2..e30875496 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h | |||
| @@ -93,12 +93,19 @@ public: | |||
| 93 | return device.CanReportMemoryUsage(); | 93 | return device.CanReportMemoryUsage(); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | bool ShouldReinterpret([[maybe_unused]] Image& dst, [[maybe_unused]] Image& src) { | 96 | bool ShouldReinterpret([[maybe_unused]] Image& dst, |
| 97 | [[maybe_unused]] Image& src) const noexcept { | ||
| 98 | return true; | ||
| 99 | } | ||
| 100 | |||
| 101 | bool CanUploadMSAA() const noexcept { | ||
| 97 | return true; | 102 | return true; |
| 98 | } | 103 | } |
| 99 | 104 | ||
| 100 | void CopyImage(Image& dst, Image& src, std::span<const VideoCommon::ImageCopy> copies); | 105 | void CopyImage(Image& dst, Image& src, std::span<const VideoCommon::ImageCopy> copies); |
| 101 | 106 | ||
| 107 | void CopyImageMSAA(Image& dst, Image& src, std::span<const VideoCommon::ImageCopy> copies); | ||
| 108 | |||
| 102 | void ReinterpretImage(Image& dst, Image& src, std::span<const VideoCommon::ImageCopy> copies); | 109 | void ReinterpretImage(Image& dst, Image& src, std::span<const VideoCommon::ImageCopy> copies); |
| 103 | 110 | ||
| 104 | void ConvertImage(Framebuffer* dst, ImageView& dst_view, ImageView& src_view) { | 111 | void ConvertImage(Framebuffer* dst, ImageView& dst_view, ImageView& src_view) { |
diff --git a/src/video_core/renderer_opengl/util_shaders.cpp b/src/video_core/renderer_opengl/util_shaders.cpp index 404def62e..2c7ac210b 100644 --- a/src/video_core/renderer_opengl/util_shaders.cpp +++ b/src/video_core/renderer_opengl/util_shaders.cpp | |||
| @@ -12,6 +12,8 @@ | |||
| 12 | #include "video_core/host_shaders/astc_decoder_comp.h" | 12 | #include "video_core/host_shaders/astc_decoder_comp.h" |
| 13 | #include "video_core/host_shaders/block_linear_unswizzle_2d_comp.h" | 13 | #include "video_core/host_shaders/block_linear_unswizzle_2d_comp.h" |
| 14 | #include "video_core/host_shaders/block_linear_unswizzle_3d_comp.h" | 14 | #include "video_core/host_shaders/block_linear_unswizzle_3d_comp.h" |
| 15 | #include "video_core/host_shaders/convert_msaa_to_non_msaa_comp.h" | ||
| 16 | #include "video_core/host_shaders/convert_non_msaa_to_msaa_comp.h" | ||
| 15 | #include "video_core/host_shaders/opengl_convert_s8d24_comp.h" | 17 | #include "video_core/host_shaders/opengl_convert_s8d24_comp.h" |
| 16 | #include "video_core/host_shaders/opengl_copy_bc4_comp.h" | 18 | #include "video_core/host_shaders/opengl_copy_bc4_comp.h" |
| 17 | #include "video_core/host_shaders/pitch_unswizzle_comp.h" | 19 | #include "video_core/host_shaders/pitch_unswizzle_comp.h" |
| @@ -51,7 +53,9 @@ UtilShaders::UtilShaders(ProgramManager& program_manager_) | |||
| 51 | block_linear_unswizzle_3d_program(MakeProgram(BLOCK_LINEAR_UNSWIZZLE_3D_COMP)), | 53 | block_linear_unswizzle_3d_program(MakeProgram(BLOCK_LINEAR_UNSWIZZLE_3D_COMP)), |
| 52 | pitch_unswizzle_program(MakeProgram(PITCH_UNSWIZZLE_COMP)), | 54 | pitch_unswizzle_program(MakeProgram(PITCH_UNSWIZZLE_COMP)), |
| 53 | copy_bc4_program(MakeProgram(OPENGL_COPY_BC4_COMP)), | 55 | copy_bc4_program(MakeProgram(OPENGL_COPY_BC4_COMP)), |
| 54 | convert_s8d24_program(MakeProgram(OPENGL_CONVERT_S8D24_COMP)) { | 56 | convert_s8d24_program(MakeProgram(OPENGL_CONVERT_S8D24_COMP)), |
| 57 | convert_ms_to_nonms_program(MakeProgram(CONVERT_MSAA_TO_NON_MSAA_COMP)), | ||
| 58 | convert_nonms_to_ms_program(MakeProgram(CONVERT_NON_MSAA_TO_MSAA_COMP)) { | ||
| 55 | const auto swizzle_table = Tegra::Texture::MakeSwizzleTable(); | 59 | const auto swizzle_table = Tegra::Texture::MakeSwizzleTable(); |
| 56 | swizzle_table_buffer.Create(); | 60 | swizzle_table_buffer.Create(); |
| 57 | glNamedBufferStorage(swizzle_table_buffer.handle, sizeof(swizzle_table), &swizzle_table, 0); | 61 | glNamedBufferStorage(swizzle_table_buffer.handle, sizeof(swizzle_table), &swizzle_table, 0); |
| @@ -269,6 +273,33 @@ void UtilShaders::ConvertS8D24(Image& dst_image, std::span<const ImageCopy> copi | |||
| 269 | program_manager.RestoreGuestCompute(); | 273 | program_manager.RestoreGuestCompute(); |
| 270 | } | 274 | } |
| 271 | 275 | ||
| 276 | void UtilShaders::CopyMSAA(Image& dst_image, Image& src_image, | ||
| 277 | std::span<const VideoCommon::ImageCopy> copies) { | ||
| 278 | const bool is_ms_to_non_ms = src_image.info.num_samples > 1 && dst_image.info.num_samples == 1; | ||
| 279 | const auto program_handle = | ||
| 280 | is_ms_to_non_ms ? convert_ms_to_nonms_program.handle : convert_nonms_to_ms_program.handle; | ||
| 281 | program_manager.BindComputeProgram(program_handle); | ||
| 282 | |||
| 283 | for (const ImageCopy& copy : copies) { | ||
| 284 | ASSERT(copy.src_subresource.base_layer == 0); | ||
| 285 | ASSERT(copy.src_subresource.num_layers == 1); | ||
| 286 | ASSERT(copy.dst_subresource.base_layer == 0); | ||
| 287 | ASSERT(copy.dst_subresource.num_layers == 1); | ||
| 288 | |||
| 289 | glBindImageTexture(0, src_image.StorageHandle(), copy.src_subresource.base_level, GL_TRUE, | ||
| 290 | 0, GL_READ_ONLY, GL_RGBA8); | ||
| 291 | glBindImageTexture(1, dst_image.StorageHandle(), copy.dst_subresource.base_level, GL_TRUE, | ||
| 292 | 0, GL_WRITE_ONLY, GL_RGBA8); | ||
| 293 | |||
| 294 | const u32 num_dispatches_x = Common::DivCeil(copy.extent.width, 8U); | ||
| 295 | const u32 num_dispatches_y = Common::DivCeil(copy.extent.height, 8U); | ||
| 296 | const u32 num_dispatches_z = copy.extent.depth; | ||
| 297 | |||
| 298 | glDispatchCompute(num_dispatches_x, num_dispatches_y, num_dispatches_z); | ||
| 299 | } | ||
| 300 | program_manager.RestoreGuestCompute(); | ||
| 301 | } | ||
| 302 | |||
| 272 | GLenum StoreFormat(u32 bytes_per_block) { | 303 | GLenum StoreFormat(u32 bytes_per_block) { |
| 273 | switch (bytes_per_block) { | 304 | switch (bytes_per_block) { |
| 274 | case 1: | 305 | case 1: |
diff --git a/src/video_core/renderer_opengl/util_shaders.h b/src/video_core/renderer_opengl/util_shaders.h index 44efb6ecf..9013808e7 100644 --- a/src/video_core/renderer_opengl/util_shaders.h +++ b/src/video_core/renderer_opengl/util_shaders.h | |||
| @@ -40,6 +40,9 @@ public: | |||
| 40 | 40 | ||
| 41 | void ConvertS8D24(Image& dst_image, std::span<const VideoCommon::ImageCopy> copies); | 41 | void ConvertS8D24(Image& dst_image, std::span<const VideoCommon::ImageCopy> copies); |
| 42 | 42 | ||
| 43 | void CopyMSAA(Image& dst_image, Image& src_image, | ||
| 44 | std::span<const VideoCommon::ImageCopy> copies); | ||
| 45 | |||
| 43 | private: | 46 | private: |
| 44 | ProgramManager& program_manager; | 47 | ProgramManager& program_manager; |
| 45 | 48 | ||
| @@ -51,6 +54,8 @@ private: | |||
| 51 | OGLProgram pitch_unswizzle_program; | 54 | OGLProgram pitch_unswizzle_program; |
| 52 | OGLProgram copy_bc4_program; | 55 | OGLProgram copy_bc4_program; |
| 53 | OGLProgram convert_s8d24_program; | 56 | OGLProgram convert_s8d24_program; |
| 57 | OGLProgram convert_ms_to_nonms_program; | ||
| 58 | OGLProgram convert_nonms_to_ms_program; | ||
| 54 | }; | 59 | }; |
| 55 | 60 | ||
| 56 | GLenum StoreFormat(u32 bytes_per_block); | 61 | GLenum StoreFormat(u32 bytes_per_block); |