mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-08-23 12:40:42 +02:00
glsl: Add MS sampler types
This commit is contained in:
parent
e54d08fc1f
commit
5710e90150
@ -61,24 +61,28 @@ std::string OutputDecorator(Stage stage, u32 size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string_view SamplerType(TextureType type, bool is_depth) {
|
std::string_view DepthSamplerType(TextureType type) {
|
||||||
if (is_depth) {
|
switch (type) {
|
||||||
switch (type) {
|
case TextureType::Color1D:
|
||||||
case TextureType::Color1D:
|
return "sampler1DShadow";
|
||||||
return "sampler1DShadow";
|
case TextureType::ColorArray1D:
|
||||||
case TextureType::ColorArray1D:
|
return "sampler1DArrayShadow";
|
||||||
return "sampler1DArrayShadow";
|
case TextureType::Color2D:
|
||||||
case TextureType::Color2D:
|
return "sampler2DShadow";
|
||||||
return "sampler2DShadow";
|
case TextureType::ColorArray2D:
|
||||||
case TextureType::ColorArray2D:
|
return "sampler2DArrayShadow";
|
||||||
return "sampler2DArrayShadow";
|
case TextureType::ColorCube:
|
||||||
case TextureType::ColorCube:
|
return "samplerCubeShadow";
|
||||||
return "samplerCubeShadow";
|
case TextureType::ColorArrayCube:
|
||||||
case TextureType::ColorArrayCube:
|
return "samplerCubeArrayShadow";
|
||||||
return "samplerCubeArrayShadow";
|
default:
|
||||||
default:
|
throw NotImplementedException("Texture type: {}", type);
|
||||||
throw NotImplementedException("Texture type: {}", type);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string_view ColorSamplerType(TextureType type, bool is_multisample = false) {
|
||||||
|
if (is_multisample) {
|
||||||
|
ASSERT(type == TextureType::Color2D || type == TextureType::ColorArray2D);
|
||||||
}
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TextureType::Color1D:
|
case TextureType::Color1D:
|
||||||
@ -87,9 +91,9 @@ std::string_view SamplerType(TextureType type, bool is_depth) {
|
|||||||
return "sampler1DArray";
|
return "sampler1DArray";
|
||||||
case TextureType::Color2D:
|
case TextureType::Color2D:
|
||||||
case TextureType::Color2DRect:
|
case TextureType::Color2DRect:
|
||||||
return "sampler2D";
|
return is_multisample ? "sampler2DMS" : "sampler2D";
|
||||||
case TextureType::ColorArray2D:
|
case TextureType::ColorArray2D:
|
||||||
return "sampler2DArray";
|
return is_multisample ? "sampler2DMSArray" : "sampler2DArray";
|
||||||
case TextureType::Color3D:
|
case TextureType::Color3D:
|
||||||
return "sampler3D";
|
return "sampler3D";
|
||||||
case TextureType::ColorCube:
|
case TextureType::ColorCube:
|
||||||
@ -677,7 +681,7 @@ void EmitContext::SetupTextures(Bindings& bindings) {
|
|||||||
texture_buffers.reserve(info.texture_buffer_descriptors.size());
|
texture_buffers.reserve(info.texture_buffer_descriptors.size());
|
||||||
for (const auto& desc : info.texture_buffer_descriptors) {
|
for (const auto& desc : info.texture_buffer_descriptors) {
|
||||||
texture_buffers.push_back({bindings.texture, desc.count});
|
texture_buffers.push_back({bindings.texture, desc.count});
|
||||||
const auto sampler_type{SamplerType(TextureType::Buffer, false)};
|
const auto sampler_type{ColorSamplerType(TextureType::Buffer)};
|
||||||
const auto array_decorator{desc.count > 1 ? fmt::format("[{}]", desc.count) : ""};
|
const auto array_decorator{desc.count > 1 ? fmt::format("[{}]", desc.count) : ""};
|
||||||
header += fmt::format("layout(binding={}) uniform {} tex{}{};", bindings.texture,
|
header += fmt::format("layout(binding={}) uniform {} tex{}{};", bindings.texture,
|
||||||
sampler_type, bindings.texture, array_decorator);
|
sampler_type, bindings.texture, array_decorator);
|
||||||
@ -686,7 +690,8 @@ void EmitContext::SetupTextures(Bindings& bindings) {
|
|||||||
textures.reserve(info.texture_descriptors.size());
|
textures.reserve(info.texture_descriptors.size());
|
||||||
for (const auto& desc : info.texture_descriptors) {
|
for (const auto& desc : info.texture_descriptors) {
|
||||||
textures.push_back({bindings.texture, desc.count});
|
textures.push_back({bindings.texture, desc.count});
|
||||||
const auto sampler_type{SamplerType(desc.type, desc.is_depth)};
|
const auto sampler_type{desc.is_depth ? DepthSamplerType(desc.type)
|
||||||
|
: ColorSamplerType(desc.type, desc.is_multisample)};
|
||||||
const auto array_decorator{desc.count > 1 ? fmt::format("[{}]", desc.count) : ""};
|
const auto array_decorator{desc.count > 1 ? fmt::format("[{}]", desc.count) : ""};
|
||||||
header += fmt::format("layout(binding={}) uniform {} tex{}{};", bindings.texture,
|
header += fmt::format("layout(binding={}) uniform {} tex{}{};", bindings.texture,
|
||||||
sampler_type, bindings.texture, array_decorator);
|
sampler_type, bindings.texture, array_decorator);
|
||||||
|
Loading…
Reference in New Issue
Block a user