mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 13:35:06 +02:00
Merge pull request #12921 from SamGondelman/precisionq
Fix AMD shader compilation
This commit is contained in:
commit
d1e2e9ce71
11 changed files with 30 additions and 78 deletions
|
@ -452,7 +452,7 @@ protected:
|
||||||
// Backend dependant compilation of the shader
|
// Backend dependant compilation of the shader
|
||||||
virtual GLShader* compileBackendProgram(const Shader& program, const Shader::CompilationHandler& handler);
|
virtual GLShader* compileBackendProgram(const Shader& program, const Shader::CompilationHandler& handler);
|
||||||
virtual GLShader* compileBackendShader(const Shader& shader, const Shader::CompilationHandler& handler);
|
virtual GLShader* compileBackendShader(const Shader& shader, const Shader::CompilationHandler& handler);
|
||||||
virtual std::string getBackendShaderHeader() const;
|
virtual std::string getBackendShaderHeader() const = 0;
|
||||||
virtual void makeProgramBindings(ShaderObject& shaderObject);
|
virtual void makeProgramBindings(ShaderObject& shaderObject);
|
||||||
class ElementResource {
|
class ElementResource {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -12,27 +12,6 @@
|
||||||
using namespace gpu;
|
using namespace gpu;
|
||||||
using namespace gpu::gl;
|
using namespace gpu::gl;
|
||||||
|
|
||||||
// GLSL version
|
|
||||||
std::string GLBackend::getBackendShaderHeader() const {
|
|
||||||
|
|
||||||
#if defined(USE_GLES)
|
|
||||||
static const std::string header(
|
|
||||||
R"SHADER(#version 310 es
|
|
||||||
#extension GL_EXT_texture_buffer : enable
|
|
||||||
precision lowp float; // check precision 2
|
|
||||||
precision lowp samplerBuffer;
|
|
||||||
precision lowp sampler2DShadow;
|
|
||||||
)SHADER");
|
|
||||||
#else
|
|
||||||
static const std::string header(
|
|
||||||
R"SHADER(#version 410 core
|
|
||||||
)SHADER");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return header;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Shader domain
|
// Shader domain
|
||||||
static const size_t NUM_SHADER_DOMAINS = 3;
|
static const size_t NUM_SHADER_DOMAINS = 3;
|
||||||
static_assert(Shader::Type::NUM_DOMAINS == NUM_SHADER_DOMAINS, "GL shader domains must equal defined GPU shader domains");
|
static_assert(Shader::Type::NUM_DOMAINS == NUM_SHADER_DOMAINS, "GL shader domains must equal defined GPU shader domains");
|
||||||
|
|
|
@ -14,7 +14,13 @@ using namespace gpu::gl41;
|
||||||
|
|
||||||
// GLSL version
|
// GLSL version
|
||||||
std::string GL41Backend::getBackendShaderHeader() const {
|
std::string GL41Backend::getBackendShaderHeader() const {
|
||||||
return std::string("#version 410 core\n#define GPU_GL410 1");
|
static const std::string header(
|
||||||
|
R"SHADER(#version 410 core
|
||||||
|
#define GPU_GL410
|
||||||
|
#define PRECISIONQ
|
||||||
|
#define BITFIELD int
|
||||||
|
)SHADER");
|
||||||
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GL41Backend::makeResourceBufferSlots(GLuint glprogram, const Shader::BindingSet& slotBindings,Shader::SlotSet& resourceBuffers) {
|
int GL41Backend::makeResourceBufferSlots(GLuint glprogram, const Shader::BindingSet& slotBindings,Shader::SlotSet& resourceBuffers) {
|
||||||
|
|
|
@ -15,15 +15,17 @@ using namespace gpu::gl45;
|
||||||
|
|
||||||
// GLSL version
|
// GLSL version
|
||||||
std::string GL45Backend::getBackendShaderHeader() const {
|
std::string GL45Backend::getBackendShaderHeader() const {
|
||||||
const char header[] =
|
static const std::string header(
|
||||||
R"GLSL(#version 450 core
|
R"SHADER(#version 450 core
|
||||||
#define GPU_GL450
|
#define GPU_GL450
|
||||||
)GLSL"
|
#define PRECISIONQ
|
||||||
|
#define BITFIELD int
|
||||||
|
)SHADER"
|
||||||
#ifdef GPU_SSBO_TRANSFORM_OBJECT
|
#ifdef GPU_SSBO_TRANSFORM_OBJECT
|
||||||
R"GLSL(#define GPU_SSBO_TRANSFORM_OBJECT 1)GLSL"
|
R"SHADER(#define GPU_SSBO_TRANSFORM_OBJECT)SHADER"
|
||||||
#endif
|
#endif
|
||||||
;
|
);
|
||||||
return std::string(header);
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GL45Backend::makeResourceBufferSlots(GLuint glprogram, const Shader::BindingSet& slotBindings,Shader::SlotSet& resourceBuffers) {
|
int GL45Backend::makeResourceBufferSlots(GLuint glprogram, const Shader::BindingSet& slotBindings,Shader::SlotSet& resourceBuffers) {
|
||||||
|
|
|
@ -14,7 +14,16 @@ using namespace gpu::gles;
|
||||||
|
|
||||||
// GLSL version
|
// GLSL version
|
||||||
std::string GLESBackend::getBackendShaderHeader() const {
|
std::string GLESBackend::getBackendShaderHeader() const {
|
||||||
return Parent::getBackendShaderHeader();
|
static const std::string header(
|
||||||
|
R"SHADER(#version 310 es
|
||||||
|
#extension GL_EXT_texture_buffer : enable
|
||||||
|
precision lowp float; // check precision 2
|
||||||
|
precision lowp samplerBuffer;
|
||||||
|
precision lowp sampler2DShadow;
|
||||||
|
#define PRECISIONQ highp
|
||||||
|
#define BITFIELD highp int
|
||||||
|
)SHADER");
|
||||||
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GLESBackend::makeResourceBufferSlots(GLuint glprogram, const Shader::BindingSet& slotBindings,Shader::SlotSet& resourceBuffers) {
|
int GLESBackend::makeResourceBufferSlots(GLuint glprogram, const Shader::BindingSet& slotBindings,Shader::SlotSet& resourceBuffers) {
|
||||||
|
|
|
@ -29,16 +29,9 @@ vec3 getLightColor(Light l) { return lightIrradiance_getColor(l.irradiance); }
|
||||||
float getLightIntensity(Light l) { return lightIrradiance_getIntensity(l.irradiance); }
|
float getLightIntensity(Light l) { return lightIrradiance_getIntensity(l.irradiance); }
|
||||||
vec3 getLightIrradiance(Light l) { return lightIrradiance_getIrradiance(l.irradiance); }
|
vec3 getLightIrradiance(Light l) { return lightIrradiance_getIrradiance(l.irradiance); }
|
||||||
|
|
||||||
// AMbient lighting needs extra info provided from a different Buffer
|
// Ambient lighting needs extra info provided from a different Buffer
|
||||||
<@include graphics/SphericalHarmonics.shared.slh@>
|
<@include graphics/SphericalHarmonics.shared.slh@>
|
||||||
// Light Ambient
|
// Light Ambient
|
||||||
#ifndef PRECISIONQ
|
|
||||||
#ifdef GL_ES
|
|
||||||
#define PRECISIONQ highp
|
|
||||||
#else
|
|
||||||
#define PRECISIONQ
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct LightAmbient {
|
struct LightAmbient {
|
||||||
PRECISIONQ vec4 _ambient;
|
PRECISIONQ vec4 _ambient;
|
||||||
|
|
|
@ -12,13 +12,7 @@
|
||||||
|
|
||||||
|
|
||||||
#define LightIrradianceConstRef LightIrradiance
|
#define LightIrradianceConstRef LightIrradiance
|
||||||
#ifndef PRECISIONQ
|
|
||||||
#ifdef GL_ES
|
|
||||||
#define PRECISIONQ highp
|
|
||||||
#else
|
|
||||||
#define PRECISIONQ
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
struct LightIrradiance {
|
struct LightIrradiance {
|
||||||
PRECISIONQ vec4 colorIntensity;
|
PRECISIONQ vec4 colorIntensity;
|
||||||
// falloffRadius, cutoffRadius, falloffSpot, spare
|
// falloffRadius, cutoffRadius, falloffSpot, spare
|
||||||
|
|
|
@ -15,14 +15,6 @@
|
||||||
|
|
||||||
#define LightVolumeConstRef LightVolume
|
#define LightVolumeConstRef LightVolume
|
||||||
|
|
||||||
#ifndef PRECISIONQ
|
|
||||||
#ifdef GL_ES
|
|
||||||
#define PRECISIONQ highp
|
|
||||||
#else
|
|
||||||
#define PRECISIONQ
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct LightVolume {
|
struct LightVolume {
|
||||||
PRECISIONQ vec4 positionRadius;
|
PRECISIONQ vec4 positionRadius;
|
||||||
PRECISIONQ vec4 directionSpotCos;
|
PRECISIONQ vec4 directionSpotCos;
|
||||||
|
|
|
@ -13,14 +13,7 @@
|
||||||
|
|
||||||
// The material values (at least the material key) must be precisely bitwise accurate
|
// The material values (at least the material key) must be precisely bitwise accurate
|
||||||
// to what is provided by the uniform buffer, or the material key has the wrong bits
|
// to what is provided by the uniform buffer, or the material key has the wrong bits
|
||||||
#ifdef GL_ES
|
|
||||||
precision highp float;
|
|
||||||
#define BITFIELD highp int
|
|
||||||
#define PRECISIONQ highp
|
|
||||||
#else
|
|
||||||
#define BITFIELD int
|
|
||||||
#define PRECISIONQ
|
|
||||||
#endif
|
|
||||||
struct Material {
|
struct Material {
|
||||||
PRECISIONQ vec4 _emissiveOpacity;
|
PRECISIONQ vec4 _emissiveOpacity;
|
||||||
PRECISIONQ vec4 _albedoRoughness;
|
PRECISIONQ vec4 _albedoRoughness;
|
||||||
|
|
|
@ -15,14 +15,6 @@
|
||||||
|
|
||||||
#define SphericalHarmonicsConstRef SphericalHarmonics
|
#define SphericalHarmonicsConstRef SphericalHarmonics
|
||||||
|
|
||||||
#ifndef PRECISIONQ
|
|
||||||
#ifdef GL_ES
|
|
||||||
#define PRECISIONQ highp
|
|
||||||
#else
|
|
||||||
#define PRECISIONQ
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct SphericalHarmonics {
|
struct SphericalHarmonics {
|
||||||
PRECISIONQ vec4 L00;
|
PRECISIONQ vec4 L00;
|
||||||
PRECISIONQ vec4 L1m1;
|
PRECISIONQ vec4 L1m1;
|
||||||
|
|
|
@ -13,14 +13,6 @@
|
||||||
|
|
||||||
<@func declareLightingModel()@>
|
<@func declareLightingModel()@>
|
||||||
|
|
||||||
#ifndef PRECISIONQ
|
|
||||||
#ifdef GL_ES
|
|
||||||
#define PRECISIONQ highp
|
|
||||||
#else
|
|
||||||
#define PRECISIONQ
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct LightingModel {
|
struct LightingModel {
|
||||||
PRECISIONQ vec4 _UnlitEmissiveLightmapBackground;
|
PRECISIONQ vec4 _UnlitEmissiveLightmapBackground;
|
||||||
PRECISIONQ vec4 _ScatteringDiffuseSpecularAlbedo;
|
PRECISIONQ vec4 _ScatteringDiffuseSpecularAlbedo;
|
||||||
|
|
Loading…
Reference in a new issue