mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 12:49:34 +02:00
PR feedback
This commit is contained in:
parent
a1a1a03bbc
commit
8eb97dc79c
4 changed files with 35 additions and 24 deletions
|
@ -82,8 +82,8 @@ Shader::Pointer Shader::createOrReuseDomainShader(Type type, const Source& sourc
|
||||||
if (0 != reflection.count(BindingType::UNIFORM_BUFFER)) {
|
if (0 != reflection.count(BindingType::UNIFORM_BUFFER)) {
|
||||||
populateSlotSet(shader->_uniformBuffers, reflection.find(BindingType::UNIFORM_BUFFER)->second);
|
populateSlotSet(shader->_uniformBuffers, reflection.find(BindingType::UNIFORM_BUFFER)->second);
|
||||||
}
|
}
|
||||||
if (0 != reflection.count(BindingType::STORAGE_BUFFER)) {
|
if (0 != reflection.count(BindingType::RESOURCE_BUFFER)) {
|
||||||
populateSlotSet(shader->_resourceBuffers, reflection.find(BindingType::STORAGE_BUFFER)->second);
|
populateSlotSet(shader->_resourceBuffers, reflection.find(BindingType::RESOURCE_BUFFER)->second);
|
||||||
}
|
}
|
||||||
if (0 != reflection.count(BindingType::TEXTURE)) {
|
if (0 != reflection.count(BindingType::TEXTURE)) {
|
||||||
populateSlotSet(shader->_textures, reflection.find(BindingType::TEXTURE)->second);
|
populateSlotSet(shader->_textures, reflection.find(BindingType::TEXTURE)->second);
|
||||||
|
@ -91,8 +91,8 @@ Shader::Pointer Shader::createOrReuseDomainShader(Type type, const Source& sourc
|
||||||
if (0 != reflection.count(BindingType::SAMPLER)) {
|
if (0 != reflection.count(BindingType::SAMPLER)) {
|
||||||
populateSlotSet(shader->_samplers, reflection.find(BindingType::SAMPLER)->second);
|
populateSlotSet(shader->_samplers, reflection.find(BindingType::SAMPLER)->second);
|
||||||
}
|
}
|
||||||
if (0 != reflection.count(BindingType::PUSH_CONSTANT)) {
|
if (0 != reflection.count(BindingType::UNIFORM)) {
|
||||||
populateSlotSet(shader->_uniforms, reflection.find(BindingType::PUSH_CONSTANT)->second);
|
populateSlotSet(shader->_uniforms, reflection.find(BindingType::UNIFORM)->second);
|
||||||
}
|
}
|
||||||
_domainShaderMaps[type].emplace(source, std::weak_ptr<Shader>(shader));
|
_domainShaderMaps[type].emplace(source, std::weak_ptr<Shader>(shader));
|
||||||
return shader;
|
return shader;
|
||||||
|
@ -144,8 +144,8 @@ ShaderPointer Shader::createOrReuseProgramShader(Type type, const Pointer& verte
|
||||||
if (0 != reflection.count(BindingType::UNIFORM_BUFFER)) {
|
if (0 != reflection.count(BindingType::UNIFORM_BUFFER)) {
|
||||||
populateSlotSet(program->_uniformBuffers, reflection.find(BindingType::UNIFORM_BUFFER)->second);
|
populateSlotSet(program->_uniformBuffers, reflection.find(BindingType::UNIFORM_BUFFER)->second);
|
||||||
}
|
}
|
||||||
if (0 != reflection.count(BindingType::STORAGE_BUFFER)) {
|
if (0 != reflection.count(BindingType::RESOURCE_BUFFER)) {
|
||||||
populateSlotSet(program->_resourceBuffers, reflection.find(BindingType::STORAGE_BUFFER)->second);
|
populateSlotSet(program->_resourceBuffers, reflection.find(BindingType::RESOURCE_BUFFER)->second);
|
||||||
}
|
}
|
||||||
if (0 != reflection.count(BindingType::TEXTURE)) {
|
if (0 != reflection.count(BindingType::TEXTURE)) {
|
||||||
populateSlotSet(program->_textures, reflection.find(BindingType::TEXTURE)->second);
|
populateSlotSet(program->_textures, reflection.find(BindingType::TEXTURE)->second);
|
||||||
|
@ -153,8 +153,8 @@ ShaderPointer Shader::createOrReuseProgramShader(Type type, const Pointer& verte
|
||||||
if (0 != reflection.count(BindingType::SAMPLER)) {
|
if (0 != reflection.count(BindingType::SAMPLER)) {
|
||||||
populateSlotSet(program->_samplers, reflection.find(BindingType::SAMPLER)->second);
|
populateSlotSet(program->_samplers, reflection.find(BindingType::SAMPLER)->second);
|
||||||
}
|
}
|
||||||
if (0 != reflection.count(BindingType::PUSH_CONSTANT)) {
|
if (0 != reflection.count(BindingType::UNIFORM)) {
|
||||||
populateSlotSet(program->_uniforms, reflection.find(BindingType::PUSH_CONSTANT)->second);
|
populateSlotSet(program->_uniforms, reflection.find(BindingType::UNIFORM)->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -215,6 +215,13 @@ Shader::ReflectionMap getShaderReflection(const std::string& reflectionJson) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define REFLECT_KEY_INPUTS "inputs"
|
||||||
|
#define REFLECT_KEY_OUTPUTS "outputs"
|
||||||
|
#define REFLECT_KEY_UBOS "uniformBuffers"
|
||||||
|
#define REFLECT_KEY_SSBOS "storageBuffers"
|
||||||
|
#define REFLECT_KEY_UNIFORMS "uniforms"
|
||||||
|
#define REFLECT_KEY_TEXTURES "textures"
|
||||||
|
|
||||||
auto doc = QJsonDocument::fromJson(reflectionJson.c_str());
|
auto doc = QJsonDocument::fromJson(reflectionJson.c_str());
|
||||||
if (doc.isNull()) {
|
if (doc.isNull()) {
|
||||||
qWarning() << "Invalid shader reflection JSON" << reflectionJson.c_str();
|
qWarning() << "Invalid shader reflection JSON" << reflectionJson.c_str();
|
||||||
|
@ -223,21 +230,26 @@ Shader::ReflectionMap getShaderReflection(const std::string& reflectionJson) {
|
||||||
|
|
||||||
Shader::ReflectionMap result;
|
Shader::ReflectionMap result;
|
||||||
auto json = doc.object();
|
auto json = doc.object();
|
||||||
if (json.contains("inputs")) {
|
if (json.contains(REFLECT_KEY_INPUTS)) {
|
||||||
updateBindingsFromJsonObject(result[Shader::BindingType::INPUT], json["inputs"].toObject());
|
updateBindingsFromJsonObject(result[Shader::BindingType::INPUT], json[REFLECT_KEY_INPUTS].toObject());
|
||||||
}
|
}
|
||||||
if (json.contains("outputs")) {
|
if (json.contains(REFLECT_KEY_OUTPUTS)) {
|
||||||
updateBindingsFromJsonObject(result[Shader::BindingType::OUTPUT], json["outputs"].toObject());
|
updateBindingsFromJsonObject(result[Shader::BindingType::OUTPUT], json[REFLECT_KEY_OUTPUTS].toObject());
|
||||||
}
|
}
|
||||||
if (json.contains("uniformBuffers")) {
|
if (json.contains(REFLECT_KEY_UBOS)) {
|
||||||
updateBindingsFromJsonObject(result[Shader::BindingType::UNIFORM_BUFFER], json["uniformBuffers"].toObject());
|
updateBindingsFromJsonObject(result[Shader::BindingType::UNIFORM_BUFFER], json[REFLECT_KEY_UBOS].toObject());
|
||||||
}
|
}
|
||||||
if (json.contains("textures")) {
|
if (json.contains(REFLECT_KEY_TEXTURES)) {
|
||||||
updateBindingsFromJsonObject(result[Shader::BindingType::TEXTURE], json["textures"].toObject());
|
updateBindingsFromJsonObject(result[Shader::BindingType::TEXTURE], json[REFLECT_KEY_TEXTURES].toObject());
|
||||||
}
|
}
|
||||||
if (json.contains("uniforms")) {
|
if (json.contains(REFLECT_KEY_UNIFORMS)) {
|
||||||
updateBindingsFromJsonObject(result[Shader::BindingType::PUSH_CONSTANT], json["uniforms"].toObject());
|
updateBindingsFromJsonObject(result[Shader::BindingType::UNIFORM], json[REFLECT_KEY_UNIFORMS].toObject());
|
||||||
}
|
}
|
||||||
|
if (json.contains(REFLECT_KEY_SSBOS)) {
|
||||||
|
updateBindingsFromJsonObject(result[Shader::BindingType::UNIFORM], json[REFLECT_KEY_SSBOS].toObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,9 +51,8 @@ public:
|
||||||
TEXTURE,
|
TEXTURE,
|
||||||
SAMPLER,
|
SAMPLER,
|
||||||
UNIFORM_BUFFER,
|
UNIFORM_BUFFER,
|
||||||
STORAGE_BUFFER,
|
RESOURCE_BUFFER,
|
||||||
PUSH_CONSTANT, // Equivalent to uniforms in GL
|
UNIFORM,
|
||||||
SPECIALIZATION_CONSTANT,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
using LocationMap = std::unordered_map<std::string, int32_t>;
|
using LocationMap = std::unordered_map<std::string, int32_t>;
|
||||||
|
|
|
@ -253,10 +253,10 @@ void Procedural::prepare(gpu::Batch& batch,
|
||||||
// Build the fragment shader
|
// Build the fragment shader
|
||||||
std::string opaqueShaderSource = replaceProceduralBlock(_opaquefragmentSource.getCode());
|
std::string opaqueShaderSource = replaceProceduralBlock(_opaquefragmentSource.getCode());
|
||||||
auto opaqueReflection = _opaquefragmentSource.getReflection();
|
auto opaqueReflection = _opaquefragmentSource.getReflection();
|
||||||
auto& opaqueUniforms = opaqueReflection[gpu::Shader::BindingType::PUSH_CONSTANT];
|
auto& opaqueUniforms = opaqueReflection[gpu::Shader::BindingType::UNIFORM];
|
||||||
std::string transparentShaderSource = replaceProceduralBlock(_transparentfragmentSource.getCode());
|
std::string transparentShaderSource = replaceProceduralBlock(_transparentfragmentSource.getCode());
|
||||||
auto transparentReflection = _transparentfragmentSource.getReflection();
|
auto transparentReflection = _transparentfragmentSource.getReflection();
|
||||||
auto& transparentUniforms = transparentReflection[gpu::Shader::BindingType::PUSH_CONSTANT];
|
auto& transparentUniforms = transparentReflection[gpu::Shader::BindingType::UNIFORM];
|
||||||
|
|
||||||
// Set any userdata specified uniforms
|
// Set any userdata specified uniforms
|
||||||
int customSlot = procedural::slot::uniform::Custom;
|
int customSlot = procedural::slot::uniform::Custom;
|
||||||
|
|
|
@ -129,7 +129,7 @@ void ShaderTests::testShaderLoad() {
|
||||||
const auto& uniformRemap = shaderObject.uniformRemap;
|
const auto& uniformRemap = shaderObject.uniformRemap;
|
||||||
#endif
|
#endif
|
||||||
auto uniforms = gl::Uniform::load(program);
|
auto uniforms = gl::Uniform::load(program);
|
||||||
auto expectedUniforms = expectedBindings[gpu::Shader::BindingType::PUSH_CONSTANT];
|
auto expectedUniforms = expectedBindings[gpu::Shader::BindingType::UNIFORM];
|
||||||
if (uniforms.size() != expectedUniforms.size()) {
|
if (uniforms.size() != expectedUniforms.size()) {
|
||||||
qDebug() << "Found" << toStringList(uniforms, [](const auto& v) { return v.name.c_str(); });
|
qDebug() << "Found" << toStringList(uniforms, [](const auto& v) { return v.name.c_str(); });
|
||||||
qDebug() << "Expected" << toStringList(expectedUniforms, [](const auto& v) { return v.first.c_str(); });
|
qDebug() << "Expected" << toStringList(expectedUniforms, [](const auto& v) { return v.first.c_str(); });
|
||||||
|
|
Loading…
Reference in a new issue