Merge pull request #9746 from ameerj/ogl-msaa-texcache
texture_cache: OpenGL: Implement MSAA uploads and copies
This commit is contained in:
commit
f70fcdb873
12 changed files with 136 additions and 14 deletions
|
@ -557,6 +557,14 @@ void TextureCacheRuntime::CopyImage(Image& dst_image, Image& src_image,
|
|||
}
|
||||
}
|
||||
|
||||
void TextureCacheRuntime::CopyImageMSAA(Image& dst_image, Image& src_image,
|
||||
std::span<const VideoCommon::ImageCopy> copies) {
|
||||
LOG_DEBUG(Render_OpenGL, "Copying from {} samples to {} samples", src_image.info.num_samples,
|
||||
dst_image.info.num_samples);
|
||||
// TODO: Leverage the format conversion pass if possible/accurate.
|
||||
util_shaders.CopyMSAA(dst_image, src_image, copies);
|
||||
}
|
||||
|
||||
void TextureCacheRuntime::ReinterpretImage(Image& dst, Image& src,
|
||||
std::span<const VideoCommon::ImageCopy> copies) {
|
||||
LOG_DEBUG(Render_OpenGL, "Converting {} to {}", src.info.format, dst.info.format);
|
||||
|
|
|
@ -93,12 +93,19 @@ public:
|
|||
return device.CanReportMemoryUsage();
|
||||
}
|
||||
|
||||
bool ShouldReinterpret([[maybe_unused]] Image& dst, [[maybe_unused]] Image& src) {
|
||||
bool ShouldReinterpret([[maybe_unused]] Image& dst,
|
||||
[[maybe_unused]] Image& src) const noexcept {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CanUploadMSAA() const noexcept {
|
||||
return true;
|
||||
}
|
||||
|
||||
void CopyImage(Image& dst, Image& src, std::span<const VideoCommon::ImageCopy> copies);
|
||||
|
||||
void CopyImageMSAA(Image& dst, Image& src, std::span<const VideoCommon::ImageCopy> copies);
|
||||
|
||||
void ReinterpretImage(Image& dst, Image& src, std::span<const VideoCommon::ImageCopy> copies);
|
||||
|
||||
void ConvertImage(Framebuffer* dst, ImageView& dst_view, ImageView& src_view) {
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include "video_core/host_shaders/astc_decoder_comp.h"
|
||||
#include "video_core/host_shaders/block_linear_unswizzle_2d_comp.h"
|
||||
#include "video_core/host_shaders/block_linear_unswizzle_3d_comp.h"
|
||||
#include "video_core/host_shaders/convert_msaa_to_non_msaa_comp.h"
|
||||
#include "video_core/host_shaders/convert_non_msaa_to_msaa_comp.h"
|
||||
#include "video_core/host_shaders/opengl_convert_s8d24_comp.h"
|
||||
#include "video_core/host_shaders/opengl_copy_bc4_comp.h"
|
||||
#include "video_core/host_shaders/pitch_unswizzle_comp.h"
|
||||
|
@ -51,7 +53,9 @@ UtilShaders::UtilShaders(ProgramManager& program_manager_)
|
|||
block_linear_unswizzle_3d_program(MakeProgram(BLOCK_LINEAR_UNSWIZZLE_3D_COMP)),
|
||||
pitch_unswizzle_program(MakeProgram(PITCH_UNSWIZZLE_COMP)),
|
||||
copy_bc4_program(MakeProgram(OPENGL_COPY_BC4_COMP)),
|
||||
convert_s8d24_program(MakeProgram(OPENGL_CONVERT_S8D24_COMP)) {
|
||||
convert_s8d24_program(MakeProgram(OPENGL_CONVERT_S8D24_COMP)),
|
||||
convert_ms_to_nonms_program(MakeProgram(CONVERT_MSAA_TO_NON_MSAA_COMP)),
|
||||
convert_nonms_to_ms_program(MakeProgram(CONVERT_NON_MSAA_TO_MSAA_COMP)) {
|
||||
const auto swizzle_table = Tegra::Texture::MakeSwizzleTable();
|
||||
swizzle_table_buffer.Create();
|
||||
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
|
|||
program_manager.RestoreGuestCompute();
|
||||
}
|
||||
|
||||
void UtilShaders::CopyMSAA(Image& dst_image, Image& src_image,
|
||||
std::span<const VideoCommon::ImageCopy> copies) {
|
||||
const bool is_ms_to_non_ms = src_image.info.num_samples > 1 && dst_image.info.num_samples == 1;
|
||||
const auto program_handle =
|
||||
is_ms_to_non_ms ? convert_ms_to_nonms_program.handle : convert_nonms_to_ms_program.handle;
|
||||
program_manager.BindComputeProgram(program_handle);
|
||||
|
||||
for (const ImageCopy& copy : copies) {
|
||||
ASSERT(copy.src_subresource.base_layer == 0);
|
||||
ASSERT(copy.src_subresource.num_layers == 1);
|
||||
ASSERT(copy.dst_subresource.base_layer == 0);
|
||||
ASSERT(copy.dst_subresource.num_layers == 1);
|
||||
|
||||
glBindImageTexture(0, src_image.StorageHandle(), copy.src_subresource.base_level, GL_TRUE,
|
||||
0, GL_READ_ONLY, GL_RGBA8);
|
||||
glBindImageTexture(1, dst_image.StorageHandle(), copy.dst_subresource.base_level, GL_TRUE,
|
||||
0, GL_WRITE_ONLY, GL_RGBA8);
|
||||
|
||||
const u32 num_dispatches_x = Common::DivCeil(copy.extent.width, 8U);
|
||||
const u32 num_dispatches_y = Common::DivCeil(copy.extent.height, 8U);
|
||||
const u32 num_dispatches_z = copy.extent.depth;
|
||||
|
||||
glDispatchCompute(num_dispatches_x, num_dispatches_y, num_dispatches_z);
|
||||
}
|
||||
program_manager.RestoreGuestCompute();
|
||||
}
|
||||
|
||||
GLenum StoreFormat(u32 bytes_per_block) {
|
||||
switch (bytes_per_block) {
|
||||
case 1:
|
||||
|
|
|
@ -40,6 +40,9 @@ public:
|
|||
|
||||
void ConvertS8D24(Image& dst_image, std::span<const VideoCommon::ImageCopy> copies);
|
||||
|
||||
void CopyMSAA(Image& dst_image, Image& src_image,
|
||||
std::span<const VideoCommon::ImageCopy> copies);
|
||||
|
||||
private:
|
||||
ProgramManager& program_manager;
|
||||
|
||||
|
@ -51,6 +54,8 @@ private:
|
|||
OGLProgram pitch_unswizzle_program;
|
||||
OGLProgram copy_bc4_program;
|
||||
OGLProgram convert_s8d24_program;
|
||||
OGLProgram convert_ms_to_nonms_program;
|
||||
OGLProgram convert_nonms_to_ms_program;
|
||||
};
|
||||
|
||||
GLenum StoreFormat(u32 bytes_per_block);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue