Updating slang
This commit is contained in:
@@ -50,7 +50,6 @@ find_package(nlohmann_json CONFIG REQUIRED)
|
|||||||
find_package(fmt CONFIG REQUIRED)
|
find_package(fmt CONFIG REQUIRED)
|
||||||
find_package(VulkanMemoryAllocator CONFIG REQUIRED)
|
find_package(VulkanMemoryAllocator CONFIG REQUIRED)
|
||||||
|
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
+10
-10
@@ -5,21 +5,21 @@ include (ExternalProject)
|
|||||||
add_library(shader-slang-glslang SHARED IMPORTED)
|
add_library(shader-slang-glslang SHARED IMPORTED)
|
||||||
add_library(shader-slang SHARED IMPORTED)
|
add_library(shader-slang SHARED IMPORTED)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(SLANG_ROOT ${EXTERNAL_ROOT}/slang/bin/windows-x64/release)
|
set(SLANG_ROOT ${EXTERNAL_ROOT}/vcpkg/packages/shader-slang_x64-windows/)
|
||||||
set_target_properties(shader-slang-glslang PROPERTIES IMPORTED_LOCATION ${SLANG_ROOT}/slang-glslang.dll)
|
set_target_properties(shader-slang-glslang PROPERTIES IMPORTED_LOCATION ${SLANG_ROOT}/bin/slang-glslang.dll)
|
||||||
set_target_properties(shader-slang-glslang PROPERTIES IMPORTED_IMPLIB ${SLANG_ROOT}/slang.lib)
|
set_target_properties(shader-slang-glslang PROPERTIES IMPORTED_IMPLIB ${SLANG_ROOT}/lib/slang.lib)
|
||||||
set_target_properties(shader-slang PROPERTIES IMPORTED_LOCATION ${SLANG_ROOT}/slang.dll)
|
set_target_properties(shader-slang PROPERTIES IMPORTED_LOCATION ${SLANG_ROOT}/bin/slang.dll)
|
||||||
set_target_properties(shader-slang PROPERTIES IMPORTED_IMPLIB ${SLANG_ROOT}/slang.lib)
|
set_target_properties(shader-slang PROPERTIES IMPORTED_IMPLIB ${SLANG_ROOT}/lib/slang.lib)
|
||||||
target_link_libraries(shader-slang INTERFACE shader-slang-glslang)
|
target_link_libraries(shader-slang INTERFACE shader-slang-glslang)
|
||||||
install(FILES
|
install(FILES
|
||||||
${SLANG_ROOT}/slang-glslang.dll
|
${SLANG_ROOT}/bin/slang-glslang.dll
|
||||||
${SLANG_ROOT}/slang.dll
|
${SLANG_ROOT}/bin/slang.dll
|
||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||||
install(FILES
|
install(FILES
|
||||||
${SLANG_ROOT}/slang.lib
|
${SLANG_ROOT}/lib/slang.lib
|
||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
set(SLANG_ROOT ${EXTERNAL_ROOT}/slang/bin/macosx-aarch64/release)
|
set(SLANG_ROOT ${EXTERNAL_ROOT}/vcpkg/packages/shader-slang_${CMAKE_PLATFORM}-macos/)
|
||||||
set_target_properties(shader-slang-glslang PROPERTIES IMPORTED_LOCATION ${SLANG_ROOT}/libslang-glslang.dylib)
|
set_target_properties(shader-slang-glslang PROPERTIES IMPORTED_LOCATION ${SLANG_ROOT}/libslang-glslang.dylib)
|
||||||
set_target_properties(shader-slang PROPERTIES IMPORTED_LOCATION ${SLANG_ROOT}/libslang.dylib)
|
set_target_properties(shader-slang PROPERTIES IMPORTED_LOCATION ${SLANG_ROOT}/libslang.dylib)
|
||||||
target_link_libraries(shader-slang INTERFACE shader-slang-glslang)
|
target_link_libraries(shader-slang INTERFACE shader-slang-glslang)
|
||||||
@@ -29,7 +29,7 @@ elseif(APPLE)
|
|||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||||
endif()
|
endif()
|
||||||
target_include_directories(shader-slang INTERFACE
|
target_include_directories(shader-slang INTERFACE
|
||||||
$<BUILD_INTERFACE:${EXTERNAL_ROOT}/slang/>
|
$<BUILD_INTERFACE:${SLANG_ROOT}/include/>
|
||||||
$<INSTALL_INTERFACE:include>
|
$<INSTALL_INTERFACE:include>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ groupshared uint uMinDepth;
|
|||||||
groupshared uint uMaxDepth;
|
groupshared uint uMaxDepth;
|
||||||
|
|
||||||
groupshared Frustum groupFrustum;
|
groupshared Frustum groupFrustum;
|
||||||
|
groupshared float4x4 viewMatrix;
|
||||||
|
|
||||||
groupshared uint oLightCount;
|
groupshared uint oLightCount;
|
||||||
groupshared uint oLightIndexStartOffset;
|
groupshared uint oLightIndexStartOffset;
|
||||||
@@ -72,6 +73,7 @@ void cullLights(ComputeShaderInput in)
|
|||||||
uint uDepth = asuint(fDepth);
|
uint uDepth = asuint(fDepth);
|
||||||
if(in.groupIndex == 0)
|
if(in.groupIndex == 0)
|
||||||
{
|
{
|
||||||
|
viewMatrix = pViewParams.viewMatrix;
|
||||||
uMinDepth = 0xffffffff;
|
uMinDepth = 0xffffffff;
|
||||||
uMaxDepth = 0x0;
|
uMaxDepth = 0x0;
|
||||||
oLightCount = 0;
|
oLightCount = 0;
|
||||||
@@ -98,11 +100,11 @@ void cullLights(ComputeShaderInput in)
|
|||||||
for ( uint i = in.groupIndex; i < pLightEnv.numPointLights; i += BLOCK_SIZE * BLOCK_SIZE )
|
for ( uint i = in.groupIndex; i < pLightEnv.numPointLights; i += BLOCK_SIZE * BLOCK_SIZE )
|
||||||
{
|
{
|
||||||
PointLight light = pLightEnv.pointLights[i];
|
PointLight light = pLightEnv.pointLights[i];
|
||||||
float3 light_VS = light.getViewPosition();
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ void taskMain(
|
|||||||
{
|
{
|
||||||
uint m = mesh.meshletOffset + i;
|
uint m = mesh.meshletOffset + i;
|
||||||
MeshletDescription meshlet = pScene.meshletInfos[m];
|
MeshletDescription meshlet = pScene.meshletInfos[m];
|
||||||
if(meshlet.bounding.insideFrustum(localToView, viewFrustum))
|
//if(meshlet.bounding.insideFrustum(localToView, viewFrustum))
|
||||||
{
|
{
|
||||||
uint index;
|
uint index;
|
||||||
InterlockedAdd(head, 1, index);
|
InterlockedAdd(head, 1, index);
|
||||||
@@ -72,41 +72,23 @@ void meshMain(
|
|||||||
in uint threadID: SV_GroupIndex,
|
in uint threadID: SV_GroupIndex,
|
||||||
in uint groupID: SV_GroupID,
|
in uint groupID: SV_GroupID,
|
||||||
in payload MeshPayload meshPayload,
|
in payload MeshPayload meshPayload,
|
||||||
out Vertices<FragmentParameter, MAX_VERTICES> vertices,
|
OutputVertices<FragmentParameter, MAX_VERTICES> vertices,
|
||||||
out Indices<uint3, MAX_PRIMITIVES> indices
|
OutputIndices<uint3, MAX_PRIMITIVES> indices
|
||||||
){
|
){
|
||||||
InstanceData inst = pScene.instances[meshPayload.instanceId[groupID]];
|
InstanceData inst = pScene.instances[meshPayload.instanceId[groupID]];
|
||||||
MeshData md = pScene.meshData[meshPayload.instanceId[groupID]];
|
MeshData md = pScene.meshData[meshPayload.instanceId[groupID]];
|
||||||
MeshletDescription m = pScene.meshletInfos[meshPayload.meshletId[groupID]];
|
MeshletDescription m = pScene.meshletInfos[meshPayload.meshletId[groupID]];
|
||||||
SetMeshOutputCounts(m.vertexCount, m.primitiveCount);
|
SetMeshOutputCounts(m.vertexCount, m.primitiveCount);
|
||||||
|
|
||||||
uint p = min(threadID, m.primitiveCount - 1);
|
for(uint i = threadID; i < MAX_PRIMITIVES; i += MESH_GROUP_SIZE)
|
||||||
{
|
{
|
||||||
uint local_idx0 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 0];
|
uint p = min(i, m.primitiveCount - 1);
|
||||||
uint local_idx1 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 1];
|
{
|
||||||
uint local_idx2 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 2];
|
uint local_idx0 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 0];
|
||||||
indices[p] = uint3(local_idx0, local_idx1, local_idx2);
|
uint local_idx1 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 1];
|
||||||
}
|
uint local_idx2 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 2];
|
||||||
p = min(threadID + 32, m.primitiveCount - 1);
|
indices[p] = uint3(local_idx0, local_idx1, local_idx2);
|
||||||
{
|
}
|
||||||
uint local_idx0 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 0];
|
|
||||||
uint local_idx1 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 1];
|
|
||||||
uint local_idx2 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 2];
|
|
||||||
indices[p] = uint3(local_idx0, local_idx1, local_idx2);
|
|
||||||
}
|
|
||||||
p = min(threadID + 64, m.primitiveCount - 1);
|
|
||||||
{
|
|
||||||
uint local_idx0 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 0];
|
|
||||||
uint local_idx1 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 1];
|
|
||||||
uint local_idx2 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 2];
|
|
||||||
indices[p] = uint3(local_idx0, local_idx1, local_idx2);
|
|
||||||
}
|
|
||||||
p = min(threadID + 96, m.primitiveCount - 1);
|
|
||||||
{
|
|
||||||
uint local_idx0 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 0];
|
|
||||||
uint local_idx1 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 1];
|
|
||||||
uint local_idx2 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 2];
|
|
||||||
indices[p] = uint3(local_idx0, local_idx1, local_idx2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupMemoryBarrierWithGroupSync();
|
GroupMemoryBarrierWithGroupSync();
|
||||||
|
|||||||
@@ -32,11 +32,6 @@ struct PointLight : ILightEnv
|
|||||||
float illuminance = max(1 - d / colorRange.w, 0);
|
float illuminance = max(1 - d / colorRange.w, 0);
|
||||||
return illuminance * brdf.evaluate(params.tbn, params.viewDir_TS, -normalize(lightDir_TS), colorRange.xyz);
|
return illuminance * brdf.evaluate(params.tbn, params.viewDir_TS, -normalize(lightDir_TS), colorRange.xyz);
|
||||||
}
|
}
|
||||||
float3 getViewPosition()
|
|
||||||
{
|
|
||||||
float4 position_VS = mul(pViewParams.viewMatrix, position_WS);
|
|
||||||
return position_VS.xyz / position_VS.w;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool insidePlane(Plane plane, float3 position_VS)
|
bool insidePlane(Plane plane, float3 position_VS)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Bounding;
|
|||||||
|
|
||||||
struct MeshletDescription
|
struct MeshletDescription
|
||||||
{
|
{
|
||||||
AABB bounding;
|
BoundingSphere bounding;
|
||||||
uint32_t vertexCount;
|
uint32_t vertexCount;
|
||||||
uint32_t primitiveCount;
|
uint32_t primitiveCount;
|
||||||
uint32_t vertexOffset;
|
uint32_t vertexOffset;
|
||||||
@@ -13,7 +13,7 @@ struct MeshletDescription
|
|||||||
|
|
||||||
struct MeshData
|
struct MeshData
|
||||||
{
|
{
|
||||||
AABB bounding;
|
BoundingSphere bounding;
|
||||||
uint32_t numMeshlets;
|
uint32_t numMeshlets;
|
||||||
uint32_t meshletOffset;
|
uint32_t meshletOffset;
|
||||||
uint32_t firstIndex;
|
uint32_t firstIndex;
|
||||||
|
|||||||
@@ -56,9 +56,6 @@ void BasePass::render()
|
|||||||
tLightGrid->pipelineBarrier(
|
tLightGrid->pipelineBarrier(
|
||||||
Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||||
depthAttachment.getTexture()->pipelineBarrier(
|
|
||||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
|
||||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT, Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
|
|
||||||
|
|
||||||
descriptorSets[INDEX_VIEW_PARAMS] = viewParamsSet;
|
descriptorSets[INDEX_VIEW_PARAMS] = viewParamsSet;
|
||||||
descriptorSets[INDEX_LIGHT_ENV] = scene->getLightEnvironment()->getDescriptorSet();
|
descriptorSets[INDEX_LIGHT_ENV] = scene->getLightEnvironment()->getDescriptorSet();
|
||||||
@@ -197,7 +194,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{
|
||||||
@@ -238,7 +235,7 @@ void BasePass::createRenderPass()
|
|||||||
.dstAccess = Gfx::SE_ACCESS_NONE,
|
.dstAccess = Gfx::SE_ACCESS_NONE,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
renderPass = graphics->createRenderPass(std::move(layout), {dependency}, viewport);
|
renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), viewport);
|
||||||
oLightIndexList = resources->requestBuffer("LIGHTCULLING_OLIGHTLIST");
|
oLightIndexList = resources->requestBuffer("LIGHTCULLING_OLIGHTLIST");
|
||||||
tLightIndexList = resources->requestBuffer("LIGHTCULLING_TLIGHTLIST");
|
tLightIndexList = resources->requestBuffer("LIGHTCULLING_TLIGHTLIST");
|
||||||
oLightGrid = resources->requestTexture("LIGHTCULLING_OLIGHTGRID");
|
oLightGrid = resources->requestTexture("LIGHTCULLING_OLIGHTGRID");
|
||||||
|
|||||||
@@ -161,15 +161,25 @@ void DepthPrepass::createRenderPass()
|
|||||||
Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
|
Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
|
||||||
.depthAttachment = depthAttachment,
|
.depthAttachment = depthAttachment,
|
||||||
};
|
};
|
||||||
Gfx::SubPassDependency dependency = {
|
Array<Gfx::SubPassDependency> dependency = {
|
||||||
.srcSubpass = ~0U,
|
{
|
||||||
.dstSubpass = 0,
|
.srcSubpass = ~0U,
|
||||||
.srcStage = Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
.dstSubpass = 0,
|
||||||
.dstStage = Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
|
.srcStage = Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||||
.srcAccess = Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
.dstStage = Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
|
||||||
.dstAccess = Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
.srcAccess = Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||||
|
.dstAccess = Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.srcSubpass = 0,
|
||||||
|
.dstSubpass = ~0U,
|
||||||
|
.srcStage = Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
||||||
|
.dstStage = Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||||
|
.srcAccess = Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||||
|
.dstAccess = Gfx::SE_ACCESS_SHADER_READ_BIT,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
renderPass = graphics->createRenderPass(std::move(layout), {dependency}, viewport);
|
renderPass = graphics->createRenderPass(std::move(layout), dependency, viewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepthPrepass::modifyRenderPassMacros(Map<const char*, const char*>&)
|
void DepthPrepass::modifyRenderPassMacros(Map<const char*, const char*>&)
|
||||||
|
|||||||
@@ -51,9 +51,6 @@ void LightCullingPass::beginFrame(const Component::Camera& cam)
|
|||||||
|
|
||||||
void LightCullingPass::render()
|
void LightCullingPass::render()
|
||||||
{
|
{
|
||||||
depthAttachment->pipelineBarrier(
|
|
||||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
|
||||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
|
||||||
depthAttachment->transferOwnership(Gfx::QueueType::COMPUTE);
|
depthAttachment->transferOwnership(Gfx::QueueType::COMPUTE);
|
||||||
cullingDescriptorSet->updateTexture(0, depthAttachment);
|
cullingDescriptorSet->updateTexture(0, depthAttachment);
|
||||||
cullingDescriptorSet->updateBuffer(1, oLightIndexCounter);
|
cullingDescriptorSet->updateBuffer(1, oLightIndexCounter);
|
||||||
@@ -70,7 +67,6 @@ void LightCullingPass::render()
|
|||||||
Array<Gfx::PComputeCommand> commands = {computeCommand};
|
Array<Gfx::PComputeCommand> commands = {computeCommand};
|
||||||
//std::cout << "Execute" << std::endl;
|
//std::cout << "Execute" << std::endl;
|
||||||
graphics->executeCommands(commands);
|
graphics->executeCommands(commands);
|
||||||
graphics->waitDeviceIdle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightCullingPass::endFrame()
|
void LightCullingPass::endFrame()
|
||||||
@@ -157,7 +153,7 @@ void LightCullingPass::publishOutputs()
|
|||||||
.size = (uint32)sizeof(uint32)
|
.size = (uint32)sizeof(uint32)
|
||||||
* dispatchParams.numThreadGroups.x
|
* dispatchParams.numThreadGroups.x
|
||||||
* dispatchParams.numThreadGroups.y
|
* dispatchParams.numThreadGroups.y
|
||||||
* dispatchParams.numThreadGroups.z * 1024 * 16,
|
* dispatchParams.numThreadGroups.z * 8192,
|
||||||
.data = nullptr,
|
.data = nullptr,
|
||||||
.owner = Gfx::QueueType::COMPUTE
|
.owner = Gfx::QueueType::COMPUTE
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -44,43 +44,43 @@ void VertexData::updateMesh(PMesh mesh, Component::Transform& transform)
|
|||||||
},
|
},
|
||||||
.data = data,
|
.data = data,
|
||||||
});
|
});
|
||||||
for (size_t i = 0; i < data.numMeshlets; ++i)
|
//for (size_t i = 0; i < data.numMeshlets; ++i)
|
||||||
{
|
//{
|
||||||
auto bounding = meshlets[data.meshletOffset + i].bounding;
|
// auto bounding = meshlets[data.meshletOffset + i].bounding;
|
||||||
StaticArray<Vector, 8> corners;
|
// StaticArray<Vector, 8> corners;
|
||||||
corners[0] = transform.toMatrix() * Vector4(bounding.min.x, bounding.min.y, bounding.min.z, 1);
|
// corners[0] = transform.toMatrix() * Vector4(bounding.min.x, bounding.min.y, bounding.min.z, 1);
|
||||||
corners[1] = transform.toMatrix() * Vector4(bounding.min.x, bounding.min.y, bounding.max.z, 1);
|
// corners[1] = transform.toMatrix() * Vector4(bounding.min.x, bounding.min.y, bounding.max.z, 1);
|
||||||
corners[2] = transform.toMatrix() * Vector4(bounding.min.x, bounding.max.y, bounding.min.z, 1);
|
// corners[2] = transform.toMatrix() * Vector4(bounding.min.x, bounding.max.y, bounding.min.z, 1);
|
||||||
corners[3] = transform.toMatrix() * Vector4(bounding.min.x, bounding.max.y, bounding.max.z, 1);
|
// corners[3] = transform.toMatrix() * Vector4(bounding.min.x, bounding.max.y, bounding.max.z, 1);
|
||||||
corners[4] = transform.toMatrix() * Vector4(bounding.max.x, bounding.min.y, bounding.min.z, 1);
|
// corners[4] = transform.toMatrix() * Vector4(bounding.max.x, bounding.min.y, bounding.min.z, 1);
|
||||||
corners[5] = transform.toMatrix() * Vector4(bounding.max.x, bounding.min.y, bounding.max.z, 1);
|
// corners[5] = transform.toMatrix() * Vector4(bounding.max.x, bounding.min.y, bounding.max.z, 1);
|
||||||
corners[6] = transform.toMatrix() * Vector4(bounding.max.x, bounding.max.y, bounding.min.z, 1);
|
// corners[6] = transform.toMatrix() * Vector4(bounding.max.x, bounding.max.y, bounding.min.z, 1);
|
||||||
corners[7] = transform.toMatrix() * Vector4(bounding.max.x, bounding.max.y, bounding.max.z, 1);
|
// corners[7] = transform.toMatrix() * Vector4(bounding.max.x, bounding.max.y, bounding.max.z, 1);
|
||||||
addDebugVertex(DebugVertex{ .position = corners[0], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[0], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[1], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[1], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[0], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[0], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[2], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[2], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[1], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[1], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[3], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[3], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[2], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[2], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[3], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[3], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[0], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[0], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[4], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[4], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[1], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[1], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[5], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[5], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[2], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[2], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[6], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[6], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[3], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[3], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[7], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[7], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[4], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[4], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[5], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[5], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[4], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[4], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[6], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[6], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[6], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[6], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[7], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[7], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[5], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[5], .color = meshlets[data.meshletOffset + i].color });
|
||||||
addDebugVertex(DebugVertex{ .position = corners[7], .color = meshlets[data.meshletOffset + i].color });
|
// addDebugVertex(DebugVertex{ .position = corners[7], .color = meshlets[data.meshletOffset + i].color });
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
matInstanceData.materialInstance = referencedInstance;
|
matInstanceData.materialInstance = referencedInstance;
|
||||||
referencedInstance->updateDescriptor();
|
referencedInstance->updateDescriptor();
|
||||||
@@ -164,7 +164,7 @@ void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet>
|
|||||||
primitiveIndices.resize(primitiveOffset + (m.numPrimitives * 3));
|
primitiveIndices.resize(primitiveOffset + (m.numPrimitives * 3));
|
||||||
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{
|
meshlets.add(MeshletDescription{
|
||||||
.bounding = m.boundingBox,
|
.bounding = m.boundingBox.toSphere(),
|
||||||
.vertexCount = m.numVertices,
|
.vertexCount = m.numVertices,
|
||||||
.primitiveCount = m.numPrimitives,
|
.primitiveCount = m.numPrimitives,
|
||||||
.vertexOffset = vertexOffset,
|
.vertexOffset = vertexOffset,
|
||||||
@@ -173,7 +173,7 @@ void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
meshData[id].add(MeshData{
|
meshData[id].add(MeshData{
|
||||||
.bounding = meshAABB,
|
.bounding = meshAABB.toSphere(),
|
||||||
.numMeshlets = numMeshlets,
|
.numMeshlets = numMeshlets,
|
||||||
.meshletOffset = meshletOffset,
|
.meshletOffset = meshletOffset,
|
||||||
.indicesOffset = (uint32)meshOffsets[id],
|
.indicesOffset = (uint32)meshOffsets[id],
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public:
|
|||||||
};
|
};
|
||||||
struct MeshData
|
struct MeshData
|
||||||
{
|
{
|
||||||
AABB bounding;
|
BoundingSphere bounding;
|
||||||
uint32 numMeshlets = 0;
|
uint32 numMeshlets = 0;
|
||||||
uint32 meshletOffset = 0;
|
uint32 meshletOffset = 0;
|
||||||
uint32 firstIndex = 0;
|
uint32 firstIndex = 0;
|
||||||
@@ -85,7 +85,7 @@ protected:
|
|||||||
VertexData();
|
VertexData();
|
||||||
struct MeshletDescription
|
struct MeshletDescription
|
||||||
{
|
{
|
||||||
AABB bounding;
|
BoundingSphere bounding;
|
||||||
uint32_t vertexCount;
|
uint32_t vertexCount;
|
||||||
uint32_t primitiveCount;
|
uint32_t primitiveCount;
|
||||||
uint32_t vertexOffset;
|
uint32_t vertexOffset;
|
||||||
|
|||||||
@@ -35,12 +35,12 @@ Graphics::~Graphics()
|
|||||||
{
|
{
|
||||||
vkDeviceWaitIdle(handle);
|
vkDeviceWaitIdle(handle);
|
||||||
pipelineCache = nullptr;
|
pipelineCache = nullptr;
|
||||||
allocator = nullptr;
|
|
||||||
allocatedFramebuffers.clear();
|
allocatedFramebuffers.clear();
|
||||||
shaderCompiler = nullptr;
|
shaderCompiler = nullptr;
|
||||||
pools.clear();
|
pools.clear();
|
||||||
queues.clear();
|
queues.clear();
|
||||||
destructionManager = nullptr;
|
destructionManager = nullptr;
|
||||||
|
allocator = nullptr;
|
||||||
vkDestroyDevice(handle, nullptr);
|
vkDestroyDevice(handle, nullptr);
|
||||||
DestroyDebugUtilsMessengerEXT(instance, nullptr, callback);
|
DestroyDebugUtilsMessengerEXT(instance, nullptr, callback);
|
||||||
vkDestroyInstance(instance, nullptr);
|
vkDestroyInstance(instance, nullptr);
|
||||||
|
|||||||
+2
-1
@@ -11,6 +11,7 @@
|
|||||||
"nlohmann-json",
|
"nlohmann-json",
|
||||||
"fmt",
|
"fmt",
|
||||||
"gtest",
|
"gtest",
|
||||||
"vulkan-memory-allocator"
|
"vulkan-memory-allocator",
|
||||||
|
"shader-slang"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user