Draw List works now
This commit is contained in:
@@ -38,7 +38,7 @@ void meshMain(
|
|||||||
uint local_idx1 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 1];
|
uint local_idx1 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 1];
|
||||||
uint local_idx2 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 2];
|
uint local_idx2 = pScene.primitiveIndices[m.primitiveOffset + (p * 3) + 2];
|
||||||
indices[p] = uint3(local_idx0, local_idx1, local_idx2);
|
indices[p] = uint3(local_idx0, local_idx1, local_idx2);
|
||||||
prim[p].cull = false;//!cull.triangleCulled(p);
|
prim[p].cull = !cull.triangleCulled(p);
|
||||||
#ifdef VISIBILITY
|
#ifdef VISIBILITY
|
||||||
prim[p].prim = encodePrimitive(p, meshletId);
|
prim[p].prim = encodePrimitive(p, meshletId);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ void taskMain(
|
|||||||
uint cull = p.cullingOffset + i;
|
uint cull = p.cullingOffset + i;
|
||||||
MeshletDescription meshlet = pScene.meshletInfos[m];
|
MeshletDescription meshlet = pScene.meshletInfos[m];
|
||||||
MeshletCullingInfo culling = pScene.cullingInfos[cull];
|
MeshletCullingInfo culling = pScene.cullingInfos[cull];
|
||||||
//if(!culling.anyVisible())
|
if(false)//if(!culling.anyVisible())
|
||||||
{
|
{
|
||||||
uint index;
|
uint index;
|
||||||
InterlockedAdd(head, 1, index);
|
InterlockedAdd(head, 1, index);
|
||||||
|
|||||||
@@ -4,26 +4,20 @@ import Scene;
|
|||||||
struct VisibilityCullingData
|
struct VisibilityCullingData
|
||||||
{
|
{
|
||||||
Texture2D<uint> visibilityTexture;
|
Texture2D<uint> visibilityTexture;
|
||||||
RWStructuredBuffer<MeshletCullingInfo> cullingInfos;
|
globallycoherent RWStructuredBuffer<MeshletCullingInfo> cullingInfos;
|
||||||
};
|
};
|
||||||
ParameterBlock<VisibilityCullingData> pVisibilityParams;
|
ParameterBlock<VisibilityCullingData> pVisibilityParams;
|
||||||
|
|
||||||
[numthreads(BLOCK_SIZE, 1, 1)]
|
[numthreads(BLOCK_SIZE, BLOCK_SIZE, 1)]
|
||||||
[shader("compute")]
|
[shader("compute")]
|
||||||
void computeMain(
|
void computeMain(
|
||||||
uint3 dispatchThreadID: SV_DispatchThreadID,
|
uint3 dispatchThreadID: SV_DispatchThreadID,
|
||||||
){
|
){
|
||||||
//int3 texCoords = int3(dispatchThreadID.xy, 0);
|
int3 texCoords = int3(dispatchThreadID.xy, 0);
|
||||||
//uint encoded = pVisibilityParams.visibilityTexture.Load(texCoords).r;
|
uint encoded = pVisibilityParams.visibilityTexture.Load(texCoords).r;
|
||||||
//uint2 decoded = decodePrimitive(encoded);
|
uint2 decoded = decodePrimitive(encoded);
|
||||||
//uint arrIdx = decoded.x / 32;
|
uint arrIdx = decoded.x / 32;
|
||||||
//uint bit = decoded.x % 32;
|
uint bit = decoded.x % 32;
|
||||||
pVisibilityParams.cullingInfos[dispatchThreadID.x].visible[0] = 0x0;
|
uint32_t orig;
|
||||||
pVisibilityParams.cullingInfos[dispatchThreadID.x].visible[1] = 0x0;
|
InterlockedOr(pVisibilityParams.cullingInfos[decoded.y].visible[arrIdx], (1 << bit), orig);
|
||||||
pVisibilityParams.cullingInfos[dispatchThreadID.x].visible[2] = 0x0;
|
|
||||||
pVisibilityParams.cullingInfos[dispatchThreadID.x].visible[3] = 0x0;
|
|
||||||
pVisibilityParams.cullingInfos[dispatchThreadID.x].visible[4] = 0x0;
|
|
||||||
pVisibilityParams.cullingInfos[dispatchThreadID.x].visible[5] = 0x0;
|
|
||||||
pVisibilityParams.cullingInfos[dispatchThreadID.x].visible[6] = 0x0;
|
|
||||||
pVisibilityParams.cullingInfos[dispatchThreadID.x].visible[7] = 0x0;
|
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
|
extern bool resetVisibility;
|
||||||
|
|
||||||
VisibilityPass::VisibilityPass(Gfx::PGraphics graphics, PScene scene)
|
VisibilityPass::VisibilityPass(Gfx::PGraphics graphics, PScene scene)
|
||||||
: RenderPass(graphics, scene)
|
: RenderPass(graphics, scene)
|
||||||
{
|
{
|
||||||
@@ -17,22 +19,26 @@ void VisibilityPass::beginFrame(const Component::Camera& cam)
|
|||||||
{
|
{
|
||||||
RenderPass::beginFrame(cam);
|
RenderPass::beginFrame(cam);
|
||||||
cullingBuffer->rotateBuffer(VertexData::getMeshletCount() * sizeof(VertexData::MeshletCullingInfo), true);
|
cullingBuffer->rotateBuffer(VertexData::getMeshletCount() * sizeof(VertexData::MeshletCullingInfo), true);
|
||||||
|
if (resetVisibility)
|
||||||
|
{
|
||||||
|
Array<VertexData::MeshletCullingInfo> cullingData(VertexData::getMeshletCount());
|
||||||
|
std::memset(cullingData.data(), 0xffff, cullingData.size() * sizeof(VertexData::MeshletCullingInfo));
|
||||||
|
|
||||||
//Array<VertexData::MeshletCullingInfo> cullingData(VertexData::getMeshletCount());
|
cullingBuffer->updateContents(ShaderBufferCreateInfo{
|
||||||
//std::memset(cullingData.data(), 0xffff, cullingData.size() * sizeof(VertexData::MeshletCullingInfo));
|
.sourceData = {
|
||||||
|
.size = VertexData::getMeshletCount() * sizeof(VertexData::MeshletCullingInfo),
|
||||||
|
.data = (uint8 *)cullingData.data(),
|
||||||
|
},
|
||||||
|
.numElements = VertexData::getMeshletCount()});
|
||||||
|
cullingBuffer->pipelineBarrier(
|
||||||
|
Gfx::SE_ACCESS_TRANSFER_WRITE_BIT,
|
||||||
|
Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
|
Gfx::SE_ACCESS_MEMORY_WRITE_BIT,
|
||||||
|
Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT);
|
||||||
|
|
||||||
|
resetVisibility = false;
|
||||||
|
}
|
||||||
|
|
||||||
//cullingBuffer->updateContents(ShaderBufferCreateInfo{
|
|
||||||
// .sourceData = {
|
|
||||||
// .size = VertexData::getMeshletCount() * sizeof(VertexData::MeshletCullingInfo),
|
|
||||||
// .data = (uint8 *)cullingData.data(),
|
|
||||||
// },
|
|
||||||
// .numElements = VertexData::getMeshletCount()});
|
|
||||||
//cullingBuffer->pipelineBarrier(
|
|
||||||
// Gfx::SE_ACCESS_TRANSFER_WRITE_BIT,
|
|
||||||
// Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
|
||||||
// Gfx::SE_ACCESS_MEMORY_WRITE_BIT,
|
|
||||||
// Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisibilityPass::render()
|
void VisibilityPass::render()
|
||||||
@@ -60,8 +66,7 @@ void VisibilityPass::render()
|
|||||||
Gfx::OComputeCommand command = graphics->createComputeCommand("VisibilityCommand");
|
Gfx::OComputeCommand command = graphics->createComputeCommand("VisibilityCommand");
|
||||||
command->bindPipeline(visibilityPipeline);
|
command->bindPipeline(visibilityPipeline);
|
||||||
command->bindDescriptor({viewParamsSet, visibilitySet});
|
command->bindDescriptor({viewParamsSet, visibilitySet});
|
||||||
command->dispatch(VertexData::getMeshletCount() / BLOCK_SIZE, 1, 1);
|
command->dispatch(threadGroupSize.x, threadGroupSize.y, threadGroupSize.z);
|
||||||
//command->dispatch(threadGroupSize.x, threadGroupSize.y, threadGroupSize.z);
|
|
||||||
Array<Gfx::OComputeCommand> commands;
|
Array<Gfx::OComputeCommand> commands;
|
||||||
commands.add(std::move(command));
|
commands.add(std::move(command));
|
||||||
graphics->executeCommands(std::move(commands));
|
graphics->executeCommands(std::move(commands));
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ using namespace Seele;
|
|||||||
bool usePositionOnly = false;
|
bool usePositionOnly = false;
|
||||||
bool useViewCulling = false;
|
bool useViewCulling = false;
|
||||||
bool useLightCulling = false;
|
bool useLightCulling = false;
|
||||||
|
bool resetVisibility = 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")
|
||||||
@@ -122,6 +124,10 @@ void GameView::keyCallback(KeyCode code, InputAction action, KeyModifier modifie
|
|||||||
useLightCulling = !useLightCulling;
|
useLightCulling = !useLightCulling;
|
||||||
std::cout << "Use Light Culling " << useLightCulling << std::endl;
|
std::cout << "Use Light Culling " << useLightCulling << std::endl;
|
||||||
}
|
}
|
||||||
|
if (code == KeyCode::KEY_R && action == InputAction::RELEASE)
|
||||||
|
{
|
||||||
|
resetVisibility = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::mouseMoveCallback(double xPos, double yPos)
|
void GameView::mouseMoveCallback(double xPos, double yPos)
|
||||||
|
|||||||
Reference in New Issue
Block a user