Descriptors now work in metal hopefully
This commit is contained in:
@@ -67,7 +67,7 @@ struct AABB
|
||||
{
|
||||
float4 clipCorner = mul(mvp, corners[i]);
|
||||
float4 screenCorner = clipToScreen(clipCorner);
|
||||
int2 screenCoords = int2(clamp(int(screenCorner.x), 0, int(pViewParams.screenDimensions.x)), clamp(int(screenCorner.y), 0, int(pViewParams.screenDimensions.y)));
|
||||
int2 screenCoords = int2(clamp(int(screenCorner.x), 0, int(pViewParams.c.screenDimensions.x)), clamp(int(screenCorner.y), 0, int(pViewParams.c.screenDimensions.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));
|
||||
maxDepth = max(maxDepth, screenCorner.z);
|
||||
|
||||
@@ -12,9 +12,13 @@ struct ViewParameter
|
||||
float4x4 inverseProjection;
|
||||
float4 cameraPos_WS;
|
||||
float2 screenDimensions;
|
||||
}
|
||||
layout(set=0)
|
||||
ParameterBlock<ViewParameter> pViewParams;
|
||||
};
|
||||
struct ViewParamWrapper
|
||||
{
|
||||
ParameterBlock<ViewParameter> c;
|
||||
};
|
||||
layout(set = 0)
|
||||
ParameterBlock<ViewParamWrapper> pViewParams;
|
||||
|
||||
float4 worldToModel(float4x4 inverseTransform, float4 world)
|
||||
{
|
||||
@@ -27,7 +31,7 @@ float4 worldToModel(float4x4 inverseTransform, float4 world)
|
||||
|
||||
float4 viewToWorld(float4 view)
|
||||
{
|
||||
float4 world = mul(pViewParams.inverseViewMatrix, view);
|
||||
float4 world = mul(pViewParams.c.inverseViewMatrix, view);
|
||||
|
||||
world = world / world.w;
|
||||
|
||||
@@ -43,7 +47,7 @@ float4 viewToModel(float4x4 inverseTransform, float4 view)
|
||||
|
||||
float4 clipToView(float4 clip)
|
||||
{
|
||||
float4 view = mul(pViewParams.inverseProjection, clip);
|
||||
float4 view = mul(pViewParams.c.inverseProjection, clip);
|
||||
|
||||
view = view / view.w;
|
||||
|
||||
@@ -59,7 +63,7 @@ float4 clipToWorld(float4 clip)
|
||||
|
||||
float4 screenToView(float4 screen)
|
||||
{
|
||||
float2 texCoord = screen.xy / pViewParams.screenDimensions;
|
||||
float2 texCoord = screen.xy / pViewParams.c.screenDimensions;
|
||||
|
||||
// Convert to clip space
|
||||
float4 clip = float4( float2( texCoord.x, 1.0f-texCoord.y ) * 2.0f - 1.0f, screen.z, screen.w);
|
||||
@@ -88,7 +92,7 @@ float4 clipToScreen(float4 clip)
|
||||
float oz = 1;
|
||||
float pz = 0 - 1;
|
||||
float zf = pz * ndc.z + oz;
|
||||
return float4(float2(texCoords.x, 1 - texCoords.y) * pViewParams.screenDimensions, zf, 1.0f);
|
||||
return float4(float2(texCoords.x, 1 - texCoords.y) * pViewParams.c.screenDimensions, zf, 1.0f);
|
||||
}
|
||||
|
||||
struct Plane
|
||||
|
||||
@@ -6,6 +6,11 @@ struct DispatchParams
|
||||
uint pad0;
|
||||
uint3 numThreads;
|
||||
uint pad1;
|
||||
RWStructuredBuffer<Frustum> frustums;
|
||||
};
|
||||
|
||||
struct DispatchParamWrapper
|
||||
{
|
||||
ParameterBlock<DispatchParams> p;
|
||||
RWStructuredBuffer<Frustum> frustums;
|
||||
}
|
||||
ParameterBlock<DispatchParams> pDispatchParams;
|
||||
ParameterBlock<DispatchParamWrapper> pDispatchParams;
|
||||
@@ -21,7 +21,6 @@ struct FragmentParameter
|
||||
{
|
||||
float4 position_CS : SV_Position;
|
||||
#ifndef POS_ONLY
|
||||
float3 cameraPos_WS: POSITION0;
|
||||
float3 normal_WS : NORMAL0;
|
||||
float3 tangent_WS : TANGENT0;
|
||||
float3 biTangent_WS : TANGENT1;
|
||||
@@ -52,7 +51,7 @@ struct FragmentParameter
|
||||
float3x3 tbn = float3x3(normalize(tangent_WS), normalize(biTangent_WS), normalize(normal_WS));
|
||||
result.tbn = tbn;
|
||||
result.position_TS = mul(tbn, position_WS);
|
||||
result.viewDir_TS = mul(tbn, normalize(cameraPos_WS - position_WS));
|
||||
result.viewDir_TS = mul(tbn, normalize(pViewParams.c.cameraPos_WS.xyz - position_WS));
|
||||
result.normal_TS = mul(tbn, normal_WS);
|
||||
return result;
|
||||
}
|
||||
@@ -67,7 +66,6 @@ struct FragmentParameter
|
||||
FragmentParameter result;
|
||||
result.position_CS = f0.position_CS * barycentricCoords.x + f1.position_CS * barycentricCoords.y + f2.position_CS * barycentricCoords.z;
|
||||
#ifndef POS_ONLY
|
||||
result.cameraPos_WS = f0.cameraPos_WS * barycentricCoords.x + f1.cameraPos_WS * barycentricCoords.y + f2.cameraPos_WS * barycentricCoords.z;
|
||||
result.normal_WS = f0.normal_WS * barycentricCoords.x + f1.normal_WS * barycentricCoords.y + f2.normal_WS * barycentricCoords.z;
|
||||
result.tangent_WS = f0.tangent_WS * barycentricCoords.x + f1.tangent_WS * barycentricCoords.y + f2.tangent_WS * barycentricCoords.z;
|
||||
result.biTangent_WS = f0.biTangent_WS * barycentricCoords.x + f1.biTangent_WS * barycentricCoords.y + f2.biTangent_WS * barycentricCoords.z;
|
||||
@@ -104,8 +102,8 @@ struct VertexAttributes
|
||||
{
|
||||
float4 modelPos = float4(position_MS, 1);
|
||||
float4 worldPos = mul(transformMatrix, modelPos);
|
||||
float4 viewPos = mul(pViewParams.viewMatrix, worldPos);
|
||||
float4 clipPos = mul(pViewParams.projectionMatrix, viewPos);
|
||||
float4 viewPos = mul(pViewParams.c.viewMatrix, worldPos);
|
||||
float4 clipPos = mul(pViewParams.c.projectionMatrix, viewPos);
|
||||
FragmentParameter result;
|
||||
result.position_CS = clipPos;
|
||||
#ifndef POS_ONLY
|
||||
@@ -113,7 +111,6 @@ struct VertexAttributes
|
||||
float3 T = mul(normalMatrix, tangent_MS);
|
||||
float3 N = mul(normalMatrix, normal_MS);
|
||||
float3 B = mul(normalMatrix, biTangent_MS);
|
||||
result.cameraPos_WS = pViewParams.cameraPos_WS.xyz;
|
||||
result.normal_WS = N;
|
||||
result.tangent_WS = T;
|
||||
result.biTangent_WS = B;
|
||||
|
||||
+10
-10
@@ -20,8 +20,8 @@ struct MeshData
|
||||
uint32_t numIndices;
|
||||
};
|
||||
|
||||
static const uint32_t MAX_VERTICES = 256;
|
||||
static const uint32_t MAX_PRIMITIVES = 256;
|
||||
static const uint32_t MAX_VERTICES = 64;
|
||||
static const uint32_t MAX_PRIMITIVES = 126;
|
||||
static const uint32_t MAX_MESHLETS_PER_INSTANCE = 2048;
|
||||
|
||||
struct InstanceData
|
||||
@@ -39,19 +39,19 @@ struct MeshletCullingInfo
|
||||
}
|
||||
};
|
||||
|
||||
struct DrawCallOffsets
|
||||
cbuffer DrawCallOffsets
|
||||
{
|
||||
uint instanceOffset;
|
||||
uint textureOffset;
|
||||
uint samplerOffset;
|
||||
uint floatOffset;
|
||||
};
|
||||
#ifdef RAY_TRACING
|
||||
layout(shaderRecordEXT)
|
||||
#else
|
||||
layout(push_constant)
|
||||
#endif
|
||||
ConstantBuffer<DrawCallOffsets> pOffsets;
|
||||
} pOffsets;
|
||||
//#ifdef RAY_TRACING
|
||||
//layout(shaderRecordEXT)
|
||||
//#else
|
||||
//layout(push_constant)
|
||||
//#endif
|
||||
//ConstantBuffer<DrawCallOffsets> pOffsets;
|
||||
|
||||
struct Scene
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user