diff options
| author | Darren Wihandi <65404740+fairywreath@users.noreply.github.com> | 2025-01-24 16:13:16 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-24 13:13:16 -0800 |
| commit | 0dd9076db2154d787f6e06b713721e877b746b83 (patch) | |
| tree | 24f75b2c612fc0ee5a3ba8157c4d0dde7ff9a3a0 /source/slang/slang-emit-glsl.cpp | |
| parent | 92c9fffb95c92b0bc07eb1c656375928b5cd5c33 (diff) | |
Add bgra8 format (#6163)
* add brga8 format
* add tests
* minor fixes
* cleanup
* maybe fix broken quad control test
* add missing xslang flag on test
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-emit-glsl.cpp')
| -rw-r--r-- | source/slang/slang-emit-glsl.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index b94f44690..61457d98e 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -608,6 +608,19 @@ void GLSLSourceEmitter::_emitGLSLParameterGroup( m_writer->emit(";\n"); } +static bool isImageFormatSupportedByGLSL(ImageFormat format) +{ + switch (format) + { + case ImageFormat::bgra8: + // These are formats Slang accept, but are not explicitly supported in GLSL. + return false; + default: + return true; + } +}; + + void GLSLSourceEmitter::_emitGLSLImageFormatModifier(IRInst* var, IRTextureType* resourceType) { SLANG_UNUSED(resourceType); @@ -618,6 +631,18 @@ void GLSLSourceEmitter::_emitGLSLImageFormatModifier(IRInst* var, IRTextureType* if (auto formatDecoration = var->findDecoration<IRFormatDecoration>()) { auto format = formatDecoration->getFormat(); + const auto formatInfo = getImageFormatInfo(format); + if (!isImageFormatSupportedByGLSL(format)) + { + getSink()->diagnose( + SourceLoc(), + Diagnostics::imageFormatUnsupportedByBackend, + formatInfo.name, + "GLSL", + "unknown"); + format = ImageFormat::unknown; + } + if (format == ImageFormat::unknown) { // If the user explicitly opts out of having a format, then @@ -636,7 +661,6 @@ void GLSLSourceEmitter::_emitGLSLImageFormatModifier(IRInst* var, IRTextureType* } else { - auto formatInfo = getImageFormatInfo(format); if (formatInfo.scalarType == SLANG_SCALAR_TYPE_UINT64 || formatInfo.scalarType == SLANG_SCALAR_TYPE_INT64) { |
