Everything is broken
This commit is contained in:
@@ -25,9 +25,9 @@ void computeFrustums(ComputeShaderInput in)
|
|||||||
frustum.sides[1] = computePlane(origin, corners[1], corners[3]);
|
frustum.sides[1] = computePlane(origin, corners[1], corners[3]);
|
||||||
frustum.sides[2] = computePlane(origin, corners[0], corners[1]);
|
frustum.sides[2] = computePlane(origin, corners[0], corners[1]);
|
||||||
frustum.sides[3] = computePlane(origin, corners[3], corners[2]);
|
frustum.sides[3] = computePlane(origin, corners[3], corners[2]);
|
||||||
if(in.dispatchThreadID.x < pDispatchParams.p.numThreads.x && in.dispatchThreadID.y < pDispatchParams.p.numThreads.y)
|
if(in.dispatchThreadID.x < pDispatchParams.numThreads.x && in.dispatchThreadID.y < pDispatchParams.numThreads.y)
|
||||||
{
|
{
|
||||||
uint index = in.dispatchThreadID.x + (in.dispatchThreadID.y * pDispatchParams.p.numThreads.x);
|
uint index = in.dispatchThreadID.x + (in.dispatchThreadID.y * pDispatchParams.numThreads.x);
|
||||||
pDispatchParams.frustums[index] = frustum;
|
pDispatchParams.frustums[index] = frustum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ Params vertexMain(
|
|||||||
DebugVertex vert
|
DebugVertex vert
|
||||||
){
|
){
|
||||||
Params result;
|
Params result;
|
||||||
result.pos = mul(pViewParams.c.projectionMatrix, mul(pViewParams.c.viewMatrix, float4(vert.position, 1)));
|
result.pos = mul(pViewParams.projectionMatrix, mul(pViewParams.viewMatrix, float4(vert.position, 1)));
|
||||||
result.color = vert.color;
|
result.color = vert.color;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,3 +17,4 @@ struct DepthData
|
|||||||
//globallycoherent RWStructuredBuffer<uint> debugHead;
|
//globallycoherent RWStructuredBuffer<uint> debugHead;
|
||||||
//globallycoherent RWStructuredBuffer<DepthDebugData> debugData;
|
//globallycoherent RWStructuredBuffer<DepthDebugData> debugData;
|
||||||
};
|
};
|
||||||
|
ParameterBlock<DepthData> pDepthAttachment;
|
||||||
|
|||||||
@@ -27,10 +27,9 @@ groupshared bool meshVisible;
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
ParameterBlock<DepthData> pDepthAttachment;
|
|
||||||
bool isBoxVisible(AABB bounding)
|
bool isBoxVisible(AABB bounding)
|
||||||
{
|
{
|
||||||
int2 mipDimensions = int2(int(pViewParams.c.screenDimensions.x), int(pViewParams.c.screenDimensions.y));
|
int2 mipDimensions = int2(int(pViewParams.screenDimensions.x), int(pViewParams.screenDimensions.y));
|
||||||
// now we calculate what mip level we need to only sample up to 4 texels covering the entire meshlet
|
// now we calculate what mip level we need to only sample up to 4 texels covering the entire meshlet
|
||||||
int2 screenCornerMin = mipDimensions;
|
int2 screenCornerMin = mipDimensions;
|
||||||
int2 screenCornerMax = int2(0, 0);
|
int2 screenCornerMax = int2(0, 0);
|
||||||
@@ -91,14 +90,14 @@ void taskMain(
|
|||||||
p.instanceId = pOffsets.instanceOffset + groupID;
|
p.instanceId = pOffsets.instanceOffset + groupID;
|
||||||
p.meshletOffset = mesh.meshletOffset;
|
p.meshletOffset = mesh.meshletOffset;
|
||||||
p.cullingOffset = pScene.cullingOffsets[p.instanceId];
|
p.cullingOffset = pScene.cullingOffsets[p.instanceId];
|
||||||
modelViewProjection = mul(mul(pViewParams.c.projectionMatrix, pViewParams.c.viewMatrix), instance.transformMatrix);
|
modelViewProjection = mul(mul(pViewParams.projectionMatrix, pViewParams.viewMatrix), instance.transformMatrix);
|
||||||
float3 origin = viewToModel(instance.inverseTransformMatrix, float4(0, 0, 0, 1)).xyz;
|
float3 origin = viewToModel(instance.inverseTransformMatrix, float4(0, 0, 0, 1)).xyz;
|
||||||
const float offset = 0.0f;
|
const float offset = 0.0f;
|
||||||
float3 corners[4] = {
|
float3 corners[4] = {
|
||||||
screenToModel(instance.inverseTransformMatrix, float4(offset, offset, -1.0f, 1.0f)).xyz,
|
screenToModel(instance.inverseTransformMatrix, float4(offset, offset, -1.0f, 1.0f)).xyz,
|
||||||
screenToModel(instance.inverseTransformMatrix, float4(pViewParams.c.screenDimensions.x - offset, offset, -1.0f, 1.0f)).xyz,
|
screenToModel(instance.inverseTransformMatrix, float4(pViewParams.screenDimensions.x - offset, offset, -1.0f, 1.0f)).xyz,
|
||||||
screenToModel(instance.inverseTransformMatrix, float4(offset, pViewParams.c.screenDimensions.y - offset, -1.0f, 1.0f)).xyz,
|
screenToModel(instance.inverseTransformMatrix, float4(offset, pViewParams.screenDimensions.y - offset, -1.0f, 1.0f)).xyz,
|
||||||
screenToModel(instance.inverseTransformMatrix, float4(pViewParams.c.screenDimensions - float2(offset, offset), -1.0f, 1.0f)).xyz
|
screenToModel(instance.inverseTransformMatrix, float4(pViewParams.screenDimensions - float2(offset, offset), -1.0f, 1.0f)).xyz
|
||||||
};
|
};
|
||||||
viewFrustum.sides[0] = computePlane(origin, corners[2], corners[0]);
|
viewFrustum.sides[0] = computePlane(origin, corners[2], corners[0]);
|
||||||
viewFrustum.sides[1] = computePlane(origin, corners[1], corners[3]);
|
viewFrustum.sides[1] = computePlane(origin, corners[1], corners[3]);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import Common;
|
import Common;
|
||||||
import DepthCommon;
|
import DepthCommon;
|
||||||
|
|
||||||
ParameterBlock<DepthData> pDepthAttachment;
|
|
||||||
|
|
||||||
struct MipParam
|
struct MipParam
|
||||||
{
|
{
|
||||||
@@ -47,9 +46,9 @@ void reduceLevel(
|
|||||||
void sourceCopy(
|
void sourceCopy(
|
||||||
uint2 dispatchID: SV_DispatchThreadID
|
uint2 dispatchID: SV_DispatchThreadID
|
||||||
) {
|
) {
|
||||||
if(dispatchID.x >= pViewParams.c.screenDimensions.x || dispatchID.y >= pViewParams.c.screenDimensions.y)
|
if(dispatchID.x >= pViewParams.screenDimensions.x || dispatchID.y >= pViewParams.screenDimensions.y)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pDepthAttachment.buffer[dispatchID.x + (dispatchID.y * uint(pViewParams.c.screenDimensions.x))] = pDepthAttachment.texture[uint2(dispatchID)];
|
pDepthAttachment.buffer[dispatchID.x + (dispatchID.y * uint(pViewParams.screenDimensions.x))] = pDepthAttachment.texture[uint2(dispatchID)];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ void cullLights(ComputeShaderInput in)
|
|||||||
uMaxDepth = 0x0;
|
uMaxDepth = 0x0;
|
||||||
oLightCount = 0;
|
oLightCount = 0;
|
||||||
tLightCount = 0;
|
tLightCount = 0;
|
||||||
groupFrustum = pDispatchParams.frustums[in.groupID.x + (in.groupID.y * pDispatchParams.p.numThreadGroups.x)];
|
groupFrustum = pDispatchParams.frustums[in.groupID.x + (in.groupID.y * pDispatchParams.numThreadGroups.x)];
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupMemoryBarrierWithGroupSync();
|
GroupMemoryBarrierWithGroupSync();
|
||||||
|
|||||||
@@ -73,10 +73,10 @@ VertexShaderOutput vertexMain(
|
|||||||
};
|
};
|
||||||
|
|
||||||
VertexShaderOutput output;
|
VertexShaderOutput output;
|
||||||
float3x3 cameraRotation = float3x3(pViewParams.c.viewMatrix);
|
float3x3 cameraRotation = float3x3(pViewParams.viewMatrix);
|
||||||
float4 worldPos = float4(mul(cameraRotation, vertices[vertexIndex]), 1.0f);
|
float4 worldPos = float4(mul(cameraRotation, vertices[vertexIndex]), 1.0f);
|
||||||
//clip(dot(worldPos, clipPlane));
|
//clip(dot(worldPos, clipPlane));
|
||||||
output.clipPos = mul(pViewParams.c.projectionMatrix, worldPos);
|
output.clipPos = mul(pViewParams.projectionMatrix, worldPos);
|
||||||
output.texCoords = normalize(vertices[vertexIndex]);
|
output.texCoords = normalize(vertices[vertexIndex]);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ void taskMain(
|
|||||||
const float offset = 0.0f;
|
const float offset = 0.0f;
|
||||||
float3 corners[4] = {
|
float3 corners[4] = {
|
||||||
screenToWorld(float4(offset, offset, -1.0f, 1.0f)).xyz,
|
screenToWorld(float4(offset, offset, -1.0f, 1.0f)).xyz,
|
||||||
screenToWorld(float4(pViewParams.c.screenDimensions.x - offset, offset, -1.0f, 1.0f)).xyz,
|
screenToWorld(float4(pViewParams.screenDimensions.x - offset, offset, -1.0f, 1.0f)).xyz,
|
||||||
screenToWorld(float4(offset, pViewParams.c.screenDimensions.y - offset, -1.0f, 1.0f)).xyz,
|
screenToWorld(float4(offset, pViewParams.screenDimensions.y - offset, -1.0f, 1.0f)).xyz,
|
||||||
screenToWorld(float4(pViewParams.c.screenDimensions - float2(offset, offset), -1.0f, 1.0f)).xyz
|
screenToWorld(float4(pViewParams.screenDimensions - float2(offset, offset), -1.0f, 1.0f)).xyz
|
||||||
};
|
};
|
||||||
Frustum viewFrustum;
|
Frustum viewFrustum;
|
||||||
viewFrustum.sides[0] = computePlane(origin, corners[2], corners[0]);
|
viewFrustum.sides[0] = computePlane(origin, corners[2], corners[0]);
|
||||||
@@ -64,7 +64,7 @@ void taskMain(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float3 median = (bounding.minCorner + bounding.maxCorner) / 2;
|
float3 median = (bounding.minCorner + bounding.maxCorner) / 2;
|
||||||
float distance = distance(median, pViewParams.c.cameraPos_WS.xyz);
|
float distance = distance(median, pViewParams.cameraPos_WS.xyz);
|
||||||
float tileDistance = distance / tile.extent;
|
float tileDistance = distance / tile.extent;
|
||||||
uint numMeshes = groupID.y + 1;
|
uint numMeshes = groupID.y + 1;
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ void meshMain(
|
|||||||
out vertices TerrainVertex vertices[TILE_VERTS],
|
out vertices TerrainVertex vertices[TILE_VERTS],
|
||||||
out indices uint3 indices[TILE_PRIMS],
|
out indices uint3 indices[TILE_PRIMS],
|
||||||
) {
|
) {
|
||||||
float4x4 vp = mul(pViewParams.c.projectionMatrix, pViewParams.c.viewMatrix);
|
float4x4 vp = mul(pViewParams.projectionMatrix, pViewParams.viewMatrix);
|
||||||
SetMeshOutputCounts(TILE_VERTS, TILE_PRIMS);
|
SetMeshOutputCounts(TILE_VERTS, TILE_PRIMS);
|
||||||
|
|
||||||
for(uint i = threadID; i < TILE_PRIMS; i += MESH_GROUP_SIZE)
|
for(uint i = threadID; i < TILE_PRIMS; i += MESH_GROUP_SIZE)
|
||||||
@@ -136,7 +136,7 @@ void meshMain(
|
|||||||
float3 worldPos = params.offset + objectPos * params.extent + float3(groupID.x * params.extent, 0, groupID.y * params.extent);
|
float3 worldPos = params.offset + objectPos * params.extent + float3(groupID.x * params.extent, 0, groupID.y * params.extent);
|
||||||
|
|
||||||
float lodDisplacement = 0;
|
float lodDisplacement = 0;
|
||||||
float3 camPos = pViewParams.c.cameraPos_WS.xyz;
|
float3 camPos = pViewParams.cameraPos_WS.xyz;
|
||||||
float cameraDistance = distance(worldPos, camPos);
|
float cameraDistance = distance(worldPos, camPos);
|
||||||
float threshold = 0;
|
float threshold = 0;
|
||||||
if(params.numMeshes == 3)
|
if(params.numMeshes == 3)
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ VertexOutput vertexMain(VertexInput input)
|
|||||||
float4 vertex = coordinates[input.vertexId];
|
float4 vertex = coordinates[input.vertexId];
|
||||||
VertexOutput output;
|
VertexOutput output;
|
||||||
output.texCoords = vertex.zw;
|
output.texCoords = vertex.zw;
|
||||||
output.position = mul(pViewParams.c.projectionMatrix, float4(vertex.xy, 0, 1));
|
output.position = mul(pViewParams.projectionMatrix, float4(vertex.xy, 0, 1));
|
||||||
output.glyphIndex = pRender.instances[input.instanceId].glyphIndex;
|
output.glyphIndex = pRender.instances[input.instanceId].glyphIndex;
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ void meshMain(
|
|||||||
float3 worldPos = params.offset + objectPos * params.extent + float3(groupID.x * params.extent, 0, groupID.y * params.extent);
|
float3 worldPos = params.offset + objectPos * params.extent + float3(groupID.x * params.extent, 0, groupID.y * params.extent);
|
||||||
|
|
||||||
float lodDisplacement = 0;
|
float lodDisplacement = 0;
|
||||||
float3 camPos = pViewParams.cameraPos_WS.xyz;
|
float3 camPos = pViewParams.ameraPos_WS.xyz;
|
||||||
float cameraDistance = distance(worldPos, camPos);
|
float cameraDistance = distance(worldPos, camPos);
|
||||||
float threshold = 0;
|
float threshold = 0;
|
||||||
if(params.numMeshes == 3)
|
if(params.numMeshes == 3)
|
||||||
@@ -237,7 +237,7 @@ void meshMain(
|
|||||||
[shader("pixel")]
|
[shader("pixel")]
|
||||||
float4 fragmentMain(WaterVertex vert) : SV_TARGET {
|
float4 fragmentMain(WaterVertex vert) : SV_TARGET {
|
||||||
float3 lightDir = -normalize(pWaterMaterial.sunDirection);
|
float3 lightDir = -normalize(pWaterMaterial.sunDirection);
|
||||||
float3 viewDir = normalize(pViewParams.c.cameraPos_WS.xyz - vert.position_WS);
|
float3 viewDir = normalize(pViewParams.cameraPos_WS.xyz - vert.position_WS);
|
||||||
float3 halfwayDir = normalize(lightDir + viewDir);
|
float3 halfwayDir = normalize(lightDir + viewDir);
|
||||||
float depth = vert.depth;
|
float depth = vert.depth;
|
||||||
float LdotH = clamp(dot(lightDir, halfwayDir), 0, 1);
|
float LdotH = clamp(dot(lightDir, halfwayDir), 0, 1);
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ struct AABB
|
|||||||
{
|
{
|
||||||
float4 clipCorner = mul(mvp, corners[i]);
|
float4 clipCorner = mul(mvp, corners[i]);
|
||||||
float4 screenCorner = clipToScreen(clipCorner);
|
float4 screenCorner = clipToScreen(clipCorner);
|
||||||
int2 screenCoords = int2(clamp(int(screenCorner.x), 0, int(pViewParams.c.screenDimensions.x)), clamp(int(screenCorner.y), 0, int(pViewParams.c.screenDimensions.y)));
|
int2 screenCoords = int2(clamp(int(screenCorner.x), 0, int(pViewParams.screenDimensions.x)), clamp(int(screenCorner.y), 0, int(pViewParams.screenDimensions.y)));
|
||||||
screenCornerMin = int2(min(screenCornerMin.x, screenCoords.x), min(screenCornerMin.y, screenCoords.y));
|
screenCornerMin = int2(min(screenCornerMin.x, screenCoords.x), min(screenCornerMin.y, screenCoords.y));
|
||||||
screenCornerMax = int2(max(screenCornerMax.x, screenCoords.x), max(screenCornerMax.y, screenCoords.y));
|
screenCornerMax = int2(max(screenCornerMax.x, screenCoords.x), max(screenCornerMax.y, screenCoords.y));
|
||||||
maxDepth = max(maxDepth, screenCorner.z);
|
maxDepth = max(maxDepth, screenCorner.z);
|
||||||
|
|||||||
@@ -13,12 +13,8 @@ struct ViewParameter
|
|||||||
float4 cameraPos_WS;
|
float4 cameraPos_WS;
|
||||||
float2 screenDimensions;
|
float2 screenDimensions;
|
||||||
};
|
};
|
||||||
struct ViewParamWrapper
|
|
||||||
{
|
|
||||||
ParameterBlock<ViewParameter> c;
|
|
||||||
};
|
|
||||||
layout(set = 0)
|
layout(set = 0)
|
||||||
ParameterBlock<ViewParamWrapper> pViewParams;
|
ParameterBlock<ViewParameter> pViewParams;
|
||||||
|
|
||||||
float4 worldToModel(float4x4 inverseTransform, float4 world)
|
float4 worldToModel(float4x4 inverseTransform, float4 world)
|
||||||
{
|
{
|
||||||
@@ -31,7 +27,7 @@ float4 worldToModel(float4x4 inverseTransform, float4 world)
|
|||||||
|
|
||||||
float4 viewToWorld(float4 view)
|
float4 viewToWorld(float4 view)
|
||||||
{
|
{
|
||||||
float4 world = mul(pViewParams.c.inverseViewMatrix, view);
|
float4 world = mul(pViewParams.inverseViewMatrix, view);
|
||||||
|
|
||||||
world = world / world.w;
|
world = world / world.w;
|
||||||
|
|
||||||
@@ -47,7 +43,7 @@ float4 viewToModel(float4x4 inverseTransform, float4 view)
|
|||||||
|
|
||||||
float4 clipToView(float4 clip)
|
float4 clipToView(float4 clip)
|
||||||
{
|
{
|
||||||
float4 view = mul(pViewParams.c.inverseProjection, clip);
|
float4 view = mul(pViewParams.inverseProjection, clip);
|
||||||
|
|
||||||
view = view / view.w;
|
view = view / view.w;
|
||||||
|
|
||||||
@@ -63,7 +59,7 @@ float4 clipToWorld(float4 clip)
|
|||||||
|
|
||||||
float4 screenToView(float4 screen)
|
float4 screenToView(float4 screen)
|
||||||
{
|
{
|
||||||
float2 texCoord = screen.xy / pViewParams.c.screenDimensions;
|
float2 texCoord = screen.xy / pViewParams.screenDimensions;
|
||||||
|
|
||||||
// Convert to clip space
|
// Convert to clip space
|
||||||
float4 clip = float4( float2( texCoord.x, 1.0f-texCoord.y ) * 2.0f - 1.0f, screen.z, screen.w);
|
float4 clip = float4( float2( texCoord.x, 1.0f-texCoord.y ) * 2.0f - 1.0f, screen.z, screen.w);
|
||||||
@@ -92,7 +88,7 @@ float4 clipToScreen(float4 clip)
|
|||||||
float oz = 1;
|
float oz = 1;
|
||||||
float pz = 0 - 1;
|
float pz = 0 - 1;
|
||||||
float zf = pz * ndc.z + oz;
|
float zf = pz * ndc.z + oz;
|
||||||
return float4(float2(texCoords.x, 1 - texCoords.y) * pViewParams.c.screenDimensions, zf, 1.0f);
|
return float4(float2(texCoords.x, 1 - texCoords.y) * pViewParams.screenDimensions, zf, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Plane
|
struct Plane
|
||||||
|
|||||||
@@ -6,11 +6,7 @@ struct DispatchParams
|
|||||||
uint pad0;
|
uint pad0;
|
||||||
uint3 numThreads;
|
uint3 numThreads;
|
||||||
uint pad1;
|
uint pad1;
|
||||||
|
RWStructuredBuffer<Frustum> frustums;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DispatchParamWrapper
|
ParameterBlock<DispatchParams> pDispatchParams;
|
||||||
{
|
|
||||||
DispatchParams p;
|
|
||||||
RWStructuredBuffer<Frustum> frustums;
|
|
||||||
}
|
|
||||||
ParameterBlock<DispatchParamWrapper> pDispatchParams;
|
|
||||||
@@ -51,7 +51,7 @@ struct FragmentParameter
|
|||||||
float3x3 tbn = float3x3(normalize(tangent_WS), normalize(biTangent_WS), normalize(normal_WS));
|
float3x3 tbn = float3x3(normalize(tangent_WS), normalize(biTangent_WS), normalize(normal_WS));
|
||||||
result.tbn = tbn;
|
result.tbn = tbn;
|
||||||
result.position_TS = mul(tbn, position_WS);
|
result.position_TS = mul(tbn, position_WS);
|
||||||
result.viewDir_TS = mul(tbn, normalize(pViewParams.c.cameraPos_WS.xyz - position_WS));
|
result.viewDir_TS = mul(tbn, normalize(pViewParams.cameraPos_WS.xyz - position_WS));
|
||||||
result.normal_TS = mul(tbn, normal_WS);
|
result.normal_TS = mul(tbn, normal_WS);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -102,8 +102,8 @@ struct VertexAttributes
|
|||||||
{
|
{
|
||||||
float4 modelPos = float4(position_MS, 1);
|
float4 modelPos = float4(position_MS, 1);
|
||||||
float4 worldPos = mul(transformMatrix, modelPos);
|
float4 worldPos = mul(transformMatrix, modelPos);
|
||||||
float4 viewPos = mul(pViewParams.c.viewMatrix, worldPos);
|
float4 viewPos = mul(pViewParams.viewMatrix, worldPos);
|
||||||
float4 clipPos = mul(pViewParams.c.projectionMatrix, viewPos);
|
float4 clipPos = mul(pViewParams.projectionMatrix, viewPos);
|
||||||
FragmentParameter result;
|
FragmentParameter result;
|
||||||
result.position_CS = clipPos;
|
result.position_CS = clipPos;
|
||||||
#ifndef POS_ONLY
|
#ifndef POS_ONLY
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ struct MeshData
|
|||||||
uint32_t numIndices;
|
uint32_t numIndices;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint32_t MAX_VERTICES = 64;
|
static const uint32_t MAX_VERTICES = 256;
|
||||||
static const uint32_t MAX_PRIMITIVES = 126;
|
static const uint32_t MAX_PRIMITIVES = 256;
|
||||||
static const uint32_t MAX_MESHLETS_PER_INSTANCE = 2048;
|
static const uint32_t MAX_MESHLETS_PER_INSTANCE = 2048;
|
||||||
|
|
||||||
struct InstanceData
|
struct InstanceData
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ struct StaticMeshVertexData
|
|||||||
{
|
{
|
||||||
attributes.texCoords[i] = float2(uint16ToFloat(texCoords[i][index * 2 + 0]), uint16ToFloat(texCoords[i][index * 2 + 1]));
|
attributes.texCoords[i] = float2(uint16ToFloat(texCoords[i][index * 2 + 0]), uint16ToFloat(texCoords[i][index * 2 + 1]));
|
||||||
}
|
}
|
||||||
attributes.vertexColor = float3(color[index * 3 + 0], color[index * 3 + 1] , color[index * 3 + 2]);
|
attributes.vertexColor = float3(uint16ToFloat(color[index * 3 + 0]), uint16ToFloat(color[index * 3 + 1]) , uint16ToFloat(color[index * 3 + 2]));
|
||||||
#endif
|
#endif
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ void raygen()
|
|||||||
const float2 pixelCenter = float2(LaunchID.xy) + float2(0.5, 0.5);
|
const float2 pixelCenter = float2(LaunchID.xy) + float2(0.5, 0.5);
|
||||||
const float2 inUV = pixelCenter / float2(LaunchSize.xy);
|
const float2 inUV = pixelCenter / float2(LaunchSize.xy);
|
||||||
float2 d = float2(inUV.x, 1 - inUV.y) * 2.0 - 1.0;
|
float2 d = float2(inUV.x, 1 - inUV.y) * 2.0 - 1.0;
|
||||||
float4 target = mul(pViewParams.c.inverseProjection, float4(d.x, d.y, 1, 1));
|
float4 target = mul(pViewParams.inverseProjection, float4(d.x, d.y, 1, 1));
|
||||||
|
|
||||||
RayDesc rayDesc;
|
RayDesc rayDesc;
|
||||||
rayDesc.Origin = mul(pViewParams.c.inverseViewMatrix, float4(0, 0, 0, 1)).xyz;
|
rayDesc.Origin = mul(pViewParams.inverseViewMatrix, float4(0, 0, 0, 1)).xyz;
|
||||||
rayDesc.Direction = mul(pViewParams.c.inverseViewMatrix, float4(normalize(target.xyz), 0)).xyz;
|
rayDesc.Direction = mul(pViewParams.inverseViewMatrix, float4(normalize(target.xyz), 0)).xyz;
|
||||||
rayDesc.TMin = 0.001;
|
rayDesc.TMin = 0.001;
|
||||||
rayDesc.TMax = 10000.0;
|
rayDesc.TMax = 10000.0;
|
||||||
|
|
||||||
|
|||||||
@@ -159,8 +159,8 @@ static constexpr bool useAsyncCompute = false;
|
|||||||
static constexpr bool useMeshShading = true;
|
static constexpr bool useMeshShading = true;
|
||||||
static constexpr uint32 numFramesBuffered = 3;
|
static constexpr uint32 numFramesBuffered = 3;
|
||||||
|
|
||||||
static constexpr uint32 numVerticesPerMeshlet = 64;
|
static constexpr uint32 numVerticesPerMeshlet = 256;
|
||||||
static constexpr uint32 numPrimitivesPerMeshlet = 126;
|
static constexpr uint32 numPrimitivesPerMeshlet = 256;
|
||||||
double getCurrentFrameDelta();
|
double getCurrentFrameDelta();
|
||||||
double getCurrentFrameTime();
|
double getCurrentFrameTime();
|
||||||
uint32 getCurrentFrameIndex();
|
uint32 getCurrentFrameIndex();
|
||||||
|
|||||||
@@ -104,10 +104,8 @@ void StaticMeshVertexData::init(Gfx::PGraphics _graphics) {
|
|||||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 3, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
|
||||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 4, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
|
||||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||||
.binding = 5,
|
.binding = 3,
|
||||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||||
.descriptorCount = MAX_TEXCOORDS,
|
.descriptorCount = MAX_TEXCOORDS,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
constexpr static uint64 NUM_DEFAULT_ELEMENTS = 36;
|
constexpr static uint64 NUM_DEFAULT_ELEMENTS = 100000;
|
||||||
uint64 VertexData::meshletCount = 0;
|
uint64 VertexData::meshletCount = 0;
|
||||||
|
|
||||||
void VertexData::resetMeshData() {
|
void VertexData::resetMeshData() {
|
||||||
|
|||||||
@@ -765,6 +765,7 @@ void Graphics::pickPhysicalDevice() {
|
|||||||
features11 = {
|
features11 = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES,
|
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES,
|
||||||
.pNext = &features12,
|
.pNext = &features12,
|
||||||
|
.storageBuffer16BitAccess = true,
|
||||||
.uniformAndStorageBuffer16BitAccess = true,
|
.uniformAndStorageBuffer16BitAccess = true,
|
||||||
};
|
};
|
||||||
features = {
|
features = {
|
||||||
@@ -780,6 +781,7 @@ void Graphics::pickPhysicalDevice() {
|
|||||||
.pipelineStatisticsQuery = true,
|
.pipelineStatisticsQuery = true,
|
||||||
.fragmentStoresAndAtomics = true,
|
.fragmentStoresAndAtomics = true,
|
||||||
.shaderInt64 = true,
|
.shaderInt64 = true,
|
||||||
|
.shaderInt16 = true,
|
||||||
.inheritedQueries = true,
|
.inheritedQueries = true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -113,10 +113,11 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg
|
|||||||
|
|
||||||
slang::ProgramLayout* signature = specializedComponent->getLayout(0, diagnostics.writeRef());
|
slang::ProgramLayout* signature = specializedComponent->getLayout(0, diagnostics.writeRef());
|
||||||
CHECK_DIAGNOSTICS();
|
CHECK_DIAGNOSTICS();
|
||||||
|
std::cout << info.name << std::endl;
|
||||||
for (size_t i = 0; i < signature->getParameterCount(); ++i) {
|
for (size_t i = 0; i < signature->getParameterCount(); ++i) {
|
||||||
auto param = signature->getParameterByIndex(i);
|
auto param = signature->getParameterByIndex(i);
|
||||||
layout->addMapping(param->getName(), param->getBindingIndex());
|
layout->addMapping(param->getName(), param->getBindingIndex());
|
||||||
//std::cout << param->getName() << ": " << param->getBindingIndex() << std::endl;
|
std::cout << param->getName() << ": " << param->getBindingIndex() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// workaround
|
// workaround
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace Seele {
|
namespace Seele {
|
||||||
class ThreadPool {
|
class ThreadPool {
|
||||||
public:
|
public:
|
||||||
ThreadPool(uint32 numWorkers = std::thread::hardware_concurrency() - 2);
|
ThreadPool(uint32 numWorkers = 1);
|
||||||
~ThreadPool();
|
~ThreadPool();
|
||||||
void runAndWait(List<std::function<void()>> functions);
|
void runAndWait(List<std::function<void()>> functions);
|
||||||
void runAsync(std::function<void()> func);
|
void runAsync(std::function<void()> func);
|
||||||
|
|||||||
Reference in New Issue
Block a user