Adding combined image samplers
This commit is contained in:
@@ -4,3 +4,6 @@
|
||||
[submodule "external/vcpkg"]
|
||||
path = external/vcpkg
|
||||
url = https://github.com/Microsoft/vcpkg.git
|
||||
[submodule "external/slang"]
|
||||
path = external/slang
|
||||
url = git@github.com:shader-slang/slang.git
|
||||
|
||||
+2
-3
@@ -28,7 +28,7 @@
|
||||
"name": "RelWithDebInfo",
|
||||
"generator": "Visual Studio 17 2022 Win64",
|
||||
"configurationType": "RelWithDebInfo",
|
||||
"buildRoot": "${CMAKE_CURRENT_SOURCE_DIR}/cmake",
|
||||
"buildRoot": "C:/Users/Dynamitos/Seele/build/",
|
||||
"installRoot": "C:/Program Files/Seele",
|
||||
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
|
||||
"buildCommandArgs": "",
|
||||
@@ -59,8 +59,7 @@
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "msvc_x64" ],
|
||||
"intelliSenseMode": "windows-msvc-x64",
|
||||
"variables": []
|
||||
"intelliSenseMode": "windows-msvc-x64"
|
||||
}
|
||||
]
|
||||
}
|
||||
+1
Submodule external/slang added at 52dcb5bd44
@@ -121,6 +121,23 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
|
||||
parameters.add(p->key);
|
||||
expressions.add(std::move(p));
|
||||
}
|
||||
else if (type.compare("Sampler2D") == 0)
|
||||
{
|
||||
OCombinedTextureParameter p = new CombinedTextureParameter(param.key(), 0, bindingCounter);
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{ .binding = bindingCounter++, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER, });
|
||||
p->sampler = graphics->createSampler({});
|
||||
if (defaultValue != param.value().end())
|
||||
{
|
||||
std::string defaultString = defaultValue.value().get<std::string>();
|
||||
p->data = AssetRegistry::findTexture(defaultString);
|
||||
}
|
||||
if (p->data == nullptr)
|
||||
{
|
||||
p->data = AssetRegistry::findTexture(""); // this will return placeholder texture
|
||||
}
|
||||
parameters.add(p->key);
|
||||
expressions.add(std::move(p));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error unsupported parameter type" << std::endl;
|
||||
@@ -206,7 +223,10 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
|
||||
OSampleExpression p = new SampleExpression();
|
||||
std::string name = fmt::format("{0}", key++);
|
||||
p->key = name;
|
||||
if (obj.contains("texture"))
|
||||
{
|
||||
p->inputs["texture"].source = referenceExpression(obj["texture"]);
|
||||
}
|
||||
p->inputs["sampler"].source = referenceExpression(obj["sampler"]);
|
||||
p->inputs["coords"].source = referenceExpression(obj["coords"]);
|
||||
expressions.add(std::move(p));
|
||||
|
||||
@@ -77,18 +77,13 @@ void MeshLoader::loadMaterials(const aiScene* scene, const std::string& baseName
|
||||
});
|
||||
matCode["params"]["diffuseTexture"] =
|
||||
{
|
||||
{"type", "Texture2D"},
|
||||
{"type", "Sampler2D"},
|
||||
{"default", fmt::format("{0}/{1}", importPath, texFilename.string())}
|
||||
};
|
||||
matCode["params"]["diffuseSampler"] =
|
||||
{
|
||||
{"type", "Sampler"}
|
||||
};
|
||||
matCode["code"].push_back(
|
||||
{
|
||||
{ "exp", "Sample" },
|
||||
{ "texture", "diffuseTexture" },
|
||||
{ "sampler", "diffuseSampler" },
|
||||
{ "sampler", "diffuseTexture" },
|
||||
{ "coords", "input.texCoords"}
|
||||
}
|
||||
);
|
||||
@@ -122,18 +117,13 @@ void MeshLoader::loadMaterials(const aiScene* scene, const std::string& baseName
|
||||
});
|
||||
matCode["params"]["normalTexture"] =
|
||||
{
|
||||
{"type", "Texture2D"},
|
||||
{"type", "Sampler2D"},
|
||||
{"default", fmt::format("{0}/{1}", importPath, texFilename.string())}
|
||||
};
|
||||
matCode["params"]["normalSampler"] =
|
||||
{
|
||||
{"type", "Sampler"}
|
||||
};
|
||||
matCode["code"].push_back(
|
||||
{
|
||||
{ "exp", "Sample" },
|
||||
{ "texture", "normalTexture" },
|
||||
{ "sampler", "normalSampler" },
|
||||
{ "sampler", "normalTexture" },
|
||||
{ "coords", "input.texCoords" }
|
||||
}
|
||||
);
|
||||
|
||||
@@ -81,10 +81,18 @@ struct Map : public Tree<K, Pair<K, V>, _KeyFun<K, Pair<K, V>>, Compare, Allocat
|
||||
{
|
||||
return Super::remove(key);
|
||||
}
|
||||
constexpr bool exists(const key_type& key) const
|
||||
{
|
||||
return Super::find(key) != Super::end();
|
||||
}
|
||||
constexpr bool exists(const key_type& key)
|
||||
{
|
||||
return Super::find(key) != Super::end();
|
||||
}
|
||||
constexpr bool contains(const key_type& key) const
|
||||
{
|
||||
return exists(key);
|
||||
}
|
||||
constexpr bool contains(const key_type& key)
|
||||
{
|
||||
return exists(key);
|
||||
|
||||
@@ -314,7 +314,7 @@ protected:
|
||||
constexpr iterator find(const key_type& key) const
|
||||
{
|
||||
Node* it = root;
|
||||
while (!equal(it->data, key))
|
||||
while (it != nullptr && !equal(it->data, key))
|
||||
{
|
||||
if (comp(key, keyFun(it->data)))
|
||||
{
|
||||
@@ -325,6 +325,10 @@ protected:
|
||||
it = it->rightChild;
|
||||
}
|
||||
}
|
||||
if (it == nullptr)
|
||||
{
|
||||
return end();
|
||||
}
|
||||
return iterator(it);
|
||||
}
|
||||
constexpr Pair<iterator, bool> insert(const NodeData& data)
|
||||
|
||||
@@ -21,7 +21,7 @@ Slang::ComPtr<slang::IBlob> Seele::generateShader(const ShaderCreateInfo& create
|
||||
option[0].value = slang::CompilerOptionValue();
|
||||
option[0].value.kind = slang::CompilerOptionValueKind::Int;
|
||||
option[0].value.intValue0 = 1;
|
||||
option[1].name = slang::CompilerOptionName::IgnoreCapabilities;
|
||||
option[1].name = slang::CompilerOptionName::EmitSpirvViaGLSL;
|
||||
option[1].value = slang::CompilerOptionValue();
|
||||
option[1].value.kind = slang::CompilerOptionValueKind::Int;
|
||||
option[1].value.intValue0 = 1;
|
||||
|
||||
@@ -246,7 +246,7 @@ void CombinedTextureParameter::updateDescriptorSet(Gfx::PDescriptorSet descripto
|
||||
|
||||
void CombinedTextureParameter::generateDeclaration(std::ofstream& stream) const
|
||||
{
|
||||
stream << "\tTexture2D " << key << ";\n";
|
||||
stream << "\tSampler2D " << key << ";\n";
|
||||
}
|
||||
|
||||
void CombinedTextureParameter::save(ArchiveBuffer& buffer) const
|
||||
@@ -408,7 +408,14 @@ std::string SampleExpression::evaluate(Map<std::string, std::string>& varState)
|
||||
{
|
||||
std::string varName = fmt::format("exp_{}", key);
|
||||
varState[key] = varName;
|
||||
if (inputs.contains("texture"))
|
||||
{
|
||||
return fmt::format("let {} = {}.Sample({}, {});\n", varName, varState[inputs.at("texture").source], varState[inputs.at("sampler").source], varState[inputs.at("coords").source]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return fmt::format("let {} = {}.Sample({});\n", varName, varState[inputs.at("sampler").source], varState[inputs.at("coords").source]);
|
||||
}
|
||||
}
|
||||
|
||||
void SampleExpression::save(ArchiveBuffer& buffer) const
|
||||
|
||||
Reference in New Issue
Block a user