Trying out more debugging
This commit is contained in:
@@ -36,7 +36,7 @@ VertexOutput vert(VertexInput input)
|
|||||||
|
|
||||||
float2 texCoord = positionRWS.xz / 1000;
|
float2 texCoord = positionRWS.xz / 1000;
|
||||||
|
|
||||||
positionRWS.y = pParams.displacementMap.SampleLevel(pParams.displacementSampler, texCoord, 0).r * 100;
|
//positionRWS.y = pParams.displacementMap.SampleLevel(pParams.displacementSampler, texCoord, 0).r * 100;
|
||||||
// Apply the view projection
|
// Apply the view projection
|
||||||
output.positionCS = mul(pViewParams.projectionMatrix, mul(pViewParams.viewMatrix, float4(positionRWS, 1.0)));
|
output.positionCS = mul(pViewParams.projectionMatrix, mul(pViewParams.viewMatrix, float4(positionRWS, 1.0)));
|
||||||
return output;
|
return output;
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ static const uint32_t OCBT_bit_count[18] = { 32, // Root 17
|
|||||||
#define BUFFER_ELEMENT_PER_LANE ((OCBT_TREE_NUM_SLOTS + WORKGROUP_SIZE - 1) / WORKGROUP_SIZE)
|
#define BUFFER_ELEMENT_PER_LANE ((OCBT_TREE_NUM_SLOTS + WORKGROUP_SIZE - 1) / WORKGROUP_SIZE)
|
||||||
#define BUFFER_ELEMENT_PER_LANE_NO_BITFIELD ((OCBT_TREE_NUM_SLOTS + WORKGROUP_SIZE - 1) / WORKGROUP_SIZE)
|
#define BUFFER_ELEMENT_PER_LANE_NO_BITFIELD ((OCBT_TREE_NUM_SLOTS + WORKGROUP_SIZE - 1) / WORKGROUP_SIZE)
|
||||||
#define BITFIELD_ELEMENT_PER_LANE ((OCBT_BITFIELD_NUM_SLOTS + WORKGROUP_SIZE - 1) / WORKGROUP_SIZE)
|
#define BITFIELD_ELEMENT_PER_LANE ((OCBT_BITFIELD_NUM_SLOTS + WORKGROUP_SIZE - 1) / WORKGROUP_SIZE)
|
||||||
#define WAVE_TREE_DEPTH uint(17)
|
#define WAVE_TREE_DEPTH uint(log2(OCBT_NUM_ELEMENTS))
|
||||||
|
|
||||||
uint32_t cbt_size()
|
uint32_t cbt_size()
|
||||||
{
|
{
|
||||||
@@ -154,7 +154,7 @@ uint get_bit(uint bitID)
|
|||||||
return uint((pParams.bitFieldBuffer[slot] & (1uLL << local_id)) >> local_id);
|
return uint((pParams.bitFieldBuffer[slot] & (1uLL << local_id)) >> local_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint get_heap_element(uint id)
|
uint get_heap_element(uint id, inout HeapDebug debug)
|
||||||
{
|
{
|
||||||
// Figure out the location of the first bit of this element
|
// Figure out the location of the first bit of this element
|
||||||
uint32_t real_heap_id = id - 1;
|
uint32_t real_heap_id = id - 1;
|
||||||
@@ -162,6 +162,12 @@ uint get_heap_element(uint id)
|
|||||||
uint32_t level_first_element = (1u << depth) - 1;
|
uint32_t level_first_element = (1u << depth) - 1;
|
||||||
uint32_t id_in_level = real_heap_id - level_first_element;
|
uint32_t id_in_level = real_heap_id - level_first_element;
|
||||||
uint32_t first_bit = OCBT_depth_offset[depth] + OCBT_bit_count[depth] * id_in_level;
|
uint32_t first_bit = OCBT_depth_offset[depth] + OCBT_bit_count[depth] * id_in_level;
|
||||||
|
debug.id = id;
|
||||||
|
debug.real_heap_id = real_heap_id;
|
||||||
|
debug.depth = depth;
|
||||||
|
debug.level_first_element = level_first_element;
|
||||||
|
debug.id_in_level = id_in_level;
|
||||||
|
debug.first_bit = first_bit;
|
||||||
if (depth < FIRST_VIRTUAL_LEVEL)
|
if (depth < FIRST_VIRTUAL_LEVEL)
|
||||||
{
|
{
|
||||||
uint32_t slot = first_bit / 32;
|
uint32_t slot = first_bit / 32;
|
||||||
@@ -222,59 +228,37 @@ uint bit_count()
|
|||||||
|
|
||||||
uint bit_count(uint depth, uint element)
|
uint bit_count(uint depth, uint element)
|
||||||
{
|
{
|
||||||
return get_heap_element((1u << depth) + element);
|
HeapDebug debug;
|
||||||
}
|
return get_heap_element((1u << depth) + element, debug);
|
||||||
|
|
||||||
// decodes the position of the i-th one in the bitfield
|
|
||||||
uint decode_bit(uint handle)
|
|
||||||
{
|
|
||||||
//uint bitID = 1;
|
|
||||||
//for (uint currentDepth = 0; currentDepth < WAVE_TREE_DEPTH; ++currentDepth)
|
|
||||||
//{
|
|
||||||
// uint heapValue = get_heap_element(2 * bitID);
|
|
||||||
// uint b = handle < heapValue ? 0 : 1;
|
|
||||||
//
|
|
||||||
// bitID = 2 * bitID + b;
|
|
||||||
// handle -= heapValue * b;
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//return (bitID ^ OCBT_NUM_ELEMENTS);
|
|
||||||
|
|
||||||
for(uint i = 0; i < OCBT_NUM_ELEMENTS; ++i)
|
|
||||||
{
|
|
||||||
if(get_bit(i) == 1)
|
|
||||||
{
|
|
||||||
if(handle == 0)
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
handle--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// decodes the position of the i-th zero in the bitfield
|
// decodes the position of the i-th zero in the bitfield
|
||||||
uint decode_bit_complement(uint handle)
|
uint decode_bit_complement(uint handle, uint dispatchID)
|
||||||
{
|
{
|
||||||
//uint bitID = 1u;
|
uint temp = handle;
|
||||||
//uint c = OCBT_NUM_ELEMENTS / 2u;
|
DebugStruct debug;
|
||||||
//
|
uint x = 0;
|
||||||
//while (bitID < OCBT_NUM_ELEMENTS) {
|
uint bitID = 1u;
|
||||||
// uint heapValue = c - get_heap_element(2u * bitID);
|
uint c = OCBT_NUM_ELEMENTS / 2u;
|
||||||
// uint b = handle < heapValue ? 0u : 1u;
|
|
||||||
//
|
while (bitID < OCBT_NUM_ELEMENTS) {
|
||||||
// bitID = 2u * bitID + b;
|
uint heapValue = c - get_heap_element(2u * bitID, debug.heapValues[x++]);
|
||||||
// handle -= heapValue * b;
|
uint b = handle < heapValue ? 0u : 1u;
|
||||||
// c /= 2u;
|
|
||||||
//}
|
bitID = 2u * bitID + b;
|
||||||
//
|
handle -= heapValue * b;
|
||||||
//return (bitID ^ OCBT_NUM_ELEMENTS);
|
c /= 2u;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint result = (bitID ^ OCBT_NUM_ELEMENTS);
|
||||||
|
handle = temp;
|
||||||
for(uint i = 0; i < OCBT_NUM_ELEMENTS; ++i)
|
for(uint i = 0; i < OCBT_NUM_ELEMENTS; ++i)
|
||||||
{
|
{
|
||||||
if(get_bit(i) == 0)
|
if(get_bit(i) == 0)
|
||||||
{
|
{
|
||||||
if(handle == 0)
|
if(handle == 0)
|
||||||
{
|
{
|
||||||
|
pParams.debugBuffer[dispatchID] = debug;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
handle--;
|
handle--;
|
||||||
@@ -284,6 +268,7 @@ uint decode_bit_complement(uint handle)
|
|||||||
|
|
||||||
void reduce(uint groupIndex)
|
void reduce(uint groupIndex)
|
||||||
{
|
{
|
||||||
|
HeapDebug debug;
|
||||||
// First we do a reduction until each lane has exactly one element to process
|
// First we do a reduction until each lane has exactly one element to process
|
||||||
uint initial_pass_size = OCBT_NUM_ELEMENTS / WORKGROUP_SIZE;
|
uint initial_pass_size = OCBT_NUM_ELEMENTS / WORKGROUP_SIZE;
|
||||||
for (uint it = initial_pass_size / 64, offset = OCBT_NUM_ELEMENTS / 64; it > 0 ; it >>=1, offset >>=1)
|
for (uint it = initial_pass_size / 64, offset = OCBT_NUM_ELEMENTS / 64; it > 0 ; it >>=1, offset >>=1)
|
||||||
@@ -293,7 +278,7 @@ void reduce(uint groupIndex)
|
|||||||
|
|
||||||
for (uint heapID = minHeapID; heapID < maxHeapID; ++heapID)
|
for (uint heapID = minHeapID; heapID < maxHeapID; ++heapID)
|
||||||
{
|
{
|
||||||
set_heap_element(heapID, get_heap_element(heapID * 2) + get_heap_element(heapID * 2 + 1));
|
set_heap_element(heapID, get_heap_element(heapID * 2, debug) + get_heap_element(heapID * 2 + 1, debug));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GroupMemoryBarrierWithGroupSync();
|
GroupMemoryBarrierWithGroupSync();
|
||||||
@@ -303,7 +288,7 @@ void reduce(uint groupIndex)
|
|||||||
if (groupIndex < s)
|
if (groupIndex < s)
|
||||||
{
|
{
|
||||||
uint v = s + groupIndex;
|
uint v = s + groupIndex;
|
||||||
set_heap_element(v, get_heap_element(v * 2) + get_heap_element(v * 2 + 1));
|
set_heap_element(v, get_heap_element(v * 2, debug) + get_heap_element(v * 2 + 1, debug));
|
||||||
}
|
}
|
||||||
GroupMemoryBarrierWithGroupSync();
|
GroupMemoryBarrierWithGroupSync();
|
||||||
}
|
}
|
||||||
@@ -338,6 +323,7 @@ void reduce_prepass(uint dispatchThreadID)
|
|||||||
|
|
||||||
void reduce_first_pass(uint dispatchThreadID, uint groupIndex)
|
void reduce_first_pass(uint dispatchThreadID, uint groupIndex)
|
||||||
{
|
{
|
||||||
|
HeapDebug debug;
|
||||||
// Load the lowest level (and only the last level)
|
// Load the lowest level (and only the last level)
|
||||||
const uint level0Offset = OCBT_depth_offset[TREE_LAST_LEVEL] / 32;
|
const uint level0Offset = OCBT_depth_offset[TREE_LAST_LEVEL] / 32;
|
||||||
if (groupIndex % 2 == 0)
|
if (groupIndex % 2 == 0)
|
||||||
@@ -355,13 +341,13 @@ void reduce_first_pass(uint dispatchThreadID, uint groupIndex)
|
|||||||
|
|
||||||
for (uint heapID = minHeapID; heapID < maxHeapID; ++heapID)
|
for (uint heapID = minHeapID; heapID < maxHeapID; ++heapID)
|
||||||
{
|
{
|
||||||
set_heap_element(heapID, get_heap_element(heapID * 2) + get_heap_element(heapID * 2 + 1));
|
set_heap_element(heapID, get_heap_element(heapID * 2, debug) + get_heap_element(heapID * 2 + 1, debug));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Last pass needs to be atomic
|
// Last pass needs to be atomic
|
||||||
uint heapID = offset + (dispatchThreadID * it);
|
uint heapID = offset + (dispatchThreadID * it);
|
||||||
set_heap_element_atomic(heapID, get_heap_element(heapID * 2) + get_heap_element(heapID * 2 + 1));
|
set_heap_element_atomic(heapID, get_heap_element(heapID * 2, debug) + get_heap_element(heapID * 2 + 1, debug));
|
||||||
|
|
||||||
GroupMemoryBarrierWithGroupSync();
|
GroupMemoryBarrierWithGroupSync();
|
||||||
|
|
||||||
@@ -376,6 +362,7 @@ void reduce_first_pass(uint dispatchThreadID, uint groupIndex)
|
|||||||
|
|
||||||
void reduce_second_pass(uint groupIndex)
|
void reduce_second_pass(uint groupIndex)
|
||||||
{
|
{
|
||||||
|
HeapDebug debug;
|
||||||
// Load the lowest level (and only the last level)
|
// Load the lowest level (and only the last level)
|
||||||
const uint level0Offset = OCBT_depth_offset[9] / 32;
|
const uint level0Offset = OCBT_depth_offset[9] / 32;
|
||||||
for (uint e = 0; e < 4; ++e)
|
for (uint e = 0; e < 4; ++e)
|
||||||
@@ -394,7 +381,7 @@ void reduce_second_pass(uint groupIndex)
|
|||||||
|
|
||||||
for (uint heapID = minHeapID; heapID < maxHeapID; ++heapID)
|
for (uint heapID = minHeapID; heapID < maxHeapID; ++heapID)
|
||||||
{
|
{
|
||||||
set_heap_element(heapID, get_heap_element(heapID * 2) + get_heap_element(heapID * 2 + 1));
|
set_heap_element(heapID, get_heap_element(heapID * 2, debug) + get_heap_element(heapID * 2 + 1, debug));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GroupMemoryBarrierWithGroupSync();
|
GroupMemoryBarrierWithGroupSync();
|
||||||
@@ -404,7 +391,7 @@ void reduce_second_pass(uint groupIndex)
|
|||||||
if (groupIndex < s)
|
if (groupIndex < s)
|
||||||
{
|
{
|
||||||
uint v = s + groupIndex;
|
uint v = s + groupIndex;
|
||||||
set_heap_element(v, get_heap_element(v * 2) + get_heap_element(v * 2 + 1));
|
set_heap_element(v, get_heap_element(v * 2, debug) + get_heap_element(v * 2 + 1, debug));
|
||||||
}
|
}
|
||||||
GroupMemoryBarrierWithGroupSync();
|
GroupMemoryBarrierWithGroupSync();
|
||||||
}
|
}
|
||||||
@@ -423,6 +410,7 @@ void reduce_second_pass(uint groupIndex)
|
|||||||
|
|
||||||
void reduce_no_bitfield(uint groupIndex)
|
void reduce_no_bitfield(uint groupIndex)
|
||||||
{
|
{
|
||||||
|
HeapDebug debug;
|
||||||
// First we do a reduction until each lane has exactly one element to process
|
// First we do a reduction until each lane has exactly one element to process
|
||||||
uint initial_pass_size = OCBT_NUM_ELEMENTS / WORKGROUP_SIZE;
|
uint initial_pass_size = OCBT_NUM_ELEMENTS / WORKGROUP_SIZE;
|
||||||
for (uint it = initial_pass_size / 128, offset = OCBT_NUM_ELEMENTS / 128; it > 0 ; it >>=1, offset >>=1)
|
for (uint it = initial_pass_size / 128, offset = OCBT_NUM_ELEMENTS / 128; it > 0 ; it >>=1, offset >>=1)
|
||||||
@@ -432,7 +420,7 @@ void reduce_no_bitfield(uint groupIndex)
|
|||||||
|
|
||||||
for (uint heapID = minHeapID; heapID < maxHeapID; ++heapID)
|
for (uint heapID = minHeapID; heapID < maxHeapID; ++heapID)
|
||||||
{
|
{
|
||||||
set_heap_element(heapID, get_heap_element(heapID * 2) + get_heap_element(heapID * 2 + 1));
|
set_heap_element(heapID, get_heap_element(heapID * 2, debug) + get_heap_element(heapID * 2 + 1, debug));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GroupMemoryBarrierWithGroupSync();
|
GroupMemoryBarrierWithGroupSync();
|
||||||
@@ -442,7 +430,7 @@ void reduce_no_bitfield(uint groupIndex)
|
|||||||
if (groupIndex < s)
|
if (groupIndex < s)
|
||||||
{
|
{
|
||||||
uint v = s + groupIndex;
|
uint v = s + groupIndex;
|
||||||
set_heap_element(v, get_heap_element(v * 2) + get_heap_element(v * 2 + 1));
|
set_heap_element(v, get_heap_element(v * 2, debug) + get_heap_element(v * 2 + 1, debug));
|
||||||
}
|
}
|
||||||
GroupMemoryBarrierWithGroupSync();
|
GroupMemoryBarrierWithGroupSync();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ void Allocate(uint groupIndex : SV_GroupIndex, uint dispatchID : SV_DispatchThre
|
|||||||
//for(uint i = 0; i < pParams.allocateBuffer[0]; ++i)
|
//for(uint i = 0; i < pParams.allocateBuffer[0]; ++i)
|
||||||
//{
|
//{
|
||||||
// Allocate the required bits
|
// Allocate the required bits
|
||||||
AllocateElement(pParams.allocateBuffer[1 + dispatchID]);
|
AllocateElement(pParams.allocateBuffer[1 + dispatchID], dispatchID);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -310,9 +310,9 @@ void EvaluateLEB(uint currentID : SV_DispatchThreadID, uint groupIndex: SV_Group
|
|||||||
EvaluateElementPosition(cHeapID, 0, pParams.geometry.baseDepth, pParams.currentVertexBuffer, parentTri, childTri);
|
EvaluateElementPosition(cHeapID, 0, pParams.geometry.baseDepth, pParams.currentVertexBuffer, parentTri, childTri);
|
||||||
|
|
||||||
// Export the child
|
// Export the child
|
||||||
pParams.lebPositionBuffer[3 * currentID + 0] = float4(1000 * (childTri.p[0]), 1.0f);
|
pParams.lebPositionBuffer[3 * currentID + 0] = float4((childTri.p[0]), 1.0f);
|
||||||
pParams.lebPositionBuffer[3 * currentID + 1] = float4(1000 * (childTri.p[1]), 1.0f);
|
pParams.lebPositionBuffer[3 * currentID + 1] = float4((childTri.p[1]), 1.0f);
|
||||||
pParams.lebPositionBuffer[3 * currentID + 2] = float4(1000 * (childTri.p[2]), 1.0f);
|
pParams.lebPositionBuffer[3 * currentID + 2] = float4((childTri.p[2]), 1.0f);
|
||||||
|
|
||||||
// Export the fourth element
|
// Export the fourth element
|
||||||
if (pParams.geometry.baseDepth < depth)
|
if (pParams.geometry.baseDepth < depth)
|
||||||
@@ -321,6 +321,6 @@ void EvaluateLEB(uint currentID : SV_DispatchThreadID, uint groupIndex: SV_Group
|
|||||||
const uint parentOffset = 3 * pParams.geometry.totalNumElements;
|
const uint parentOffset = 3 * pParams.geometry.totalNumElements;
|
||||||
|
|
||||||
// Transform the coordinate to planet space
|
// Transform the coordinate to planet space
|
||||||
pParams.lebPositionBuffer[parentOffset + currentID] = float4(1000 * (cHeapID % 2 == 0 ? parentTri.p[0] : parentTri.p[2]), 1.0f);
|
pParams.lebPositionBuffer[parentOffset + currentID] = float4((cHeapID % 2 == 0 ? parentTri.p[0] : parentTri.p[2]), 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,13 +26,19 @@ struct UpdateCB
|
|||||||
float farPlaneDistance;
|
float farPlaneDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct HeapDebug
|
||||||
|
{
|
||||||
|
uint id;
|
||||||
|
uint real_heap_id;
|
||||||
|
uint depth;
|
||||||
|
uint level_first_element;
|
||||||
|
uint id_in_level;
|
||||||
|
uint first_bit;
|
||||||
|
};
|
||||||
|
|
||||||
struct DebugStruct
|
struct DebugStruct
|
||||||
{
|
{
|
||||||
uint4 indices;
|
HeapDebug heapValues[18];
|
||||||
uint baseHeapID;
|
|
||||||
uint subdivision;
|
|
||||||
uint propagateLocation;
|
|
||||||
uint numSiblings;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ void SplitElement(uint currentID, uint baseDepth)
|
|||||||
InterlockedAdd(pParams.memoryBuffer[1], maxRequiredMemory - usedMemory, remainingMemory);
|
InterlockedAdd(pParams.memoryBuffer[1], maxRequiredMemory - usedMemory, remainingMemory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AllocateElement(uint currentID)
|
void AllocateElement(uint currentID, uint dispatchID)
|
||||||
{
|
{
|
||||||
// Load the bisector for this element
|
// Load the bisector for this element
|
||||||
BisectorData bisectorData = pParams.bisectorDataBuffer[currentID];
|
BisectorData bisectorData = pParams.bisectorDataBuffer[currentID];
|
||||||
@@ -338,7 +338,7 @@ void AllocateElement(uint currentID)
|
|||||||
// llocate the bits we need
|
// llocate the bits we need
|
||||||
for (uint bitId = 0; bitId < numSlots; ++bitId)
|
for (uint bitId = 0; bitId < numSlots; ++bitId)
|
||||||
{
|
{
|
||||||
bisectorData.indices[bitId] = decode_bit_complement(firstBitIndex + bitId);
|
bisectorData.indices[bitId] = decode_bit_complement(firstBitIndex + bitId, dispatchID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ int main(int argc, char** argv) {
|
|||||||
useDepthCulling = false;
|
useDepthCulling = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::filesystem::path binaryPath = "C:/Users/Dynamitos/MeshShadingDemo/bin/MeshShadingDemo.dll";
|
std::filesystem::path binaryPath = "MeshShadingDemo.dll";
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
graphics = new Metal::Graphics();
|
graphics = new Metal::Graphics();
|
||||||
@@ -40,7 +40,7 @@ int main(int argc, char** argv) {
|
|||||||
vd->init(graphics);
|
vd->init(graphics);
|
||||||
|
|
||||||
OWindowManager windowManager = new WindowManager();
|
OWindowManager windowManager = new WindowManager();
|
||||||
AssetRegistry::init("C:/Users/Dynamitos/MeshShadingDemo/Assets", graphics);
|
AssetRegistry::init("Assets", graphics);
|
||||||
vd->commitMeshes();
|
vd->commitMeshes();
|
||||||
WindowCreateInfo mainWindowInfo = {
|
WindowCreateInfo mainWindowInfo = {
|
||||||
.width = 1920,
|
.width = 1920,
|
||||||
|
|||||||
@@ -111,12 +111,12 @@ void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset) {
|
|||||||
ktxBasisParams basisParams = {
|
ktxBasisParams basisParams = {
|
||||||
.structSize = sizeof(ktxBasisParams),
|
.structSize = sizeof(ktxBasisParams),
|
||||||
.uastc = true,
|
.uastc = true,
|
||||||
.threadCount = 1,
|
.threadCount = 14,
|
||||||
.uastcFlags = KTX_PACK_UASTC_LEVEL_FASTER,
|
.uastcFlags = KTX_PACK_UASTC_LEVEL_FASTER,
|
||||||
.uastcRDO = true,
|
.uastcRDO = true,
|
||||||
};
|
};
|
||||||
//KTX_ASSERT(ktxTexture2_CompressBasisEx(kTexture, &basisParams));
|
KTX_ASSERT(ktxTexture2_CompressBasisEx(kTexture, &basisParams));
|
||||||
//KTX_ASSERT(ktxTexture2_DeflateZstd(kTexture, 20));
|
KTX_ASSERT(ktxTexture2_DeflateZstd(kTexture, 20));
|
||||||
|
|
||||||
char writer[100];
|
char writer[100];
|
||||||
snprintf(writer, sizeof(writer), "%s version %s", "SeeleEngine", "0.0.1");
|
snprintf(writer, sizeof(writer), "%s version %s", "SeeleEngine", "0.0.1");
|
||||||
|
|||||||
@@ -5,16 +5,16 @@
|
|||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
Array<Vector4> basePoints = {
|
Array<Vector4> basePoints = {
|
||||||
Vector4(0.0f / 3, 0, 0.0f / 3, 1), Vector4(0.0f / 3, 0, 1.0f / 3, 1), Vector4(0.0f / 3, 0, 2.0f / 3, 1),
|
//Vector4(0.0f / 3, 0, 0.0f / 3, 1), Vector4(0.0f / 3, 0, 1.0f / 3, 1), Vector4(0.0f / 3, 0, 2.0f / 3, 1),
|
||||||
Vector4(0.0f / 3, 0, 3.0f / 3, 1), Vector4(1.0f / 3, 0, 0.0f / 3, 1), Vector4(1.0f / 3, 0, 1.0f / 3, 1),
|
//Vector4(0.0f / 3, 0, 3.0f / 3, 1), Vector4(1.0f / 3, 0, 0.0f / 3, 1), Vector4(1.0f / 3, 0, 1.0f / 3, 1),
|
||||||
Vector4(1.0f / 3, 0, 2.0f / 3, 1), Vector4(1.0f / 3, 0, 3.0f / 3, 1), Vector4(2.0f / 3, 0, 0.0f / 3, 1),
|
//Vector4(1.0f / 3, 0, 2.0f / 3, 1), Vector4(1.0f / 3, 0, 3.0f / 3, 1), Vector4(2.0f / 3, 0, 0.0f / 3, 1),
|
||||||
Vector4(2.0f / 3, 0, 1.0f / 3, 1), Vector4(2.0f / 3, 0, 2.0f / 3, 1), Vector4(2.0f / 3, 0, 3.0f / 3, 1),
|
//Vector4(2.0f / 3, 0, 1.0f / 3, 1), Vector4(2.0f / 3, 0, 2.0f / 3, 1), Vector4(2.0f / 3, 0, 3.0f / 3, 1),
|
||||||
Vector4(3.0f / 3, 0, 0.0f / 3, 1), Vector4(3.0f / 3, 0, 1.0f / 3, 1), Vector4(3.0f / 3, 0, 2.0f / 3, 1),
|
//Vector4(3.0f / 3, 0, 0.0f / 3, 1), Vector4(3.0f / 3, 0, 1.0f / 3, 1), Vector4(3.0f / 3, 0, 2.0f / 3, 1),
|
||||||
Vector4(3.0f / 3, 0, 3.0f / 3, 1),
|
//Vector4(3.0f / 3, 0, 3.0f / 3, 1),
|
||||||
// Vector4(0, -0.525731, 0.850651, 1), Vector4(0.850651, 0, 0.525731, 1), Vector4(0.850651, 0, -0.525731, 1),
|
Vector4(0, -0.525731, 0.850651, 1), Vector4(0.850651, 0, 0.525731, 1), Vector4(0.850651, 0, -0.525731, 1),
|
||||||
// Vector4(-0.850651, 0, -0.525731, 1), Vector4(-0.850651, 0, 0.525731, 1), Vector4(-0.525731, 0.850651, 0, 1),
|
Vector4(-0.850651, 0, -0.525731, 1), Vector4(-0.850651, 0, 0.525731, 1), Vector4(-0.525731, 0.850651, 0, 1),
|
||||||
// Vector4(0.525731, 0.850651, 0, 1), Vector4(0.525731, -0.850651, 0, 1), Vector4(-0.525731, -0.850651, 0, 1),
|
Vector4(0.525731, 0.850651, 0, 1), Vector4(0.525731, -0.850651, 0, 1), Vector4(-0.525731, -0.850651, 0, 1),
|
||||||
// Vector4(0, -0.525731, -0.850651, 1), Vector4(0, 0.525731, -0.850651, 1), Vector4(0, 0.525731, 0.850651, 1),
|
Vector4(0, -0.525731, -0.850651, 1), Vector4(0, 0.525731, -0.850651, 1), Vector4(0, 0.525731, 0.850651, 1),
|
||||||
};
|
};
|
||||||
struct Halfedge {
|
struct Halfedge {
|
||||||
uint32 vertexID;
|
uint32 vertexID;
|
||||||
@@ -23,90 +23,90 @@ struct Halfedge {
|
|||||||
uint32 twinID;
|
uint32 twinID;
|
||||||
};
|
};
|
||||||
Array<Halfedge> edges = {
|
Array<Halfedge> edges = {
|
||||||
Halfedge{0, 1, 2, 4294967295},
|
//Halfedge{0, 1, 2, 4294967295},
|
||||||
Halfedge{4, 2, 0, 3},
|
//Halfedge{4, 2, 0, 3},
|
||||||
Halfedge{1, 0, 1, 4294967295},
|
//Halfedge{1, 0, 1, 4294967295},
|
||||||
|
//
|
||||||
|
//Halfedge{4, 4, 5, 1},
|
||||||
|
//Halfedge{5, 5, 3, 8},
|
||||||
|
//Halfedge{1, 3, 4, 18},
|
||||||
|
//
|
||||||
|
//Halfedge{1, 7, 8, 4294967295},
|
||||||
|
//Halfedge{5, 8, 6, 9},
|
||||||
|
//Halfedge{2, 6, 7, 4},
|
||||||
|
//
|
||||||
|
//Halfedge{5, 10, 11, 7},
|
||||||
|
//Halfedge{6, 11, 9, 14},
|
||||||
|
//Halfedge{2, 9, 10, 24},
|
||||||
|
//
|
||||||
|
//Halfedge{2, 13, 14, 4294967295},
|
||||||
|
//Halfedge{6, 14, 12, 15},
|
||||||
|
//Halfedge{3, 12, 13, 10},
|
||||||
|
//
|
||||||
|
//Halfedge{6, 16, 17, 13},
|
||||||
|
//Halfedge{7, 17, 15, 4294967295},
|
||||||
|
//Halfedge{3, 15, 16, 30},
|
||||||
|
//
|
||||||
|
//Halfedge{4, 19, 20, 5},
|
||||||
|
//Halfedge{8, 20, 18, 21},
|
||||||
|
//Halfedge{5, 18, 19, 4294967295},
|
||||||
|
//
|
||||||
|
//Halfedge{8, 22, 23, 19},
|
||||||
|
//Halfedge{9, 23, 21, 26},
|
||||||
|
//Halfedge{5, 21, 22, 36},
|
||||||
|
//
|
||||||
|
//Halfedge{5, 25, 26, 11},
|
||||||
|
//Halfedge{9, 26, 24, 27},
|
||||||
|
//Halfedge{6, 24, 25, 22},
|
||||||
|
//
|
||||||
|
//Halfedge{9, 28, 29, 25},
|
||||||
|
//Halfedge{10, 29, 27, 32},
|
||||||
|
//Halfedge{6, 27, 28, 42},
|
||||||
|
//
|
||||||
|
//Halfedge{6, 31, 32, 17},
|
||||||
|
//Halfedge{10, 32, 30, 33},
|
||||||
|
//Halfedge{7, 30, 31, 28},
|
||||||
|
//
|
||||||
|
//Halfedge{10, 34, 35, 31},
|
||||||
|
//Halfedge{11, 35, 33, 4294967295},
|
||||||
|
//Halfedge{7, 33, 34, 48},
|
||||||
|
//
|
||||||
|
//Halfedge{8, 37, 38, 23},
|
||||||
|
//Halfedge{12, 38, 36, 39},
|
||||||
|
//Halfedge{9, 36, 37, 4294967295},
|
||||||
|
//
|
||||||
|
//Halfedge{12, 40, 41, 37},
|
||||||
|
//Halfedge{13, 41, 39, 44},
|
||||||
|
//Halfedge{9, 39, 40, 4294967295},
|
||||||
|
//
|
||||||
|
//Halfedge{9, 43, 44, 29},
|
||||||
|
//Halfedge{13, 44, 42, 45},
|
||||||
|
//Halfedge{10, 42, 43, 40},
|
||||||
|
//
|
||||||
|
//Halfedge{13, 46, 47, 43},
|
||||||
|
//Halfedge{14, 47, 45, 50},
|
||||||
|
//Halfedge{10, 45, 46, 4294967295},
|
||||||
|
//
|
||||||
|
//Halfedge{10, 49, 50, 35},
|
||||||
|
//Halfedge{14, 50, 48, 51},
|
||||||
|
//Halfedge{11, 48, 49, 46},
|
||||||
|
//
|
||||||
|
//Halfedge{14, 52, 53, 49},
|
||||||
|
//Halfedge{15, 53, 51, 4294967295},
|
||||||
|
//Halfedge{11, 51, 52, 4294967295},
|
||||||
|
|
||||||
Halfedge{4, 4, 5, 1},
|
Halfedge{1, 1, 2, 5}, Halfedge{2, 2, 0, 36}, Halfedge{6, 0, 1, 39}, Halfedge{1, 4, 5, 51}, Halfedge{7, 5, 3, 48},
|
||||||
Halfedge{5, 5, 3, 8},
|
Halfedge{2, 3, 4, 0}, Halfedge{3, 7, 8, 9}, Halfedge{4, 8, 6, 45}, Halfedge{5, 6, 7, 42}, Halfedge{4, 10, 11, 6},
|
||||||
Halfedge{1, 3, 4, 18},
|
Halfedge{3, 11, 9, 56}, Halfedge{8, 9, 10, 57}, Halfedge{6, 13, 14, 15}, Halfedge{5, 14, 12, 47}, Halfedge{11, 12, 13, 40},
|
||||||
|
Halfedge{5, 16, 17, 12}, Halfedge{6, 17, 15, 38}, Halfedge{10, 15, 16, 43}, Halfedge{9, 19, 20, 21}, Halfedge{10, 20, 18, 37},
|
||||||
Halfedge{1, 7, 8, 4294967295},
|
Halfedge{2, 18, 19, 50}, Halfedge{10, 22, 23, 18}, Halfedge{9, 23, 21, 54}, Halfedge{3, 21, 22, 44}, Halfedge{7, 25, 26, 27},
|
||||||
Halfedge{5, 8, 6, 9},
|
Halfedge{8, 26, 24, 55}, Halfedge{9, 24, 25, 49}, Halfedge{8, 28, 29, 24}, Halfedge{7, 29, 27, 53}, Halfedge{0, 27, 28, 58},
|
||||||
Halfedge{2, 6, 7, 4},
|
Halfedge{11, 31, 32, 33}, Halfedge{0, 32, 30, 52}, Halfedge{1, 30, 31, 41}, Halfedge{0, 34, 35, 30}, Halfedge{11, 35, 33, 46},
|
||||||
|
Halfedge{4, 33, 34, 59}, Halfedge{6, 37, 38, 1}, Halfedge{2, 38, 36, 19}, Halfedge{10, 36, 37, 16}, Halfedge{1, 40, 41, 2},
|
||||||
Halfedge{5, 10, 11, 7},
|
Halfedge{6, 41, 39, 14}, Halfedge{11, 39, 40, 32}, Halfedge{3, 43, 44, 8}, Halfedge{5, 44, 42, 17}, Halfedge{10, 42, 43, 23},
|
||||||
Halfedge{6, 11, 9, 14},
|
Halfedge{5, 46, 47, 7}, Halfedge{4, 47, 45, 34}, Halfedge{11, 45, 46, 13}, Halfedge{2, 49, 50, 4}, Halfedge{7, 50, 48, 26},
|
||||||
Halfedge{2, 9, 10, 24},
|
Halfedge{9, 48, 49, 20}, Halfedge{7, 52, 53, 3}, Halfedge{1, 53, 51, 31}, Halfedge{0, 51, 52, 28}, Halfedge{3, 55, 56, 22},
|
||||||
|
Halfedge{9, 56, 54, 25}, Halfedge{8, 54, 55, 10}, Halfedge{4, 58, 59, 11}, Halfedge{8, 59, 57, 29}, Halfedge{0, 57, 58, 35},
|
||||||
Halfedge{2, 13, 14, 4294967295},
|
|
||||||
Halfedge{6, 14, 12, 15},
|
|
||||||
Halfedge{3, 12, 13, 10},
|
|
||||||
|
|
||||||
Halfedge{6, 16, 17, 13},
|
|
||||||
Halfedge{7, 17, 15, 4294967295},
|
|
||||||
Halfedge{3, 15, 16, 30},
|
|
||||||
|
|
||||||
Halfedge{4, 19, 20, 5},
|
|
||||||
Halfedge{8, 20, 18, 21},
|
|
||||||
Halfedge{5, 18, 19, 4294967295},
|
|
||||||
|
|
||||||
Halfedge{8, 22, 23, 19},
|
|
||||||
Halfedge{9, 23, 21, 26},
|
|
||||||
Halfedge{5, 21, 22, 36},
|
|
||||||
|
|
||||||
Halfedge{5, 25, 26, 11},
|
|
||||||
Halfedge{9, 26, 24, 27},
|
|
||||||
Halfedge{6, 24, 25, 22},
|
|
||||||
|
|
||||||
Halfedge{9, 28, 29, 25},
|
|
||||||
Halfedge{10, 29, 27, 32},
|
|
||||||
Halfedge{6, 27, 28, 42},
|
|
||||||
|
|
||||||
Halfedge{6, 31, 32, 17},
|
|
||||||
Halfedge{10, 32, 30, 33},
|
|
||||||
Halfedge{7, 30, 31, 28},
|
|
||||||
|
|
||||||
Halfedge{10, 34, 35, 31},
|
|
||||||
Halfedge{11, 35, 33, 4294967295},
|
|
||||||
Halfedge{7, 33, 34, 48},
|
|
||||||
|
|
||||||
Halfedge{8, 37, 38, 23},
|
|
||||||
Halfedge{12, 38, 36, 39},
|
|
||||||
Halfedge{9, 36, 37, 4294967295},
|
|
||||||
|
|
||||||
Halfedge{12, 40, 41, 37},
|
|
||||||
Halfedge{13, 41, 39, 44},
|
|
||||||
Halfedge{9, 39, 40, 4294967295},
|
|
||||||
|
|
||||||
Halfedge{9, 43, 44, 29},
|
|
||||||
Halfedge{13, 44, 42, 45},
|
|
||||||
Halfedge{10, 42, 43, 40},
|
|
||||||
|
|
||||||
Halfedge{13, 46, 47, 43},
|
|
||||||
Halfedge{14, 47, 45, 50},
|
|
||||||
Halfedge{10, 45, 46, 4294967295},
|
|
||||||
|
|
||||||
Halfedge{10, 49, 50, 35},
|
|
||||||
Halfedge{14, 50, 48, 51},
|
|
||||||
Halfedge{11, 48, 49, 46},
|
|
||||||
|
|
||||||
Halfedge{14, 52, 53, 49},
|
|
||||||
Halfedge{15, 53, 51, 4294967295},
|
|
||||||
Halfedge{11, 51, 52, 4294967295},
|
|
||||||
|
|
||||||
// Halfedge{1, 1, 2, 5}, Halfedge{2, 2, 0, 36}, Halfedge{6, 0, 1, 39}, Halfedge{1, 4, 5, 51}, Halfedge{7, 5, 3, 48},
|
|
||||||
// Halfedge{2, 3, 4, 0}, Halfedge{3, 7, 8, 9}, Halfedge{4, 8, 6, 45}, Halfedge{5, 6, 7, 42}, Halfedge{4, 10, 11, 6},
|
|
||||||
// Halfedge{3, 11, 9, 56}, Halfedge{8, 9, 10, 57}, Halfedge{6, 13, 14, 15}, Halfedge{5, 14, 12, 47}, Halfedge{11, 12, 13, 40},
|
|
||||||
// Halfedge{5, 16, 17, 12}, Halfedge{6, 17, 15, 38}, Halfedge{10, 15, 16, 43}, Halfedge{9, 19, 20, 21}, Halfedge{10, 20, 18, 37},
|
|
||||||
// Halfedge{2, 18, 19, 50}, Halfedge{10, 22, 23, 18}, Halfedge{9, 23, 21, 54}, Halfedge{3, 21, 22, 44}, Halfedge{7, 25, 26, 27},
|
|
||||||
// Halfedge{8, 26, 24, 55}, Halfedge{9, 24, 25, 49}, Halfedge{8, 28, 29, 24}, Halfedge{7, 29, 27, 53}, Halfedge{0, 27, 28, 58},
|
|
||||||
// Halfedge{11, 31, 32, 33}, Halfedge{0, 32, 30, 52}, Halfedge{1, 30, 31, 41}, Halfedge{0, 34, 35, 30}, Halfedge{11, 35, 33, 46},
|
|
||||||
// Halfedge{4, 33, 34, 59}, Halfedge{6, 37, 38, 1}, Halfedge{2, 38, 36, 19}, Halfedge{10, 36, 37, 16}, Halfedge{1, 40, 41, 2},
|
|
||||||
// Halfedge{6, 41, 39, 14}, Halfedge{11, 39, 40, 32}, Halfedge{3, 43, 44, 8}, Halfedge{5, 44, 42, 17}, Halfedge{10, 42, 43, 23},
|
|
||||||
// Halfedge{5, 46, 47, 7}, Halfedge{4, 47, 45, 34}, Halfedge{11, 45, 46, 13}, Halfedge{2, 49, 50, 4}, Halfedge{7, 50, 48, 26},
|
|
||||||
// Halfedge{9, 48, 49, 20}, Halfedge{7, 52, 53, 3}, Halfedge{1, 53, 51, 31}, Halfedge{0, 51, 52, 28}, Halfedge{3, 55, 56, 22},
|
|
||||||
// Halfedge{9, 56, 54, 25}, Halfedge{8, 54, 55, 10}, Halfedge{4, 58, 59, 11}, Halfedge{8, 59, 57, 29}, Halfedge{0, 57, 58, 35},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t find_msb_64(uint64_t x) {
|
uint32_t find_msb_64(uint64_t x) {
|
||||||
@@ -291,7 +291,7 @@ void MeshUpdater::init(Gfx::PGraphics gfx, Gfx::PDescriptorLayout viewParamsLayo
|
|||||||
debugBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
debugBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||||
.sourceData =
|
.sourceData =
|
||||||
{
|
{
|
||||||
.size = 100000,
|
.size = 1000000,
|
||||||
},
|
},
|
||||||
.name = "DebugBuffer",
|
.name = "DebugBuffer",
|
||||||
});
|
});
|
||||||
@@ -560,6 +560,7 @@ void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::
|
|||||||
set->updateBuffer(ALLOCATE_BUFFER, 0, mesh.allocateBuffer);
|
set->updateBuffer(ALLOCATE_BUFFER, 0, mesh.allocateBuffer);
|
||||||
set->updateBuffer(BISECTOR_DATA_BUFFER, 0, mesh.updateBuffer);
|
set->updateBuffer(BISECTOR_DATA_BUFFER, 0, mesh.updateBuffer);
|
||||||
set->updateBuffer(MEMORY_BUFFER, 0, memoryBuffer);
|
set->updateBuffer(MEMORY_BUFFER, 0, memoryBuffer);
|
||||||
|
set->updateBuffer(DEBUG_BUFFER, 0, debugBuffer);
|
||||||
set->writeChanges();
|
set->writeChanges();
|
||||||
Gfx::OComputeCommand allocateCmd = graphics->createComputeCommand("Allocate");
|
Gfx::OComputeCommand allocateCmd = graphics->createComputeCommand("Allocate");
|
||||||
allocateCmd->bindPipeline(allocate);
|
allocateCmd->bindPipeline(allocate);
|
||||||
@@ -595,7 +596,6 @@ void MeshUpdater::update(CBTMesh& mesh, Gfx::PDescriptorSet viewParamsSet, Gfx::
|
|||||||
set->updateBuffer(NEIGHBOURS_BUFFER, 0, currentNeighborsBuffer);
|
set->updateBuffer(NEIGHBOURS_BUFFER, 0, currentNeighborsBuffer);
|
||||||
set->updateBuffer(NEIGHBOURS_OUTPUT_BUFFER, 0, nextNeighborsBuffer);
|
set->updateBuffer(NEIGHBOURS_OUTPUT_BUFFER, 0, nextNeighborsBuffer);
|
||||||
set->updateBuffer(PROPAGATE_BUFFER, 0, mesh.propagateBuffer);
|
set->updateBuffer(PROPAGATE_BUFFER, 0, mesh.propagateBuffer);
|
||||||
set->updateBuffer(DEBUG_BUFFER, 0, debugBuffer);
|
|
||||||
set->writeChanges();
|
set->writeChanges();
|
||||||
Gfx::OComputeCommand bisectCmd = graphics->createComputeCommand("Bisect");
|
Gfx::OComputeCommand bisectCmd = graphics->createComputeCommand("Bisect");
|
||||||
bisectCmd->bindPipeline(bisect);
|
bisectCmd->bindPipeline(bisect);
|
||||||
|
|||||||
Reference in New Issue
Block a user