mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
love.graphics.validateShader no longer errors if the system doesn't support the shader
This commit is contained in:
@@ -241,7 +241,8 @@ ShaderStage *Graphics::newShaderStage(ShaderStageType stage, const std::string &
|
|||||||
|
|
||||||
if (s == nullptr)
|
if (s == nullptr)
|
||||||
{
|
{
|
||||||
std::string glsl = Shader::createShaderStageCode(this, stage, source, info);
|
bool gles = getRenderer() == Graphics::RENDERER_OPENGLES;
|
||||||
|
std::string glsl = Shader::createShaderStageCode(this, stage, source, info, gles, true);
|
||||||
s = newShaderStageInternal(stage, cachekey, glsl, getRenderer() == RENDERER_OPENGLES);
|
s = newShaderStageInternal(stage, cachekey, glsl, getRenderer() == RENDERER_OPENGLES);
|
||||||
if (!cachekey.empty())
|
if (!cachekey.empty())
|
||||||
cachedShaderStages[stage][cachekey] = s;
|
cachedShaderStages[stage][cachekey] = s;
|
||||||
@@ -363,7 +364,7 @@ bool Graphics::validateShader(bool gles, const std::vector<std::string> &stagess
|
|||||||
if (info.stages[i] != Shader::ENTRYPOINT_NONE)
|
if (info.stages[i] != Shader::ENTRYPOINT_NONE)
|
||||||
{
|
{
|
||||||
isanystage = true;
|
isanystage = true;
|
||||||
std::string glsl = Shader::createShaderStageCode(this, stype, source, info);
|
std::string glsl = Shader::createShaderStageCode(this, stype, source, info, gles, false);
|
||||||
stages[i].set(new ShaderStageForValidation(this, stype, glsl, gles), Acquire::NORETAIN);
|
stages[i].set(new ShaderStageForValidation(this, stype, glsl, gles), Acquire::NORETAIN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -514,7 +514,7 @@ Shader::SourceInfo Shader::getSourceInfo(const std::string &src)
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Shader::createShaderStageCode(Graphics *gfx, ShaderStageType stage, const std::string &code, const Shader::SourceInfo &info)
|
std::string Shader::createShaderStageCode(Graphics *gfx, ShaderStageType stage, const std::string &code, const Shader::SourceInfo &info, bool gles, bool checksystemfeatures)
|
||||||
{
|
{
|
||||||
if (info.language == Shader::LANGUAGE_MAX_ENUM)
|
if (info.language == Shader::LANGUAGE_MAX_ENUM)
|
||||||
throw love::Exception("Invalid shader language");
|
throw love::Exception("Invalid shader language");
|
||||||
@@ -528,19 +528,23 @@ std::string Shader::createShaderStageCode(Graphics *gfx, ShaderStageType stage,
|
|||||||
if (stage == SHADERSTAGE_COMPUTE && info.language != LANGUAGE_GLSL4)
|
if (stage == SHADERSTAGE_COMPUTE && info.language != LANGUAGE_GLSL4)
|
||||||
throw love::Exception("Compute shaders must use GLSL 4.");
|
throw love::Exception("Compute shaders must use GLSL 4.");
|
||||||
|
|
||||||
const auto &features = gfx->getCapabilities().features;
|
bool glsl1on3 = info.language == LANGUAGE_GLSL1;
|
||||||
|
|
||||||
if (stage == SHADERSTAGE_COMPUTE && !features[Graphics::FEATURE_GLSL4])
|
if (checksystemfeatures)
|
||||||
throw love::Exception("Compute shaders require GLSL 4 which is not supported on this system.");
|
{
|
||||||
|
const auto &features = gfx->getCapabilities().features;
|
||||||
|
|
||||||
if (info.language == LANGUAGE_GLSL3 && !features[Graphics::FEATURE_GLSL3])
|
if (stage == SHADERSTAGE_COMPUTE && !features[Graphics::FEATURE_GLSL4])
|
||||||
throw love::Exception("GLSL 3 shaders are not supported on this system.");
|
throw love::Exception("Compute shaders require GLSL 4 which is not supported on this system.");
|
||||||
|
|
||||||
if (info.language == LANGUAGE_GLSL4 && !features[Graphics::FEATURE_GLSL4])
|
if (info.language == LANGUAGE_GLSL3 && !features[Graphics::FEATURE_GLSL3])
|
||||||
throw love::Exception("GLSL 4 shaders are not supported on this system.");
|
throw love::Exception("GLSL 3 shaders are not supported on this system.");
|
||||||
|
|
||||||
bool gles = gfx->getRenderer() == Graphics::RENDERER_OPENGLES;
|
if (info.language == LANGUAGE_GLSL4 && !features[Graphics::FEATURE_GLSL4])
|
||||||
bool glsl1on3 = info.language == LANGUAGE_GLSL1 && features[Graphics::FEATURE_GLSL3];
|
throw love::Exception("GLSL 4 shaders are not supported on this system.");
|
||||||
|
|
||||||
|
glsl1on3 = info.language == LANGUAGE_GLSL1 && features[Graphics::FEATURE_GLSL3];
|
||||||
|
}
|
||||||
|
|
||||||
Language lang = info.language;
|
Language lang = info.language;
|
||||||
if (glsl1on3)
|
if (glsl1on3)
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ public:
|
|||||||
void getLocalThreadgroupSize(int *x, int *y, int *z);
|
void getLocalThreadgroupSize(int *x, int *y, int *z);
|
||||||
|
|
||||||
static SourceInfo getSourceInfo(const std::string &src);
|
static SourceInfo getSourceInfo(const std::string &src);
|
||||||
static std::string createShaderStageCode(Graphics *gfx, ShaderStageType stage, const std::string &code, const SourceInfo &info);
|
static std::string createShaderStageCode(Graphics *gfx, ShaderStageType stage, const std::string &code, const SourceInfo &info, bool gles, bool checksystemfeatures);
|
||||||
|
|
||||||
static bool validate(StrongRef<ShaderStage> stages[], std::string &err);
|
static bool validate(StrongRef<ShaderStage> stages[], std::string &err);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user