renderer_opengl: Specify precision in compute shader and add RGB5A1 converter
* Fixes OpenGLES crash
This commit is contained in:
@ -12,9 +12,9 @@ namespace OpenGL {
|
|||||||
D24S8toRGBA8::D24S8toRGBA8(bool use_texture_view) : use_texture_view{use_texture_view} {
|
D24S8toRGBA8::D24S8toRGBA8(bool use_texture_view) : use_texture_view{use_texture_view} {
|
||||||
constexpr std::string_view cs_source = R"(
|
constexpr std::string_view cs_source = R"(
|
||||||
layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in;
|
layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in;
|
||||||
layout(binding = 0) uniform sampler2D depth;
|
layout(binding = 0) uniform highp sampler2D depth;
|
||||||
layout(binding = 1) uniform usampler2D stencil;
|
layout(binding = 1) uniform lowp usampler2D stencil;
|
||||||
layout(rgba8, binding = 2) uniform writeonly image2D color;
|
layout(rgba8, binding = 2) uniform highp writeonly image2D color;
|
||||||
|
|
||||||
uniform mediump ivec2 src_offset;
|
uniform mediump ivec2 src_offset;
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ D24S8toRGBA8::D24S8toRGBA8(const Instance& instance, TaskScheduler& scheduler,
|
|||||||
#version 450 core
|
#version 450 core
|
||||||
#extension GL_EXT_samplerless_texture_functions : require
|
#extension GL_EXT_samplerless_texture_functions : require
|
||||||
layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in;
|
layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in;
|
||||||
layout(set = 0, binding = 0) uniform texture2D depth;
|
layout(set = 0, binding = 0) uniform highp texture2D depth;
|
||||||
layout(set = 0, binding = 1) uniform utexture2D stencil;
|
layout(set = 0, binding = 1) uniform lowp utexture2D stencil;
|
||||||
layout(set = 0, binding = 2, rgba8) uniform writeonly image2D color;
|
layout(set = 0, binding = 2, rgba8) uniform highp writeonly image2D color;
|
||||||
|
|
||||||
layout(push_constant, std140) uniform ComputeInfo {
|
layout(push_constant, std140) uniform ComputeInfo {
|
||||||
mediump ivec2 src_offset;
|
mediump ivec2 src_offset;
|
||||||
|
@ -231,6 +231,8 @@ void TextureRuntime::FormatConvert(const Surface& surface, bool upload, std::spa
|
|||||||
return Pica::Texture::ConvertBGRToRGBA(source, dest);
|
return Pica::Texture::ConvertBGRToRGBA(source, dest);
|
||||||
case VideoCore::PixelFormat::RGBA4:
|
case VideoCore::PixelFormat::RGBA4:
|
||||||
return Pica::Texture::ConvertRGBA4ToRGBA8(source, dest);
|
return Pica::Texture::ConvertRGBA4ToRGBA8(source, dest);
|
||||||
|
case VideoCore::PixelFormat::RGB5A1:
|
||||||
|
return Pica::Texture::ConvertRGB5A1ToRGBA8(source, dest);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -251,22 +251,6 @@ void ConvertABGRToRGBA(std::span<const std::byte> source, std::span<std::byte> d
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertD32S8ToD24S8(std::span<const std::byte> source, std::span<std::byte> dest) {
|
|
||||||
std::size_t depth_offset = 0;
|
|
||||||
std::size_t stencil_offset = 4 * source.size() / 5;
|
|
||||||
for (std::size_t i = 0; i < dest.size(); i += 4) {
|
|
||||||
float depth;
|
|
||||||
std::memcpy(&depth, source.data() + depth_offset, sizeof(float));
|
|
||||||
u32 depth_uint = depth * 0xFFFFFF;
|
|
||||||
|
|
||||||
dest[i] = source[stencil_offset];
|
|
||||||
std::memcpy(dest.data() + i + 1, &depth_uint, 3);
|
|
||||||
|
|
||||||
depth_offset += 4;
|
|
||||||
stencil_offset += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConvertRGBA4ToRGBA8(std::span<const std::byte> source, std::span<std::byte> dest) {
|
void ConvertRGBA4ToRGBA8(std::span<const std::byte> source, std::span<std::byte> dest) {
|
||||||
u32 j = 0;
|
u32 j = 0;
|
||||||
for (std::size_t i = 0; i < dest.size(); i += 4) {
|
for (std::size_t i = 0; i < dest.size(); i += 4) {
|
||||||
@ -286,6 +270,31 @@ void ConvertRGBA8ToRGBA4(std::span<const std::byte> source, std::span<std::byte>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConvertRGB5A1ToRGBA8(std::span<const std::byte> source, std::span<std::byte> dest) {
|
||||||
|
u32 j = 0;
|
||||||
|
for (std::size_t i = 0; i < dest.size(); i += 4) {
|
||||||
|
auto rgba = Color::DecodeRGB5A1(reinterpret_cast<const u8*>(source.data() + j));
|
||||||
|
std::memcpy(dest.data() + i, rgba.AsArray(), sizeof(rgba));
|
||||||
|
j += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConvertD32S8ToD24S8(std::span<const std::byte> source, std::span<std::byte> dest) {
|
||||||
|
std::size_t depth_offset = 0;
|
||||||
|
std::size_t stencil_offset = 4 * source.size() / 5;
|
||||||
|
for (std::size_t i = 0; i < dest.size(); i += 4) {
|
||||||
|
float depth;
|
||||||
|
std::memcpy(&depth, source.data() + depth_offset, sizeof(float));
|
||||||
|
u32 depth_uint = depth * 0xFFFFFF;
|
||||||
|
|
||||||
|
dest[i] = source[stencil_offset];
|
||||||
|
std::memcpy(dest.data() + i + 1, &depth_uint, 3);
|
||||||
|
|
||||||
|
depth_offset += 4;
|
||||||
|
stencil_offset += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void InterleaveD24S8(std::span<const std::byte> source, std::span<std::byte> dest) {
|
void InterleaveD24S8(std::span<const std::byte> source, std::span<std::byte> dest) {
|
||||||
std::size_t depth_offset = 0;
|
std::size_t depth_offset = 0;
|
||||||
std::size_t stencil_offset = 3 * source.size() / 4;
|
std::size_t stencil_offset = 3 * source.size() / 4;
|
||||||
|
@ -79,12 +79,14 @@ void ConvertBGRToRGBA(std::span<const std::byte> source, std::span<std::byte> de
|
|||||||
*/
|
*/
|
||||||
void ConvertABGRToRGBA(std::span<const std::byte> source, std::span<std::byte> dest);
|
void ConvertABGRToRGBA(std::span<const std::byte> source, std::span<std::byte> dest);
|
||||||
|
|
||||||
void ConvertD32S8ToD24S8(std::span<const std::byte> source, std::span<std::byte> dest);
|
|
||||||
|
|
||||||
void ConvertRGBA4ToRGBA8(std::span<const std::byte> source, std::span<std::byte> dest);
|
void ConvertRGBA4ToRGBA8(std::span<const std::byte> source, std::span<std::byte> dest);
|
||||||
|
|
||||||
void ConvertRGBA8ToRGBA4(std::span<const std::byte> source, std::span<std::byte> dest);
|
void ConvertRGBA8ToRGBA4(std::span<const std::byte> source, std::span<std::byte> dest);
|
||||||
|
|
||||||
|
void ConvertRGB5A1ToRGBA8(std::span<const std::byte> source, std::span<std::byte> dest);
|
||||||
|
|
||||||
|
void ConvertD32S8ToD24S8(std::span<const std::byte> source, std::span<std::byte> dest);
|
||||||
|
|
||||||
void InterleaveD24S8(std::span<const std::byte> source, std::span<std::byte> dest);
|
void InterleaveD24S8(std::span<const std::byte> source, std::span<std::byte> dest);
|
||||||
|
|
||||||
} // namespace Pica::Texture
|
} // namespace Pica::Texture
|
||||||
|
Reference in New Issue
Block a user