[Scummvm-git-logs] scummvm master -> e532e33127622e3ff0944ed7959eae241d517c59
lephilousophe
noreply at scummvm.org
Sun Oct 16 12:41:25 UTC 2022
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3a31992403 BACKENDS: OPENGL: Really fix Pass# and PassPrev# uniforms
353239a158 BACKENDS: OPENGL: Reuse existing samplers if possible
e532e33127 BACKENDS: OPENGL: Add aliases support to libretro
Commit: 3a31992403eba55b3e54bb40bee1b6935c86c007
https://github.com/scummvm/scummvm/commit/3a31992403eba55b3e54bb40bee1b6935c86c007
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-10-16T14:04:39+02:00
Commit Message:
BACKENDS: OPENGL: Really fix Pass# and PassPrev# uniforms
Changed paths:
backends/graphics/opengl/pipelines/libretro.cpp
diff --git a/backends/graphics/opengl/pipelines/libretro.cpp b/backends/graphics/opengl/pipelines/libretro.cpp
index a95905bc6a5..08ca06e71f1 100644
--- a/backends/graphics/opengl/pipelines/libretro.cpp
+++ b/backends/graphics/opengl/pipelines/libretro.cpp
@@ -480,9 +480,10 @@ void LibRetroPipeline::setupPassUniforms(const uint id) {
if (id >= 1) {
setShaderTexUniforms(Common::String::format("PassPrev%u", id + 1), shader, *_passes[0].inputTexture);
for (uint passId = 0; passId < id; ++passId) {
- setShaderTexUniforms(Common::String::format("Pass%u", passId + 1), shader, *_passes[passId].inputTexture);
- // PassPrev is (id + 1) - (passId + 1)
- setShaderTexUniforms(Common::String::format("PassPrev%u", id - passId), shader, *_passes[passId].inputTexture);
+ // Pass1 is the output texture of first pass, ie. the input texture of second pass (indexed 1)
+ setShaderTexUniforms(Common::String::format("Pass%u", passId + 1), shader, *_passes[passId + 1].inputTexture);
+ // PassPrev1 is the output texture of last pass, ie. the input texture of current pass
+ setShaderTexUniforms(Common::String::format("PassPrev%u", id - passId), shader, *_passes[passId + 1].inputTexture);
}
}
@@ -540,8 +541,14 @@ void LibRetroPipeline::Pass::buildTexCoords(const uint id) {
addTexCoord("OrigTexCoord", TexCoordAttribute::kTypePass, 0);
addTexCoord("LUTTexCoord", TexCoordAttribute::kTypeTexture, 0);
- for (uint pass = 0; pass < id; ++pass) {
- addTexCoord(Common::String::format("Pass%uTexCoord", pass + 1), TexCoordAttribute::kTypePass, pass);
+ if (id >= 1) {
+ addTexCoord(Common::String::format("PassPrev%uTexCoord", id + 1), TexCoordAttribute::kTypePass, 0);
+ for (uint pass = 0; pass < id; ++pass) {
+ // Pass1TexCoord is the output texture coords of first pass, ie. the input texture coords of second pass (indexed 1)
+ addTexCoord(Common::String::format("Pass%uTexCoord", pass + 1), TexCoordAttribute::kTypePass, pass + 1);
+ // PassPrev1TexCoord is the output texture coords of last pass, ie. the input texture coords of current pass
+ addTexCoord(Common::String::format("PassPrev%uTexCoord", id - pass), TexCoordAttribute::kTypePass, pass + 1);
+ }
}
addTexCoord("PrevTexCoord", TexCoordAttribute::kTypePrev, 0);
@@ -567,11 +574,12 @@ void LibRetroPipeline::Pass::buildTexSamplers(const uint id, const TextureArray
// 2. Step: Assign pass inputs to samplers.
if (id >= 1) {
- addTexSampler(Common::String::format("PassPrev%u", id), &sampler, TextureSampler::kTypePass, 0);
+ addTexSampler(Common::String::format("PassPrev%u", id + 1), &sampler, TextureSampler::kTypePass, 0);
for (uint pass = 0; pass < id; ++pass) {
- addTexSampler(Common::String::format("Pass%u", pass + 1), &sampler, TextureSampler::kTypePass, pass);
- // PassPrev is (id + 1) - (pass + 1)
- addTexSampler(Common::String::format("PassPrev%u", id - pass), &sampler, TextureSampler::kTypePass, pass);
+ // Pass1 is the output texture of first pass, ie. the input texture of second pass (indexed 1)
+ addTexSampler(Common::String::format("Pass%u", pass + 1), &sampler, TextureSampler::kTypePass, pass + 1);
+ // PassPrev1 is the output texture of last pass, ie. the input texture of current pass
+ addTexSampler(Common::String::format("PassPrev%u", id - pass), &sampler, TextureSampler::kTypePass, pass + 1);
}
}
Commit: 353239a1585deae127bcf979a975d3da100cff51
https://github.com/scummvm/scummvm/commit/353239a1585deae127bcf979a975d3da100cff51
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-10-16T14:04:57+02:00
Commit Message:
BACKENDS: OPENGL: Reuse existing samplers if possible
This avoids allocating samplers when one with the same texture already
exists.
Changed paths:
backends/graphics/opengl/pipelines/libretro.cpp
diff --git a/backends/graphics/opengl/pipelines/libretro.cpp b/backends/graphics/opengl/pipelines/libretro.cpp
index 08ca06e71f1..7c6cb0bd001 100644
--- a/backends/graphics/opengl/pipelines/libretro.cpp
+++ b/backends/graphics/opengl/pipelines/libretro.cpp
@@ -596,6 +596,14 @@ void LibRetroPipeline::Pass::buildTexSamplers(const uint id, const TextureArray
void LibRetroPipeline::Pass::addTexSampler(const Common::String &prefix, uint *unit, const TextureSampler::Type type, const uint index, const bool prefixIsId) {
const Common::String id = prefixIsId ? prefix : (prefix + "Texture");
+ /* Search in the samplers if we already have one for the texture */
+ for(TextureSamplerArray::iterator it = texSamplers.begin(); it != texSamplers.end(); it++) {
+ if (it->type == type && it->index == index) {
+ shader->setUniform(id, it->unit);
+ return;
+ }
+ }
+
if (shader->setUniform(id, *unit)) {
texSamplers.push_back(TextureSampler((*unit)++, type, index));
}
Commit: e532e33127622e3ff0944ed7959eae241d517c59
https://github.com/scummvm/scummvm/commit/e532e33127622e3ff0944ed7959eae241d517c59
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-10-16T14:06:44+02:00
Commit Message:
BACKENDS: OPENGL: Add aliases support to libretro
Changed paths:
backends/graphics/opengl/pipelines/libretro.cpp
backends/graphics/opengl/pipelines/libretro.h
backends/graphics/opengl/pipelines/libretro/parser.cpp
backends/graphics/opengl/pipelines/libretro/types.h
diff --git a/backends/graphics/opengl/pipelines/libretro.cpp b/backends/graphics/opengl/pipelines/libretro.cpp
index 7c6cb0bd001..7ef5cc8aa9b 100644
--- a/backends/graphics/opengl/pipelines/libretro.cpp
+++ b/backends/graphics/opengl/pipelines/libretro.cpp
@@ -278,6 +278,20 @@ static void stripShaderParameters(char *source, UniformsMap &uniforms) {
}
bool LibRetroPipeline::loadPasses() {
+ // First of all, build the aliases list
+ Common::String aliasesDefines;
+ Common::StringArray aliases;
+
+ aliases.reserve(_shaderPreset->passes.size());
+ for (LibRetro::ShaderPreset::PassArray::const_iterator
+ i = _shaderPreset->passes.begin(), end = _shaderPreset->passes.end();
+ i != end; ++i) {
+ aliases.push_back(i->alias);
+ if (!i->alias.empty()) {
+ aliasesDefines += Common::String::format("#define %s_ALIAS\n", i->alias.c_str());
+ }
+ }
+
for (LibRetro::ShaderPreset::PassArray::const_iterator
i = _shaderPreset->passes.begin(), end = _shaderPreset->passes.end();
i != end; ++i) {
@@ -335,8 +349,6 @@ bool LibRetroPipeline::loadPasses() {
shimsDetected += "#define HAS_ROUND\n";
}
- // TODO: Handle alias defines
-
Shader *shader = new Shader;
const char *const vertexSources[] = {
@@ -344,7 +356,7 @@ bool LibRetroPipeline::loadPasses() {
"#define VERTEX\n#define PARAMETER_UNIFORM\n",
shimsDetected.c_str(),
g_compatVertex,
- // TODO: alias defines
+ aliasesDefines.c_str(),
shaderFileStart,
};
const char *const fragmentSources[] = {
@@ -352,11 +364,10 @@ bool LibRetroPipeline::loadPasses() {
"#define FRAGMENT\n#define PARAMETER_UNIFORM\n",
shimsDetected.c_str(),
g_compatFragment,
- // TODO: alias defines
+ aliasesDefines.c_str(),
shaderFileStart,
};
-
if (!shader->loadFromStringsArray(fileNode.getName(),
ARRAYSIZE(vertexSources), vertexSources,
ARRAYSIZE(fragmentSources), fragmentSources,
@@ -382,8 +393,8 @@ bool LibRetroPipeline::loadPasses() {
Pass &pass = _passes[_passes.size() - 1];
const uint passId = _passes.size() - 1;
- pass.buildTexCoords(passId);
- pass.buildTexSamplers(passId, _textures);
+ pass.buildTexCoords(passId, aliases);
+ pass.buildTexSamplers(passId, _textures, aliases);
if (passId > 0) {
GLTexture *const texture = _passes[passId - 1].target->getTexture();
texture->enableLinearFiltering(i->filteringMode == LibRetro::kFilteringModeLinear);
@@ -484,6 +495,11 @@ void LibRetroPipeline::setupPassUniforms(const uint id) {
setShaderTexUniforms(Common::String::format("Pass%u", passId + 1), shader, *_passes[passId + 1].inputTexture);
// PassPrev1 is the output texture of last pass, ie. the input texture of current pass
setShaderTexUniforms(Common::String::format("PassPrev%u", id - passId), shader, *_passes[passId + 1].inputTexture);
+
+ // If pass has an alias, define the uniforms using the input texture of the next pass
+ if (!_passes[passId].shaderPass->alias.empty()) {
+ setShaderTexUniforms(_passes[passId].shaderPass->alias, shader, *_passes[passId + 1].inputTexture);
+ }
}
}
@@ -534,7 +550,7 @@ LibRetroPipeline::Texture LibRetroPipeline::loadTexture(const Common::FSNode &fi
return Texture();
}
-void LibRetroPipeline::Pass::buildTexCoords(const uint id) {
+void LibRetroPipeline::Pass::buildTexCoords(const uint id, const Common::StringArray &aliases) {
texCoords.clear();
addTexCoord("TexCoord", TexCoordAttribute::kTypePass, id);
@@ -548,6 +564,11 @@ void LibRetroPipeline::Pass::buildTexCoords(const uint id) {
addTexCoord(Common::String::format("Pass%uTexCoord", pass + 1), TexCoordAttribute::kTypePass, pass + 1);
// PassPrev1TexCoord is the output texture coords of last pass, ie. the input texture coords of current pass
addTexCoord(Common::String::format("PassPrev%uTexCoord", id - pass), TexCoordAttribute::kTypePass, pass + 1);
+
+ // If pass has an alias, define the uniforms using the input texture coords of the next pass
+ if (!aliases[pass].empty()) {
+ addTexCoord(Common::String::format("%sTexCoord", aliases[pass].c_str()), TexCoordAttribute::kTypePass, pass + 1);
+ }
}
}
@@ -563,7 +584,7 @@ void LibRetroPipeline::Pass::addTexCoord(const Common::String &name, const TexCo
}
}
-void LibRetroPipeline::Pass::buildTexSamplers(const uint id, const TextureArray &textures) {
+void LibRetroPipeline::Pass::buildTexSamplers(const uint id, const TextureArray &textures, const Common::StringArray &aliases) {
texSamplers.clear();
uint sampler = 1;
@@ -580,6 +601,11 @@ void LibRetroPipeline::Pass::buildTexSamplers(const uint id, const TextureArray
addTexSampler(Common::String::format("Pass%u", pass + 1), &sampler, TextureSampler::kTypePass, pass + 1);
// PassPrev1 is the output texture of last pass, ie. the input texture of current pass
addTexSampler(Common::String::format("PassPrev%u", id - pass), &sampler, TextureSampler::kTypePass, pass + 1);
+
+ // If pass has an alias, define the uniforms using the input texture of the next pass
+ if (!aliases[pass].empty()) {
+ addTexSampler(aliases[pass], &sampler, TextureSampler::kTypePass, pass + 1);
+ }
}
}
diff --git a/backends/graphics/opengl/pipelines/libretro.h b/backends/graphics/opengl/pipelines/libretro.h
index d7005fe5b5f..5f270a554f2 100644
--- a/backends/graphics/opengl/pipelines/libretro.h
+++ b/backends/graphics/opengl/pipelines/libretro.h
@@ -164,7 +164,7 @@ private:
*
* @param id Identifier of the current pass.
*/
- void buildTexCoords(const uint id);
+ void buildTexCoords(const uint id, const Common::StringArray &aliases);
void addTexCoord(const Common::String &prefix, const TexCoordAttribute::Type type, const uint index);
@@ -217,7 +217,7 @@ private:
* @param id Identifier of the current pass.
* @param textures Array of shader textures available.
*/
- void buildTexSamplers(const uint id, const TextureArray &textures);
+ void buildTexSamplers(const uint id, const TextureArray &textures, const Common::StringArray &aliases);
void addTexSampler(const Common::String &name, uint *unit, const TextureSampler::Type type, const uint index, const bool prefixIsId = false);
diff --git a/backends/graphics/opengl/pipelines/libretro/parser.cpp b/backends/graphics/opengl/pipelines/libretro/parser.cpp
index efa7c6485dd..d6801ef59b2 100644
--- a/backends/graphics/opengl/pipelines/libretro/parser.cpp
+++ b/backends/graphics/opengl/pipelines/libretro/parser.cpp
@@ -342,6 +342,11 @@ bool PresetParser::parsePass(const uint id, const bool isLast) {
return false;
}
+ if (!lookUpValue(passKey("alias"), &pass.alias)) {
+ _errorDesc.clear();
+ pass.alias.clear();
+ }
+
if (!lookUpValue(passKey("filter_linear"), &pass.filteringMode, kFilteringModeUnspecified)) {
return false;
}
diff --git a/backends/graphics/opengl/pipelines/libretro/types.h b/backends/graphics/opengl/pipelines/libretro/types.h
index 575526ec878..489b53adeb4 100644
--- a/backends/graphics/opengl/pipelines/libretro/types.h
+++ b/backends/graphics/opengl/pipelines/libretro/types.h
@@ -80,6 +80,7 @@ inline void applyScale(const ScaleType type,
struct ShaderPass {
Common::String fileName;
+ Common::String alias;
FilteringMode filteringMode;
bool mipmapInput;
More information about the Scummvm-git-logs
mailing list