|
|
@ -42,12 +42,7 @@ using VideoCore::Surface::BytesPerBlock;
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
namespace {
|
|
|
|
OGLProgram MakeProgram(std::string_view source) {
|
|
|
|
OGLProgram MakeProgram(std::string_view source) {
|
|
|
|
OGLProgram program;
|
|
|
|
return CreateProgram(source, GL_COMPUTE_SHADER);
|
|
|
|
OGLShader shader;
|
|
|
|
|
|
|
|
program.handle = glCreateProgram();
|
|
|
|
|
|
|
|
AttachShader(GL_COMPUTE_SHADER, program.handle, source);
|
|
|
|
|
|
|
|
LinkProgram(program.handle);
|
|
|
|
|
|
|
|
return program;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
size_t NumPixelsInCopy(const VideoCommon::ImageCopy& copy) {
|
|
|
|
size_t NumPixelsInCopy(const VideoCommon::ImageCopy& copy) {
|
|
|
@ -84,7 +79,7 @@ void UtilShaders::ASTCDecode(Image& image, const ImageBufferMap& map,
|
|
|
|
.width = VideoCore::Surface::DefaultBlockWidth(image.info.format),
|
|
|
|
.width = VideoCore::Surface::DefaultBlockWidth(image.info.format),
|
|
|
|
.height = VideoCore::Surface::DefaultBlockHeight(image.info.format),
|
|
|
|
.height = VideoCore::Surface::DefaultBlockHeight(image.info.format),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
program_manager.BindProgram(astc_decoder_program.handle);
|
|
|
|
program_manager.BindComputeProgram(astc_decoder_program.handle);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, BINDING_SWIZZLE_BUFFER, swizzle_table_buffer.handle);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, BINDING_SWIZZLE_BUFFER, swizzle_table_buffer.handle);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, BINDING_ENC_BUFFER, astc_buffer.handle);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, BINDING_ENC_BUFFER, astc_buffer.handle);
|
|
|
|
|
|
|
|
|
|
|
@ -132,7 +127,7 @@ void UtilShaders::BlockLinearUpload2D(Image& image, const ImageBufferMap& map,
|
|
|
|
static constexpr GLuint BINDING_INPUT_BUFFER = 1;
|
|
|
|
static constexpr GLuint BINDING_INPUT_BUFFER = 1;
|
|
|
|
static constexpr GLuint BINDING_OUTPUT_IMAGE = 0;
|
|
|
|
static constexpr GLuint BINDING_OUTPUT_IMAGE = 0;
|
|
|
|
|
|
|
|
|
|
|
|
program_manager.BindProgram(block_linear_unswizzle_2d_program.handle);
|
|
|
|
program_manager.BindComputeProgram(block_linear_unswizzle_2d_program.handle);
|
|
|
|
glFlushMappedNamedBufferRange(map.buffer, map.offset, image.guest_size_bytes);
|
|
|
|
glFlushMappedNamedBufferRange(map.buffer, map.offset, image.guest_size_bytes);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, BINDING_SWIZZLE_BUFFER, swizzle_table_buffer.handle);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, BINDING_SWIZZLE_BUFFER, swizzle_table_buffer.handle);
|
|
|
|
|
|
|
|
|
|
|
@ -171,7 +166,7 @@ void UtilShaders::BlockLinearUpload3D(Image& image, const ImageBufferMap& map,
|
|
|
|
static constexpr GLuint BINDING_OUTPUT_IMAGE = 0;
|
|
|
|
static constexpr GLuint BINDING_OUTPUT_IMAGE = 0;
|
|
|
|
|
|
|
|
|
|
|
|
glFlushMappedNamedBufferRange(map.buffer, map.offset, image.guest_size_bytes);
|
|
|
|
glFlushMappedNamedBufferRange(map.buffer, map.offset, image.guest_size_bytes);
|
|
|
|
program_manager.BindProgram(block_linear_unswizzle_3d_program.handle);
|
|
|
|
program_manager.BindComputeProgram(block_linear_unswizzle_3d_program.handle);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, BINDING_SWIZZLE_BUFFER, swizzle_table_buffer.handle);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, BINDING_SWIZZLE_BUFFER, swizzle_table_buffer.handle);
|
|
|
|
|
|
|
|
|
|
|
|
const GLenum store_format = StoreFormat(BytesPerBlock(image.info.format));
|
|
|
|
const GLenum store_format = StoreFormat(BytesPerBlock(image.info.format));
|
|
|
@ -220,7 +215,7 @@ void UtilShaders::PitchUpload(Image& image, const ImageBufferMap& map,
|
|
|
|
UNIMPLEMENTED_IF_MSG(!std::has_single_bit(bytes_per_block),
|
|
|
|
UNIMPLEMENTED_IF_MSG(!std::has_single_bit(bytes_per_block),
|
|
|
|
"Non-power of two images are not implemented");
|
|
|
|
"Non-power of two images are not implemented");
|
|
|
|
|
|
|
|
|
|
|
|
program_manager.BindProgram(pitch_unswizzle_program.handle);
|
|
|
|
program_manager.BindComputeProgram(pitch_unswizzle_program.handle);
|
|
|
|
glFlushMappedNamedBufferRange(map.buffer, map.offset, image.guest_size_bytes);
|
|
|
|
glFlushMappedNamedBufferRange(map.buffer, map.offset, image.guest_size_bytes);
|
|
|
|
glUniform2ui(LOC_ORIGIN, 0, 0);
|
|
|
|
glUniform2ui(LOC_ORIGIN, 0, 0);
|
|
|
|
glUniform2i(LOC_DESTINATION, 0, 0);
|
|
|
|
glUniform2i(LOC_DESTINATION, 0, 0);
|
|
|
@ -248,7 +243,7 @@ void UtilShaders::CopyBC4(Image& dst_image, Image& src_image, std::span<const Im
|
|
|
|
static constexpr GLuint LOC_SRC_OFFSET = 0;
|
|
|
|
static constexpr GLuint LOC_SRC_OFFSET = 0;
|
|
|
|
static constexpr GLuint LOC_DST_OFFSET = 1;
|
|
|
|
static constexpr GLuint LOC_DST_OFFSET = 1;
|
|
|
|
|
|
|
|
|
|
|
|
program_manager.BindProgram(copy_bc4_program.handle);
|
|
|
|
program_manager.BindComputeProgram(copy_bc4_program.handle);
|
|
|
|
|
|
|
|
|
|
|
|
for (const ImageCopy& copy : copies) {
|
|
|
|
for (const ImageCopy& copy : copies) {
|
|
|
|
ASSERT(copy.src_subresource.base_layer == 0);
|
|
|
|
ASSERT(copy.src_subresource.base_layer == 0);
|
|
|
@ -284,7 +279,7 @@ void UtilShaders::CopyBGR(Image& dst_image, Image& src_image,
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 4: {
|
|
|
|
case 4: {
|
|
|
|
// BGRA8 copy
|
|
|
|
// BGRA8 copy
|
|
|
|
program_manager.BindProgram(copy_bgra_program.handle);
|
|
|
|
program_manager.BindComputeProgram(copy_bgra_program.handle);
|
|
|
|
constexpr GLenum FORMAT = GL_RGBA8;
|
|
|
|
constexpr GLenum FORMAT = GL_RGBA8;
|
|
|
|
for (const ImageCopy& copy : copies) {
|
|
|
|
for (const ImageCopy& copy : copies) {
|
|
|
|
ASSERT(copy.src_offset == zero_offset);
|
|
|
|
ASSERT(copy.src_offset == zero_offset);
|
|
|
|