Fixing some import problems
This commit is contained in:
@@ -37,6 +37,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_CURRENT_SOURCE_DIR}/bu
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_CURRENT_SOURCE_DIR}/build)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/build)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/build)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_CURRENT_SOURCE_DIR}/build)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_CURRENT_SOURCE_DIR}/build)
|
||||
|
||||
find_package(Vulkan REQUIRED)
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
"name": "RelWithDebInfo",
|
||||
"generator": "Visual Studio 17 2022 Win64",
|
||||
"configurationType": "RelWithDebInfo",
|
||||
"buildRoot": "C:/Users/Dynamitos/Seele/build/",
|
||||
"buildRoot": "${CMAKE_CURRENT_SOURCE_DIR}/cmake",
|
||||
"installRoot": "C:/Program Files/Seele",
|
||||
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
|
||||
"buildCommandArgs": "",
|
||||
|
||||
Vendored
+1
-1
Submodule external/vcpkg updated: 042c31edc6...4002e5f359
@@ -31,5 +31,5 @@ float4 fragmentMain(in FragmentParameter params) : SV_Target
|
||||
//uint lightIndex = pLightCullingData.lightIndexList[startOffset + i];
|
||||
result += pLightEnv.pointLights[i].illuminate(lightingParams, brdf);
|
||||
}
|
||||
return float4(1.0f, 0.1f, 0.5f, 1.0f);
|
||||
return float4(result, 1.0f);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ void taskMain(
|
||||
{
|
||||
uint m = mesh.meshletOffset + i;
|
||||
MeshletDescription meshlet = pScene.meshletInfos[m];
|
||||
if(meshlet.bounding.insideFrustum(localToView, viewFrustum))
|
||||
//if(meshlet.bounding.insideFrustum(localToView, viewFrustum))
|
||||
{
|
||||
uint index;
|
||||
InterlockedAdd(head, 1, index);
|
||||
|
||||
@@ -10,6 +10,7 @@ struct ViewParameter
|
||||
float4 cameraPos_WS;
|
||||
float2 screenDimensions;
|
||||
}
|
||||
layout(set=0)
|
||||
ParameterBlock<ViewParameter> pViewParams;
|
||||
|
||||
float4 clipToView(float4 clip)
|
||||
|
||||
@@ -63,4 +63,5 @@ struct LightEnv
|
||||
StructuredBuffer<PointLight> pointLights;
|
||||
uint numPointLights;
|
||||
};
|
||||
layout(set=3)
|
||||
ParameterBlock<LightEnv> pLightEnv;
|
||||
|
||||
@@ -7,5 +7,5 @@ interface IMaterial
|
||||
associatedtype BRDF : IBRDF;
|
||||
BRDF prepare(MaterialParameter input);
|
||||
};
|
||||
|
||||
layout(set=4)
|
||||
ParameterBlock<IMaterial> pMaterial;
|
||||
|
||||
@@ -22,8 +22,8 @@ struct MeshData
|
||||
uint32_t pad0[3];
|
||||
};
|
||||
|
||||
static const uint MAX_VERTICES = 64;
|
||||
static const uint MAX_PRIMITIVES = 126;
|
||||
static const uint MAX_VERTICES = 256;
|
||||
static const uint MAX_PRIMITIVES = 256;
|
||||
static const uint TASK_GROUP_SIZE = 128;
|
||||
static const uint MESH_GROUP_SIZE = 32;
|
||||
static const uint MAX_MESHLETS_PER_MESH = 512;
|
||||
@@ -41,6 +41,6 @@ struct Scene
|
||||
StructuredBuffer<uint8_t> primitiveIndices;
|
||||
StructuredBuffer<uint32_t> vertexIndices;
|
||||
};
|
||||
layout(set=1)
|
||||
layout(set=2)
|
||||
ParameterBlock<Scene> pScene;
|
||||
|
||||
|
||||
@@ -11,5 +11,5 @@ interface IVertexData
|
||||
VertexAttributes getAttributes(uint index);
|
||||
};
|
||||
|
||||
layout(set=2)
|
||||
layout(set=1)
|
||||
ParameterBlock<IVertexData> pVertexData;
|
||||
@@ -78,7 +78,7 @@ void MeshLoader::loadMaterials(const aiScene* scene, const std::string& baseName
|
||||
matCode["params"]["diffuseTexture"] =
|
||||
{
|
||||
{"type", "Texture2D"},
|
||||
{"default", texFilename.string()}
|
||||
{"default", fmt::format("{0}/{1}", importPath, texFilename.string())}
|
||||
};
|
||||
matCode["params"]["diffuseSampler"] =
|
||||
{
|
||||
@@ -123,7 +123,7 @@ void MeshLoader::loadMaterials(const aiScene* scene, const std::string& baseName
|
||||
matCode["params"]["normalTexture"] =
|
||||
{
|
||||
{"type", "Texture2D"},
|
||||
{"default", texFilename.string()}
|
||||
{"default", fmt::format("{0}/{1}", importPath, texFilename.string())}
|
||||
};
|
||||
matCode["params"]["normalSampler"] =
|
||||
{
|
||||
@@ -326,25 +326,28 @@ void MeshLoader::loadTextures(const aiScene* scene, const std::filesystem::path&
|
||||
aiTexture* tex = scene->mTextures[i];
|
||||
auto texPath = std::filesystem::path(tex->mFilename.C_Str());
|
||||
auto texPngPath = meshDirectory;
|
||||
texPngPath.append(texPath.filename().string());
|
||||
if(tex->mHeight == 0)
|
||||
texPngPath.append(fmt::format("{0}.{1}", texPath.filename().string(), tex->achFormatHint));
|
||||
if (!std::filesystem::exists(texPngPath))
|
||||
{
|
||||
// already compressed, just dump it to the disk
|
||||
std::ofstream file(texPngPath, std::ios::binary);
|
||||
file.write((const char*)tex->pcData, tex->mWidth);
|
||||
file.flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
// recompress data so that the TextureLoader can read it
|
||||
unsigned char* texData = new unsigned char[tex->mWidth * tex->mHeight * 4];
|
||||
convertAssimpARGB(texData, tex->pcData, tex->mWidth * tex->mHeight);
|
||||
stbi_write_png(texPngPath.string().c_str(), tex->mWidth, tex->mHeight, 4, tex->pcData, tex->mWidth * 32);
|
||||
delete[] texData;
|
||||
if (tex->mHeight == 0)
|
||||
{
|
||||
// already compressed, just dump it to the disk
|
||||
std::ofstream file(texPngPath, std::ios::binary);
|
||||
file.write((const char*)tex->pcData, tex->mWidth);
|
||||
file.flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
// recompress data so that the TextureLoader can read it
|
||||
unsigned char* texData = new unsigned char[tex->mWidth * tex->mHeight * 4];
|
||||
convertAssimpARGB(texData, tex->pcData, tex->mWidth * tex->mHeight);
|
||||
stbi_write_png(texPngPath.string().c_str(), tex->mWidth, tex->mHeight, 4, tex->pcData, tex->mWidth * 32);
|
||||
delete[] texData;
|
||||
}
|
||||
}
|
||||
std::cout << "Loading model texture " << texPngPath.string() << std::endl;
|
||||
AssetImporter::importTexture(TextureImportArgs {
|
||||
.filePath = texPath,
|
||||
.filePath = texPngPath,
|
||||
.importPath = importPath,
|
||||
});
|
||||
}
|
||||
@@ -353,21 +356,21 @@ void MeshLoader::loadTextures(const aiScene* scene, const std::filesystem::path&
|
||||
Matrix4 convertMatrix(aiMatrix4x4 matrix)
|
||||
{
|
||||
return Matrix4(
|
||||
matrix.a1, matrix.a2, matrix.a3, matrix.a4,
|
||||
matrix.b1, matrix.b2, matrix.b3, matrix.b4,
|
||||
matrix.c1, matrix.c2, matrix.c3, matrix.c4,
|
||||
matrix.d1, matrix.d2, matrix.d3, matrix.d4
|
||||
matrix.a1, matrix.b1, matrix.c1, matrix.d1,
|
||||
matrix.a2, matrix.b2, matrix.c2, matrix.d2,
|
||||
matrix.a3, matrix.b3, matrix.c3, matrix.d3,
|
||||
matrix.a4, matrix.b4, matrix.c4, matrix.d4
|
||||
);
|
||||
}
|
||||
|
||||
Matrix4 MeshLoader::loadNodeTransform(aiNode* node)
|
||||
aiMatrix4x4 loadNodeTransform(aiNode* node)
|
||||
{
|
||||
Matrix4 parent = Matrix4(1);
|
||||
aiMatrix4x4 parent = aiMatrix4x4();
|
||||
if (node->mParent != nullptr)
|
||||
{
|
||||
parent = loadNodeTransform(node->mParent);
|
||||
}
|
||||
return parent * convertMatrix(node->mTransformation);
|
||||
return node->mTransformation * parent;
|
||||
}
|
||||
|
||||
void MeshLoader::import(MeshImportArgs args, PMeshAsset meshAsset)
|
||||
@@ -382,10 +385,11 @@ void MeshLoader::import(MeshImportArgs args, PMeshAsset meshAsset)
|
||||
aiProcess_SortByPType |
|
||||
aiProcess_GenBoundingBoxes |
|
||||
aiProcess_GenSmoothNormals |
|
||||
aiProcess_ImproveCacheLocality |
|
||||
aiProcess_GenUVCoords |
|
||||
aiProcess_SortByPType |
|
||||
aiProcess_FindDegenerates));
|
||||
const aiScene *scene = importer.ApplyPostProcessing(aiProcess_CalcTangentSpace);
|
||||
std::cout << importer.GetErrorString() << std::endl;
|
||||
|
||||
Array<PMaterialInstanceAsset> globalMaterials(scene->mNumMaterials);
|
||||
loadTextures(scene, args.filePath.parent_path(), args.importPath);
|
||||
@@ -408,7 +412,7 @@ void MeshLoader::import(MeshImportArgs args, PMeshAsset meshAsset)
|
||||
continue;
|
||||
}
|
||||
meshes.add(std::move(globalMeshes[meshNode->mMeshes[i]]));
|
||||
meshes.back()->transform = loadNodeTransform(meshNode);
|
||||
meshes.back()->transform = convertMatrix(loadNodeTransform(meshNode));
|
||||
}
|
||||
}
|
||||
meshAsset->meshes = std::move(meshes);
|
||||
|
||||
@@ -30,7 +30,6 @@ private:
|
||||
void loadGlobalMeshes(const aiScene* scene, const Array<PMaterialInstanceAsset>& materials, Array<OMesh>& globalMeshes, Component::Collider& collider);
|
||||
void convertAssimpARGB(unsigned char* dst, aiTexel* src, uint32 numPixels);
|
||||
|
||||
Matrix4 loadNodeTransform(aiNode* node);
|
||||
void import(MeshImportArgs args, PMeshAsset meshAsset);
|
||||
Gfx::PGraphics graphics;
|
||||
};
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ int main() {
|
||||
.filePath = sourcePath / "import/models/cube.fbx",
|
||||
});
|
||||
AssetImporter::importMesh(MeshImportArgs{
|
||||
.filePath = sourcePath / "import/models/after-the-rain-vr-sound/source/Whitechapel.blend",
|
||||
.filePath = sourcePath / "import/models/after-the-rain-vr-sound/source/Whitechapel.obj",
|
||||
.importPath = "Whitechapel"
|
||||
});
|
||||
WindowCreateInfo mainWindowInfo;
|
||||
|
||||
@@ -169,8 +169,8 @@ static constexpr bool useMeshShading = true;
|
||||
static constexpr uint32 numFramesBuffered = 3;
|
||||
|
||||
// meshlet dimensions curated by NVIDIA
|
||||
static constexpr uint32 numVerticesPerMeshlet = 64;
|
||||
static constexpr uint32 numPrimitivesPerMeshlet = 126;
|
||||
static constexpr uint32 numVerticesPerMeshlet = 256;
|
||||
static constexpr uint32 numPrimitivesPerMeshlet = 256;
|
||||
double getCurrentFrameDelta();
|
||||
uint32 getCurrentFrameIndex();
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Containers/Map.h"
|
||||
#include "Containers/List.h"
|
||||
#include "Containers/Set.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
@@ -194,7 +195,7 @@ bool addTriangle(const Array<Vector>& positions, Meshlet ¤t, Triangle& tri
|
||||
int f2 = findIndex(current, tri.indices[1]);
|
||||
int f3 = findIndex(current, tri.indices[2]);
|
||||
|
||||
if (f1 == -1 || f2 == -1 || f3 == -1)
|
||||
if (f1 == -1 || f2 == -1 || f3 == -1 || current.numPrimitives == Gfx::numPrimitivesPerMeshlet)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -214,16 +215,16 @@ void Meshlet::build(const Array<Vector> &positions, const Array<uint32> &indices
|
||||
.numVertices = 0,
|
||||
.numPrimitives = 0,
|
||||
};
|
||||
Array<uint32> optimizedIndices;
|
||||
tipsifyIndexBuffer(indices, positions.size(), 25, optimizedIndices);
|
||||
Array<Triangle> triangles(optimizedIndices.size() / 3);
|
||||
//Array<uint32> optimizedIndices = indices;
|
||||
//tipsifyIndexBuffer(indices, positions.size(), 25, optimizedIndices);
|
||||
Array<Triangle> triangles(indices.size() / 3);
|
||||
for (size_t i = 0; i < triangles.size(); ++i)
|
||||
{
|
||||
triangles[i] = Triangle{
|
||||
.indices = {
|
||||
optimizedIndices[i * 3 + 0],
|
||||
optimizedIndices[i * 3 + 1],
|
||||
optimizedIndices[i * 3 + 2],
|
||||
indices[i * 3 + 0],
|
||||
indices[i * 3 + 1],
|
||||
indices[i * 3 + 2],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -164,11 +164,7 @@ void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet>
|
||||
std::memcpy(vertexIndices.data() + vertexOffset, m.uniqueVertices, m.numVertices * sizeof(uint32));
|
||||
uint32 primitiveOffset = primitiveIndices.size();
|
||||
primitiveIndices.resize(primitiveOffset + (m.numPrimitives * 3));
|
||||
for(size_t x = 0; x < m.numPrimitives*3; ++x)
|
||||
{
|
||||
primitiveIndices[primitiveOffset + x] = m.primitiveLayout[x];
|
||||
}
|
||||
//std::memcpy(primitiveIndices.data() + primitiveOffset, m.primitiveLayout, m.numPrimitives * 3 * sizeof(uint8));
|
||||
std::memcpy(primitiveIndices.data() + primitiveOffset, m.primitiveLayout, m.numPrimitives * 3 * sizeof(uint8));
|
||||
meshlets.add(MeshletDescription{
|
||||
.bounding = m.boundingBox.toSphere(),
|
||||
.vertexCount = m.numVertices,
|
||||
@@ -218,7 +214,7 @@ void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet>
|
||||
});
|
||||
primitiveIndicesBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||
.sourceData = {
|
||||
.size = sizeof(uint32) * primitiveIndices.size(),
|
||||
.size = sizeof(uint8) * primitiveIndices.size(),
|
||||
.data = (uint8*)primitiveIndices.data(),
|
||||
},
|
||||
.numElements = primitiveIndices.size(),
|
||||
@@ -280,11 +276,11 @@ void Seele::VertexData::init(Gfx::PGraphics _graphics)
|
||||
// meshData
|
||||
instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,});
|
||||
// meshletData
|
||||
instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding =2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
// primitiveIndices
|
||||
instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding =3, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 3, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
// vetexIndices
|
||||
instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding =4, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 4, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
|
||||
instanceDataLayout->create();
|
||||
resizeBuffers();
|
||||
|
||||
@@ -99,7 +99,7 @@ protected:
|
||||
Map<MeshId, uint64> meshOffsets;
|
||||
Map<MeshId, uint64> meshVertexCounts;
|
||||
Array<MeshletDescription> meshlets;
|
||||
Array<uint32> primitiveIndices;
|
||||
Array<uint8> primitiveIndices;
|
||||
Array<uint32> vertexIndices;
|
||||
Array<uint32> indices;
|
||||
Gfx::PGraphics graphics;
|
||||
|
||||
@@ -328,7 +328,7 @@ void PipelineLayout::create() {
|
||||
PDescriptorLayout layout = desc.cast<DescriptorLayout>();
|
||||
layout->create();
|
||||
uint32 parameterIndex = parameterMapping[layout->getName()];
|
||||
if (parameterIndex > vulkanDescriptorLayouts.size())
|
||||
if (parameterIndex >= vulkanDescriptorLayouts.size())
|
||||
{
|
||||
vulkanDescriptorLayouts.resize(parameterIndex + 1);
|
||||
}
|
||||
|
||||
@@ -489,7 +489,7 @@ void Graphics::pickPhysicalDevice()
|
||||
{
|
||||
if (std::strcmp(VK_EXT_MESH_SHADER_EXTENSION_NAME, extensionProps[i].extensionName) == 0)
|
||||
{
|
||||
meshShadingEnabled = true;
|
||||
//meshShadingEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ Slang::ComPtr<slang::IBlob> Seele::generateShader(const ShaderCreateInfo& create
|
||||
}
|
||||
slang::SessionDesc sessionDesc;
|
||||
sessionDesc.flags = 0;
|
||||
StaticArray<slang::CompilerOptionEntry, 4> option;
|
||||
StaticArray<slang::CompilerOptionEntry, 2> option;
|
||||
option[0].name = slang::CompilerOptionName::DumpIntermediates;
|
||||
option[0].value = slang::CompilerOptionValue();
|
||||
option[0].value.kind = slang::CompilerOptionValueKind::Int;
|
||||
@@ -25,14 +25,6 @@ Slang::ComPtr<slang::IBlob> Seele::generateShader(const ShaderCreateInfo& create
|
||||
option[1].value = slang::CompilerOptionValue();
|
||||
option[1].value.kind = slang::CompilerOptionValueKind::Int;
|
||||
option[1].value.intValue0 = 1;
|
||||
option[2].name = slang::CompilerOptionName::DebugInformation;
|
||||
option[2].value = slang::CompilerOptionValue();
|
||||
option[2].value.kind = slang::CompilerOptionValueKind::Int;
|
||||
option[2].value.intValue0 = 3;
|
||||
option[3].name = slang::CompilerOptionName::DebugInformationFormat;
|
||||
option[3].value = slang::CompilerOptionValue();
|
||||
option[3].value.kind = slang::CompilerOptionValueKind::Int;
|
||||
option[3].value.stringValue0 = "c7";
|
||||
sessionDesc.compilerOptionEntries = option.data();
|
||||
sessionDesc.compilerOptionEntryCount = option.size();
|
||||
sessionDesc.defaultMatrixLayoutMode = SLANG_MATRIX_LAYOUT_COLUMN_MAJOR;
|
||||
@@ -112,8 +104,19 @@ Slang::ComPtr<slang::IBlob> Seele::generateShader(const ShaderCreateInfo& create
|
||||
for(size_t i = 0; i < signature->getParameterCount(); ++i)
|
||||
{
|
||||
auto param = signature->getParameterByIndex(i);
|
||||
paramMapping[param->getName()] = param->getBindingIndex();
|
||||
std::cout << "Parameter " << param->getName() << " index " << param->getBindingIndex() << std::endl;
|
||||
// workaround
|
||||
if (std::strcmp(param->getName(), "pVertexData") == 0)
|
||||
{
|
||||
paramMapping[param->getName()] = 1;
|
||||
}
|
||||
else if (std::strcmp(param->getName(), "pMaterial") == 0)
|
||||
{
|
||||
paramMapping[param->getName()] = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
paramMapping[param->getName()] = param->getBindingIndex();
|
||||
}
|
||||
}
|
||||
return kernelBlob;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user