|
1 | 1 | /* |
2 | | - * Copyright 2019-2023 Diligent Graphics LLC |
| 2 | + * Copyright 2019-2024 Diligent Graphics LLC |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -239,27 +239,30 @@ void SerializedShaderImpl::CreateShaderGL(IReferenceCounters* pRefCounters, |
239 | 239 | CreateShader<CompiledShaderGL>(DeviceType::OpenGL, pRefCounters, ShaderCI, GLShaderCI, m_pDevice->GetRenderDevice(RENDER_DEVICE_TYPE_GL)); |
240 | 240 |
|
241 | 241 | #if !DILIGENT_NO_GLSLANG |
242 | | - const auto* pCompiledShaderGL = GetShader<CompiledShaderGL>(DeviceObjectArchive::DeviceType::OpenGL); |
243 | | - VERIFY_EXPR(pCompiledShaderGL != nullptr); |
| 242 | + if (m_pDevice->GetGLProperties().ValidateShaders) |
| 243 | + { |
| 244 | + const auto* pCompiledShaderGL = GetShader<CompiledShaderGL>(DeviceObjectArchive::DeviceType::OpenGL); |
| 245 | + VERIFY_EXPR(pCompiledShaderGL != nullptr); |
244 | 246 |
|
245 | | - const void* Source = nullptr; |
246 | | - Uint64 SourceLen = 0; |
247 | | - // For OpenGL, GetBytecode returns the full GLSL source |
248 | | - pCompiledShaderGL->pShaderGL->GetBytecode(&Source, SourceLen); |
249 | | - VERIFY_EXPR(Source != nullptr && SourceLen != 0); |
| 247 | + const void* Source = nullptr; |
| 248 | + Uint64 SourceLen = 0; |
| 249 | + // For OpenGL, GetBytecode returns the full GLSL source |
| 250 | + pCompiledShaderGL->pShaderGL->GetBytecode(&Source, SourceLen); |
| 251 | + VERIFY_EXPR(Source != nullptr && SourceLen != 0); |
250 | 252 |
|
251 | | - GLSLangUtils::GLSLtoSPIRVAttribs Attribs; |
| 253 | + GLSLangUtils::GLSLtoSPIRVAttribs Attribs; |
252 | 254 |
|
253 | | - Attribs.ShaderType = ShaderCI.Desc.ShaderType; |
254 | | - VERIFY_EXPR(DeviceType == RENDER_DEVICE_TYPE_GL || DeviceType == RENDER_DEVICE_TYPE_GLES); |
255 | | - Attribs.Version = DeviceType == RENDER_DEVICE_TYPE_GL ? GLSLangUtils::SpirvVersion::GL : GLSLangUtils::SpirvVersion::GLES; |
| 255 | + Attribs.ShaderType = ShaderCI.Desc.ShaderType; |
| 256 | + VERIFY_EXPR(DeviceType == RENDER_DEVICE_TYPE_GL || DeviceType == RENDER_DEVICE_TYPE_GLES); |
| 257 | + Attribs.Version = DeviceType == RENDER_DEVICE_TYPE_GL ? GLSLangUtils::SpirvVersion::GL : GLSLangUtils::SpirvVersion::GLES; |
256 | 258 |
|
257 | | - Attribs.ppCompilerOutput = ppCompilerOutput; |
258 | | - Attribs.ShaderSource = static_cast<const char*>(Source); |
259 | | - Attribs.SourceCodeLen = static_cast<int>(SourceLen); |
| 259 | + Attribs.ppCompilerOutput = ppCompilerOutput; |
| 260 | + Attribs.ShaderSource = static_cast<const char*>(Source); |
| 261 | + Attribs.SourceCodeLen = static_cast<int>(SourceLen); |
260 | 262 |
|
261 | | - if (GLSLangUtils::GLSLtoSPIRV(Attribs).empty()) |
262 | | - LOG_ERROR_AND_THROW("Failed to compile shader '", ShaderCI.Desc.Name, "'"); |
| 263 | + if (GLSLangUtils::GLSLtoSPIRV(Attribs).empty()) |
| 264 | + LOG_ERROR_AND_THROW("Failed to compile shader '", ShaderCI.Desc.Name, "'"); |
| 265 | + } |
263 | 266 | #endif |
264 | 267 | } |
265 | 268 |
|
|
0 commit comments