Implement quick shader switch hotkeys
This commit is contained in:
@@ -34,10 +34,10 @@ FragmentOutput fragmentMain(in FragmentParameter params)
|
|||||||
}
|
}
|
||||||
for(uint i = 0; i < pLightEnv.numPointLights; ++i)
|
for(uint i = 0; i < pLightEnv.numPointLights; ++i)
|
||||||
{
|
{
|
||||||
//uint lightIndex = pLightCullingData.lightIndexList[startOffset + i];
|
uint lightIndex = pLightCullingData.lightIndexList[startOffset + i];
|
||||||
result += pLightEnv.pointLights[i].illuminate(lightingParams, brdf);
|
result += pLightEnv.pointLights[lightIndex].illuminate(lightingParams, brdf);
|
||||||
}
|
}
|
||||||
//result += brdf.evaluateAmbient();
|
result += brdf.evaluateAmbient();
|
||||||
// gamma correction
|
// gamma correction
|
||||||
result = result / (result + float3(1.0));
|
result = result / (result + float3(1.0));
|
||||||
result = pow(result, float3(1.0/2.2));
|
result = pow(result, float3(1.0/2.2));
|
||||||
@@ -46,3 +46,4 @@ FragmentOutput fragmentMain(in FragmentParameter params)
|
|||||||
output.meshletId = params.meshletId;
|
output.meshletId = params.meshletId;
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,10 +98,10 @@ void cullLights(ComputeShaderInput in)
|
|||||||
{
|
{
|
||||||
PointLight light = pLightEnv.pointLights[i];
|
PointLight light = pLightEnv.pointLights[i];
|
||||||
float3 light_VS = mul(viewMatrix, float4(light.position_WS.xyz, 1.0f)).xyz;
|
float3 light_VS = mul(viewMatrix, float4(light.position_WS.xyz, 1.0f)).xyz;
|
||||||
if(light.insideFrustum(groupFrustum, light_VS, nearClipVS, maxDepthVS))
|
//if(light.insideFrustum(groupFrustum, light_VS, nearClipVS, maxDepthVS))
|
||||||
{
|
{
|
||||||
tAppendLight(i);
|
tAppendLight(i);
|
||||||
if(!light.insidePlane(minPlane, light_VS))
|
//if(!light.insidePlane(minPlane, light_VS))
|
||||||
{
|
{
|
||||||
oAppendLight(i);
|
oAppendLight(i);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ void meshMain(
|
|||||||
out indices uint3 indices[MAX_PRIMITIVES]
|
out indices uint3 indices[MAX_PRIMITIVES]
|
||||||
){
|
){
|
||||||
InstanceData inst = pScene.instances[meshPayload.instanceId];
|
InstanceData inst = pScene.instances[meshPayload.instanceId];
|
||||||
//MeshData data = pScene.meshData[meshPayload.instanceId];
|
|
||||||
MeshletDescription m = pScene.meshletInfos[meshPayload.culledMeshlets[groupID]];
|
MeshletDescription m = pScene.meshletInfos[meshPayload.culledMeshlets[groupID]];
|
||||||
SetMeshOutputCounts(m.vertexCount, m.primitiveCount);
|
SetMeshOutputCounts(m.vertexCount, m.primitiveCount);
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ void taskMain(
|
|||||||
{
|
{
|
||||||
uint m = mesh.meshletOffset + i;
|
uint m = mesh.meshletOffset + i;
|
||||||
MeshletDescription meshlet = pScene.meshletInfos[m];
|
MeshletDescription meshlet = pScene.meshletInfos[m];
|
||||||
|
#ifdef VIEW_CULLING
|
||||||
if(meshlet.bounding.insideFrustum(viewFrustum))
|
if(meshlet.bounding.insideFrustum(viewFrustum))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
uint index;
|
uint index;
|
||||||
InterlockedAdd(head, 1, index);
|
InterlockedAdd(head, 1, index);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ void MeshLoader::importAsset(MeshImportArgs args)
|
|||||||
PMeshAsset ref = asset;
|
PMeshAsset ref = asset;
|
||||||
asset->setStatus(Asset::Status::Loading);
|
asset->setStatus(Asset::Status::Loading);
|
||||||
AssetRegistry::get().registerMesh(std::move(asset));
|
AssetRegistry::get().registerMesh(std::move(asset));
|
||||||
import(args, ref);
|
import(args, ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -59,8 +59,9 @@ void MeshLoader::loadTextures(const aiScene* scene, const std::filesystem::path&
|
|||||||
aiTexture* tex = scene->mTextures[i];
|
aiTexture* tex = scene->mTextures[i];
|
||||||
auto texPath = std::filesystem::path(tex->mFilename.C_Str());
|
auto texPath = std::filesystem::path(tex->mFilename.C_Str());
|
||||||
if (std::filesystem::exists(texPath))
|
if (std::filesystem::exists(texPath))
|
||||||
{ }
|
{
|
||||||
else if(std::filesystem::exists(meshDirectory / texPath))
|
}
|
||||||
|
else if (std::filesystem::exists(meshDirectory / texPath))
|
||||||
{
|
{
|
||||||
texPath = meshDirectory / texPath;
|
texPath = meshDirectory / texPath;
|
||||||
}
|
}
|
||||||
@@ -112,7 +113,7 @@ constexpr const char* KEY_AMBIENT_OCCLUSION_TEXTURE = "tex_ao";
|
|||||||
|
|
||||||
void MeshLoader::loadMaterials(const aiScene* scene, const Array<PTextureAsset>& textures, const std::string& baseName, const std::filesystem::path& meshDirectory, const std::string& importPath, Array<PMaterialInstanceAsset>& globalMaterials)
|
void MeshLoader::loadMaterials(const aiScene* scene, const Array<PTextureAsset>& textures, const std::string& baseName, const std::filesystem::path& meshDirectory, const std::string& importPath, Array<PMaterialInstanceAsset>& globalMaterials)
|
||||||
{
|
{
|
||||||
for(uint32 m = 0; m < scene->mNumMaterials; ++m)
|
for (uint32 m = 0; m < scene->mNumMaterials; ++m)
|
||||||
{
|
{
|
||||||
aiMaterial* material = scene->mMaterials[m];
|
aiMaterial* material = scene->mMaterials[m];
|
||||||
aiString texPath;
|
aiString texPath;
|
||||||
@@ -191,6 +192,15 @@ void MeshLoader::loadMaterials(const aiScene* scene, const Array<PTextureAsset>&
|
|||||||
});
|
});
|
||||||
texture = AssetRegistry::findTexture(importPath, texFilename.stem().string());
|
texture = AssetRegistry::findTexture(importPath, texFilename.stem().string());
|
||||||
}
|
}
|
||||||
|
else if (std::filesystem::exists(meshDirectory.parent_path() / "textures" / texFilename))
|
||||||
|
{
|
||||||
|
AssetImporter::importTexture(TextureImportArgs{
|
||||||
|
.filePath = meshDirectory.parent_path() / "textures" / texFilename,
|
||||||
|
.importPath = importPath,
|
||||||
|
.type = type == aiTextureType_NORMALS ? TextureImportType::TEXTURE_NORMAL : TextureImportType::TEXTURE_2D,
|
||||||
|
});
|
||||||
|
texture = AssetRegistry::findTexture(importPath, texFilename.stem().string());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "couldnt find " << texPath.C_Str() << std::endl;
|
std::cout << "couldnt find " << texPath.C_Str() << std::endl;
|
||||||
@@ -447,7 +457,7 @@ void MeshLoader::loadMaterials(const aiScene* scene, const Array<PTextureAsset>&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void findMeshRoots(aiNode *node, List<aiNode *> &meshNodes)
|
void findMeshRoots(aiNode* node, List<aiNode*>& meshNodes)
|
||||||
{
|
{
|
||||||
if (node->mNumMeshes > 0)
|
if (node->mNumMeshes > 0)
|
||||||
{
|
{
|
||||||
@@ -508,7 +518,7 @@ void MeshLoader::loadGlobalMeshes(const aiScene* scene, const Array<PMaterialIns
|
|||||||
tangents[i] = Vector(0, 0, 1);
|
tangents[i] = Vector(0, 0, 1);
|
||||||
biTangents[i] = Vector(1, 0, 0);
|
biTangents[i] = Vector(1, 0, 0);
|
||||||
}
|
}
|
||||||
if(mesh->HasVertexColors(0))
|
if (mesh->HasVertexColors(0))
|
||||||
{
|
{
|
||||||
colors[i] = Vector(mesh->mColors[0][i].r, mesh->mColors[0][i].g, mesh->mColors[0][i].b);
|
colors[i] = Vector(mesh->mColors[0][i].r, mesh->mColors[0][i].g, mesh->mColors[0][i].b);
|
||||||
}
|
}
|
||||||
@@ -577,7 +587,7 @@ aiMatrix4x4 loadNodeTransform(aiNode* node)
|
|||||||
|
|
||||||
void MeshLoader::import(MeshImportArgs args, PMeshAsset meshAsset)
|
void MeshLoader::import(MeshImportArgs args, PMeshAsset meshAsset)
|
||||||
{
|
{
|
||||||
std::cout << "Starting to import "<<args.filePath<< std::endl;
|
std::cout << "Starting to import " << args.filePath << std::endl;
|
||||||
meshAsset->setStatus(Asset::Status::Loading);
|
meshAsset->setStatus(Asset::Status::Loading);
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
importer.ReadFile(args.filePath.string().c_str(), (uint32)(
|
importer.ReadFile(args.filePath.string().c_str(), (uint32)(
|
||||||
@@ -590,7 +600,7 @@ void MeshLoader::import(MeshImportArgs args, PMeshAsset meshAsset)
|
|||||||
aiProcess_ImproveCacheLocality |
|
aiProcess_ImproveCacheLocality |
|
||||||
aiProcess_GenUVCoords |
|
aiProcess_GenUVCoords |
|
||||||
aiProcess_FindDegenerates));
|
aiProcess_FindDegenerates));
|
||||||
const aiScene *scene = importer.ApplyPostProcessing(aiProcess_CalcTangentSpace);
|
const aiScene* scene = importer.ApplyPostProcessing(aiProcess_CalcTangentSpace);
|
||||||
std::cout << importer.GetErrorString() << std::endl;
|
std::cout << importer.GetErrorString() << std::endl;
|
||||||
|
|
||||||
Array<PTextureAsset> textures;
|
Array<PTextureAsset> textures;
|
||||||
@@ -602,13 +612,13 @@ void MeshLoader::import(MeshImportArgs args, PMeshAsset meshAsset)
|
|||||||
Component::Collider collider;
|
Component::Collider collider;
|
||||||
loadGlobalMeshes(scene, globalMaterials, globalMeshes, collider);
|
loadGlobalMeshes(scene, globalMaterials, globalMeshes, collider);
|
||||||
|
|
||||||
List<aiNode *> meshNodes;
|
List<aiNode*> meshNodes;
|
||||||
findMeshRoots(scene->mRootNode, meshNodes);
|
findMeshRoots(scene->mRootNode, meshNodes);
|
||||||
|
|
||||||
Array<OMesh> meshes;
|
Array<OMesh> meshes;
|
||||||
for (auto meshNode : meshNodes)
|
for (auto meshNode : meshNodes)
|
||||||
{
|
{
|
||||||
for(uint32 i = 0; i < meshNode->mNumMeshes; ++i)
|
for (uint32 i = 0; i < meshNode->mNumMeshes; ++i)
|
||||||
{
|
{
|
||||||
if (globalMeshes[meshNode->mMeshes[i]] == nullptr)
|
if (globalMeshes[meshNode->mMeshes[i]] == nullptr)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ int main() {
|
|||||||
.filePath = sourcePath / "import/models/cube.fbx",
|
.filePath = sourcePath / "import/models/cube.fbx",
|
||||||
});
|
});
|
||||||
AssetImporter::importMesh(MeshImportArgs{
|
AssetImporter::importMesh(MeshImportArgs{
|
||||||
.filePath = sourcePath / "import/models/after-the-rain-vr-sound/source/Whitechapel.gltf",
|
.filePath = sourcePath / "import/models/after-the-rain-vr-sound/source/Whitechapel.fbx",
|
||||||
.importPath = "Whitechapel"
|
.importPath = "Whitechapel"
|
||||||
});
|
});
|
||||||
//AssetImporter::importMesh(MeshImportArgs{
|
//AssetImporter::importMesh(MeshImportArgs{
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
|
extern bool useViewCulling;
|
||||||
|
|
||||||
BasePass::BasePass(Gfx::PGraphics graphics, PScene scene)
|
BasePass::BasePass(Gfx::PGraphics graphics, PScene scene)
|
||||||
: RenderPass(graphics, scene)
|
: RenderPass(graphics, scene)
|
||||||
{
|
{
|
||||||
@@ -40,11 +42,11 @@ BasePass::BasePass(Gfx::PGraphics graphics, PScene scene)
|
|||||||
|
|
||||||
if (graphics->supportMeshShading())
|
if (graphics->supportMeshShading())
|
||||||
{
|
{
|
||||||
graphics->getShaderCompiler()->registerRenderPass(basePassLayout, "BasePass", "MeshletPass", false, true, true, "BasePass", true, true, "ViewCullingTask");
|
graphics->getShaderCompiler()->registerRenderPass(basePassLayout, "BasePass", "MeshletPass", true, true, "BasePass", true, true, "ViewCullingTask");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
graphics->getShaderCompiler()->registerRenderPass(basePassLayout, "BasePass", "LegacyPass", false, true, true, "BasePass");
|
graphics->getShaderCompiler()->registerRenderPass(basePassLayout, "BasePass", "LegacyPass", true, true, "BasePass");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,6 +99,7 @@ void BasePass::render()
|
|||||||
permutation.setVertexFile("LegacyPass");
|
permutation.setVertexFile("LegacyPass");
|
||||||
}
|
}
|
||||||
permutation.setFragmentFile("BasePass");
|
permutation.setFragmentFile("BasePass");
|
||||||
|
permutation.setViewCulling(useViewCulling);
|
||||||
for (VertexData* vertexData : VertexData::getList())
|
for (VertexData* vertexData : VertexData::getList())
|
||||||
{
|
{
|
||||||
permutation.setVertexData(vertexData->getTypeName());
|
permutation.setVertexData(vertexData->getTypeName());
|
||||||
@@ -168,7 +171,6 @@ void BasePass::render()
|
|||||||
command->bindDescriptor(scene->getLightEnvironment()->getDescriptorSet());
|
command->bindDescriptor(scene->getLightEnvironment()->getDescriptorSet());
|
||||||
command->bindDescriptor(opaqueCulling);
|
command->bindDescriptor(opaqueCulling);
|
||||||
command->bindDescriptor(vertexData->getInstanceDataSet());
|
command->bindDescriptor(vertexData->getInstanceDataSet());
|
||||||
command->bindDescriptor(vertexData->getInstanceDataSet());
|
|
||||||
for (const auto& drawCall : materialData.instances)
|
for (const auto& drawCall : materialData.instances)
|
||||||
{
|
{
|
||||||
command->bindDescriptor(drawCall.materialInstance->getDescriptorSet());
|
command->bindDescriptor(drawCall.materialInstance->getDescriptorSet());
|
||||||
@@ -222,7 +224,7 @@ void BasePass::publishOutputs()
|
|||||||
void BasePass::createRenderPass()
|
void BasePass::createRenderPass()
|
||||||
{
|
{
|
||||||
depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
|
depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
|
||||||
depthAttachment.setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR);
|
depthAttachment.setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_LOAD);
|
||||||
depthAttachment.setInitialLayout(Gfx::SE_IMAGE_LAYOUT_GENERAL);
|
depthAttachment.setInitialLayout(Gfx::SE_IMAGE_LAYOUT_GENERAL);
|
||||||
depthAttachment.setFinalLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
depthAttachment.setFinalLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||||
Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
|
Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ target_sources(Engine
|
|||||||
RenderPass.cpp
|
RenderPass.cpp
|
||||||
SkyboxRenderPass.h
|
SkyboxRenderPass.h
|
||||||
SkyboxRenderPass.cpp
|
SkyboxRenderPass.cpp
|
||||||
StaticDepthPrepass.h
|
#StaticDepthPrepass.h
|
||||||
StaticDepthPrepass.cpp
|
#StaticDepthPrepass.cpp
|
||||||
StaticBasePass.h
|
#StaticBasePass.h
|
||||||
StaticBasePass.cpp
|
#StaticBasePass.cpp
|
||||||
TextPass.h
|
TextPass.h
|
||||||
TextPass.cpp
|
TextPass.cpp
|
||||||
UIPass.h
|
UIPass.h
|
||||||
@@ -35,7 +35,7 @@ target_sources(Engine
|
|||||||
RenderGraphResources.h
|
RenderGraphResources.h
|
||||||
RenderPass.h
|
RenderPass.h
|
||||||
SkyboxRenderPass.h
|
SkyboxRenderPass.h
|
||||||
StaticDepthPrepass.h
|
#StaticDepthPrepass.h
|
||||||
StaticBasePass.h
|
#StaticBasePass.h
|
||||||
TextPass.h
|
TextPass.h
|
||||||
UIPass.h)
|
UIPass.h)
|
||||||
@@ -13,6 +13,9 @@
|
|||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
|
extern bool usePositionOnly;
|
||||||
|
extern bool useViewCulling;
|
||||||
|
|
||||||
DepthPrepass::DepthPrepass(Gfx::PGraphics graphics, PScene scene)
|
DepthPrepass::DepthPrepass(Gfx::PGraphics graphics, PScene scene)
|
||||||
: RenderPass(graphics, scene)
|
: RenderPass(graphics, scene)
|
||||||
{
|
{
|
||||||
@@ -25,11 +28,11 @@ DepthPrepass::DepthPrepass(Gfx::PGraphics graphics, PScene scene)
|
|||||||
});
|
});
|
||||||
if (graphics->supportMeshShading())
|
if (graphics->supportMeshShading())
|
||||||
{
|
{
|
||||||
graphics->getShaderCompiler()->registerRenderPass(depthPrepassLayout, "DepthPass", "MeshletPass", true, false, false, "", true, true, "ViewCullingTask");
|
graphics->getShaderCompiler()->registerRenderPass(depthPrepassLayout, "DepthPass", "MeshletPass", false, false, "", true, true, "ViewCullingTask");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
graphics->getShaderCompiler()->registerRenderPass(depthPrepassLayout, "DepthPass", "LegacyPass", true);
|
graphics->getShaderCompiler()->registerRenderPass(depthPrepassLayout, "DepthPass", "LegacyPass");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +51,8 @@ void DepthPrepass::render()
|
|||||||
Array<Gfx::ORenderCommand> commands;
|
Array<Gfx::ORenderCommand> commands;
|
||||||
|
|
||||||
Gfx::ShaderPermutation permutation;
|
Gfx::ShaderPermutation permutation;
|
||||||
permutation.setPositionOnly();
|
permutation.setPositionOnly(usePositionOnly);
|
||||||
|
permutation.setViewCulling(useViewCulling);
|
||||||
if (graphics->supportMeshShading())
|
if (graphics->supportMeshShading())
|
||||||
{
|
{
|
||||||
permutation.setTaskFile("ViewCullingTask");
|
permutation.setTaskFile("ViewCullingTask");
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ StaticBasePass::StaticBasePass(Gfx::PGraphics graphics, PScene scene)
|
|||||||
basePassLayout->addDescriptorLayout(lightCullingLayout);
|
basePassLayout->addDescriptorLayout(lightCullingLayout);
|
||||||
if (graphics->supportMeshShading())
|
if (graphics->supportMeshShading())
|
||||||
{
|
{
|
||||||
graphics->getShaderCompiler()->registerRenderPass(basePassLayout, "BasePass", "StaticMeshletPass", false, true, true, "BasePass", true);
|
graphics->getShaderCompiler()->registerRenderPass(basePassLayout, "BasePass", "StaticMeshletPass", false, true, "BasePass", true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
graphics->getShaderCompiler()->registerRenderPass(basePassLayout, "StaticBasePass", "StaticLegacyPass", false, true, true, "BasePass");
|
graphics->getShaderCompiler()->registerRenderPass(basePassLayout, "StaticBasePass", "StaticLegacyPass", false, true, "BasePass");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ StaticDepthPrepass::StaticDepthPrepass(Gfx::PGraphics graphics, PScene scene)
|
|||||||
depthPrepassLayout->addDescriptorLayout(meshletCullingLayout);
|
depthPrepassLayout->addDescriptorLayout(meshletCullingLayout);
|
||||||
if (graphics->supportMeshShading())
|
if (graphics->supportMeshShading())
|
||||||
{
|
{
|
||||||
graphics->getShaderCompiler()->registerRenderPass(depthPrepassLayout, "DepthPass", "MeshletPass", true, false, false, "", true);
|
graphics->getShaderCompiler()->registerRenderPass(depthPrepassLayout, "DepthPass", "MeshletPass", false, false, "", true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
graphics->getShaderCompiler()->registerRenderPass(depthPrepassLayout, "DepthPass", "LegacyPass", true);
|
graphics->getShaderCompiler()->registerRenderPass(depthPrepassLayout, "DepthPass", "LegacyPass");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ void ShaderCompiler::registerVertexData(VertexData* vd)
|
|||||||
|
|
||||||
void ShaderCompiler::registerRenderPass(Gfx::PPipelineLayout layout,
|
void ShaderCompiler::registerRenderPass(Gfx::PPipelineLayout layout,
|
||||||
std::string name, std::string mainFile,
|
std::string name, std::string mainFile,
|
||||||
bool positionOnly,
|
|
||||||
bool useMaterials,
|
bool useMaterials,
|
||||||
bool hasFragmentShader,
|
bool hasFragmentShader,
|
||||||
std::string fragmentFile,
|
std::string fragmentFile,
|
||||||
@@ -53,7 +52,6 @@ void ShaderCompiler::registerRenderPass(Gfx::PPipelineLayout layout,
|
|||||||
.useMeshShading = useMeshShading,
|
.useMeshShading = useMeshShading,
|
||||||
.hasTaskShader = hasTaskShader,
|
.hasTaskShader = hasTaskShader,
|
||||||
.useMaterial = useMaterials,
|
.useMaterial = useMaterials,
|
||||||
.positionOnly = positionOnly,
|
|
||||||
};
|
};
|
||||||
compile();
|
compile();
|
||||||
}
|
}
|
||||||
@@ -70,12 +68,14 @@ void ShaderCompiler::compile()
|
|||||||
{
|
{
|
||||||
for (const auto& [matName, mat] : materials)
|
for (const auto& [matName, mat] : materials)
|
||||||
{
|
{
|
||||||
//work.add([=]() {
|
for (int x = 0; x < 2; x++)
|
||||||
ShaderPermutation permutation;
|
|
||||||
if (pass.positionOnly)
|
|
||||||
{
|
{
|
||||||
permutation.setPositionOnly();
|
for (int y = 0; y < 2; y++)
|
||||||
}
|
{
|
||||||
|
work.add([=]() {
|
||||||
|
ShaderPermutation permutation;
|
||||||
|
permutation.setPositionOnly(x);
|
||||||
|
permutation.setViewCulling(y);
|
||||||
if (pass.useMeshShading)
|
if (pass.useMeshShading)
|
||||||
{
|
{
|
||||||
permutation.setMeshFile(pass.mainFile);
|
permutation.setMeshFile(pass.mainFile);
|
||||||
@@ -99,17 +99,22 @@ void ShaderCompiler::compile()
|
|||||||
layout->addDescriptorLayout(mat->getDescriptorLayout());
|
layout->addDescriptorLayout(mat->getDescriptorLayout());
|
||||||
permutation.setMaterial(mat->getName());
|
permutation.setMaterial(mat->getName());
|
||||||
createShaders(permutation, std::move(layout));
|
createShaders(permutation, std::move(layout));
|
||||||
//});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//work.add([=]() {
|
for (int x = 0; x < 2; x++)
|
||||||
ShaderPermutation permutation;
|
|
||||||
if (pass.positionOnly)
|
|
||||||
{
|
{
|
||||||
permutation.setPositionOnly();
|
for (int y = 0; y < 2; y++)
|
||||||
}
|
{
|
||||||
|
work.add([=]() {
|
||||||
|
ShaderPermutation permutation;
|
||||||
|
permutation.setPositionOnly(x);
|
||||||
|
permutation.setViewCulling(y);
|
||||||
if (pass.useMeshShading)
|
if (pass.useMeshShading)
|
||||||
{
|
{
|
||||||
permutation.setMeshFile(pass.mainFile);
|
permutation.setMeshFile(pass.mainFile);
|
||||||
@@ -131,11 +136,13 @@ void ShaderCompiler::compile()
|
|||||||
layout->addDescriptorLayout(vd->getVertexDataLayout());
|
layout->addDescriptorLayout(vd->getVertexDataLayout());
|
||||||
layout->addDescriptorLayout(vd->getInstanceDataLayout());
|
layout->addDescriptorLayout(vd->getInstanceDataLayout());
|
||||||
createShaders(permutation, std::move(layout));
|
createShaders(permutation, std::move(layout));
|
||||||
//});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//getThreadPool().runAndWait(std::move(work));
|
}
|
||||||
|
}
|
||||||
|
getThreadPool().runAndWait(std::move(work));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderCompiler::createShaders(ShaderPermutation permutation, Gfx::OPipelineLayout layout)
|
void ShaderCompiler::createShaders(ShaderPermutation permutation, Gfx::OPipelineLayout layout)
|
||||||
@@ -161,6 +168,10 @@ void ShaderCompiler::createShaders(ShaderPermutation permutation, Gfx::OPipeline
|
|||||||
{
|
{
|
||||||
createInfo.defines["POS_ONLY"] = "1";
|
createInfo.defines["POS_ONLY"] = "1";
|
||||||
}
|
}
|
||||||
|
if (permutation.viewCulling)
|
||||||
|
{
|
||||||
|
createInfo.defines["VIEW_CULLING"] = "1";
|
||||||
|
}
|
||||||
createInfo.typeParameter.add({ Pair<const char*, const char*>("IVertexData", permutation.vertexDataName) });
|
createInfo.typeParameter.add({ Pair<const char*, const char*>("IVertexData", permutation.vertexDataName) });
|
||||||
createInfo.additionalModules.add(permutation.vertexDataName);
|
createInfo.additionalModules.add(permutation.vertexDataName);
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ struct ShaderPermutation
|
|||||||
uint8 hasTaskShader;
|
uint8 hasTaskShader;
|
||||||
uint8 useMaterial;
|
uint8 useMaterial;
|
||||||
uint8 positionOnly;
|
uint8 positionOnly;
|
||||||
|
uint8 viewCulling;
|
||||||
//TODO: lightmapping etc
|
//TODO: lightmapping etc
|
||||||
ShaderPermutation()
|
ShaderPermutation()
|
||||||
{
|
{
|
||||||
@@ -103,9 +104,13 @@ struct ShaderPermutation
|
|||||||
useMaterial = 1;
|
useMaterial = 1;
|
||||||
strncpy(materialName, name.data(), sizeof(materialName));
|
strncpy(materialName, name.data(), sizeof(materialName));
|
||||||
}
|
}
|
||||||
void setPositionOnly()
|
void setPositionOnly(bool enable)
|
||||||
{
|
{
|
||||||
positionOnly = true;
|
positionOnly = enable;
|
||||||
|
}
|
||||||
|
void setViewCulling(bool enable)
|
||||||
|
{
|
||||||
|
viewCulling = enable;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//Hashed ShaderPermutation for fast lookup
|
//Hashed ShaderPermutation for fast lookup
|
||||||
@@ -146,7 +151,6 @@ public:
|
|||||||
void registerRenderPass(Gfx::PPipelineLayout baseLayout,
|
void registerRenderPass(Gfx::PPipelineLayout baseLayout,
|
||||||
std::string name,
|
std::string name,
|
||||||
std::string mainFile,
|
std::string mainFile,
|
||||||
bool positionOnly = true,
|
|
||||||
bool useMaterials = false,
|
bool useMaterials = false,
|
||||||
bool hasFragmentShader = false,
|
bool hasFragmentShader = false,
|
||||||
std::string fragmentFile = "",
|
std::string fragmentFile = "",
|
||||||
@@ -170,7 +174,6 @@ private:
|
|||||||
bool useMeshShading;
|
bool useMeshShading;
|
||||||
bool hasTaskShader;
|
bool hasTaskShader;
|
||||||
bool useMaterial;
|
bool useMaterial;
|
||||||
bool positionOnly;
|
|
||||||
};
|
};
|
||||||
Map<std::string, PassConfig> passes;
|
Map<std::string, PassConfig> passes;
|
||||||
Gfx::PGraphics graphics;
|
Gfx::PGraphics graphics;
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ void PipelineLayout::create() {
|
|||||||
|
|
||||||
std::unique_lock l(layoutLock);
|
std::unique_lock l(layoutLock);
|
||||||
if (cachedLayouts.contains(layoutHash)) {
|
if (cachedLayouts.contains(layoutHash)) {
|
||||||
std::cout << "New Layout" << std::endl;
|
// std::cout << "New Layout" << std::endl;
|
||||||
layoutHandle = cachedLayouts[layoutHash];
|
layoutHandle = cachedLayouts[layoutHash];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ void Fence::reset()
|
|||||||
{
|
{
|
||||||
if (signaled)
|
if (signaled)
|
||||||
{
|
{
|
||||||
vkResetFences(graphics->getDevice(), 1, &fence);
|
VK_CHECK(vkResetFences(graphics->getDevice(), 1, &fence));
|
||||||
|
//std::cout << vkGetFenceStatus(graphics->getDevice(), fence) << std::endl;
|
||||||
signaled = false;
|
signaled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ void Window::pollInput()
|
|||||||
|
|
||||||
void Window::beginFrame()
|
void Window::beginFrame()
|
||||||
{
|
{
|
||||||
imageAvailableFences[currentSemaphoreIndex]->wait(100000);
|
imageAvailableFences[currentSemaphoreIndex]->wait(100000000);
|
||||||
imageAvailableFences[currentSemaphoreIndex]->reset();
|
imageAvailableFences[currentSemaphoreIndex]->reset();
|
||||||
vkAcquireNextImageKHR(graphics->getDevice(), swapchain, std::numeric_limits<uint64>::max(), imageAvailableSemaphores[currentSemaphoreIndex]->getHandle(), imageAvailableFences[currentSemaphoreIndex]->getHandle(), ¤tImageIndex);
|
vkAcquireNextImageKHR(graphics->getDevice(), swapchain, std::numeric_limits<uint64>::max(), imageAvailableSemaphores[currentSemaphoreIndex]->getHandle(), imageAvailableFences[currentSemaphoreIndex]->getHandle(), ¤tImageIndex);
|
||||||
graphics->getGraphicsCommands()->getCommands()->waitForSemaphore(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, imageAvailableSemaphores[currentSemaphoreIndex]);
|
graphics->getGraphicsCommands()->getCommands()->waitForSemaphore(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, imageAvailableSemaphores[currentSemaphoreIndex]);
|
||||||
@@ -284,14 +284,14 @@ void Window::chooseSwapSurfaceFormat()
|
|||||||
|
|
||||||
void Window::chooseSwapPresentMode()
|
void Window::chooseSwapPresentMode()
|
||||||
{
|
{
|
||||||
/*for (const auto& supportedPresentMode : supportedPresentModes)
|
for (const auto& supportedPresentMode : supportedPresentModes)
|
||||||
{
|
{
|
||||||
if (supportedPresentMode == VK_PRESENT_MODE_MAILBOX_KHR)
|
if (supportedPresentMode == VK_PRESENT_MODE_MAILBOX_KHR)
|
||||||
{
|
{
|
||||||
presentMode = supportedPresentMode;
|
presentMode = supportedPresentMode;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
presentMode = VK_PRESENT_MODE_FIFO_KHR;
|
presentMode = VK_PRESENT_MODE_FIFO_KHR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-12
@@ -23,18 +23,18 @@ ThreadPool::~ThreadPool()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//void ThreadPool::runAndWait(List<std::function<void()>> functions)
|
void ThreadPool::runAndWait(List<std::function<void()>> functions)
|
||||||
//{
|
{
|
||||||
// std::unique_lock l(taskLock);
|
std::unique_lock l(taskLock);
|
||||||
// currentTask.numRemaining = functions.size();
|
currentTask.numRemaining = functions.size();
|
||||||
// currentTask.functions = std::move(functions);
|
currentTask.functions = std::move(functions);
|
||||||
// taskCV.notify_all();
|
taskCV.notify_all();
|
||||||
//
|
|
||||||
// while (currentTask.numRemaining > 0)
|
while (currentTask.numRemaining > 0)
|
||||||
// {
|
{
|
||||||
// completedCV.wait(l);
|
completedCV.wait(l);
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
void ThreadPool::work()
|
void ThreadPool::work()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ namespace Seele
|
|||||||
class ThreadPool
|
class ThreadPool
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ThreadPool(uint32 numWorkers = std::thread::hardware_concurrency());
|
ThreadPool(uint32 numWorkers = std::thread::hardware_concurrency() - 2);
|
||||||
~ThreadPool();
|
~ThreadPool();
|
||||||
//void runAndWait(List<std::function<void()>> functions);
|
void runAndWait(List<std::function<void()>> functions);
|
||||||
private:
|
private:
|
||||||
struct Task
|
struct Task
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
|
bool usePositionOnly = false;
|
||||||
|
bool useViewCulling = false;
|
||||||
|
|
||||||
GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo, std::string dllPath)
|
GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo, std::string dllPath)
|
||||||
: View(graphics, window, createInfo, "Game")
|
: View(graphics, window, createInfo, "Game")
|
||||||
, scene(new Scene(graphics))
|
, scene(new Scene(graphics))
|
||||||
@@ -98,6 +101,22 @@ void GameView::reloadGame()
|
|||||||
void GameView::keyCallback(KeyCode code, InputAction action, KeyModifier modifier)
|
void GameView::keyCallback(KeyCode code, InputAction action, KeyModifier modifier)
|
||||||
{
|
{
|
||||||
keyboardSystem->keyCallback(code, action, modifier);
|
keyboardSystem->keyCallback(code, action, modifier);
|
||||||
|
if (code == KeyCode::KEY_P && action == InputAction::RELEASE)
|
||||||
|
{
|
||||||
|
usePositionOnly = true;
|
||||||
|
}
|
||||||
|
if (code == KeyCode::KEY_O && action == InputAction::RELEASE)
|
||||||
|
{
|
||||||
|
usePositionOnly = false;
|
||||||
|
}
|
||||||
|
if (code == KeyCode::KEY_L && action == InputAction::RELEASE)
|
||||||
|
{
|
||||||
|
useViewCulling = true;
|
||||||
|
}
|
||||||
|
if (code == KeyCode::KEY_K && action == InputAction::RELEASE)
|
||||||
|
{
|
||||||
|
useViewCulling = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::mouseMoveCallback(double xPos, double yPos)
|
void GameView::mouseMoveCallback(double xPos, double yPos)
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
#include "Graphics/RenderPass/BasePass.h"
|
#include "Graphics/RenderPass/BasePass.h"
|
||||||
#include "Graphics/RenderPass/SkyboxRenderPass.h"
|
#include "Graphics/RenderPass/SkyboxRenderPass.h"
|
||||||
#include "Graphics/RenderPass/DebugPass.h"
|
#include "Graphics/RenderPass/DebugPass.h"
|
||||||
#include "Graphics/RenderPass/StaticDepthPrepass.h"
|
|
||||||
#include "Graphics/RenderPass/StaticBasePass.h"
|
|
||||||
#include "System/KeyboardInput.h"
|
#include "System/KeyboardInput.h"
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include "Platform/Windows/GameInterface.h" // TODO
|
#include "Platform/Windows/GameInterface.h" // TODO
|
||||||
|
|||||||
Reference in New Issue
Block a user