forked from DiligentGraphics/DiligentTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
074de5c
commit 4503641
Showing
13 changed files
with
537 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
Tests/DiligentToolsTest/assets/RenderStates/RenderStateNotationParser/GeometryOpaque.drsn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"Shaders": [ | ||
{ | ||
"Desc": { | ||
"Name": "GeometryOpaque-VS", | ||
"ShaderType": "VERTEX" | ||
}, | ||
"SourceLanguage": "HLSL", | ||
"FilePath": "GeometryOpaque.hlsl", | ||
"EntryPoint": "VSMain", | ||
"UseCombinedTextureSamplers": true | ||
}, | ||
{ | ||
"Desc": { | ||
"Name": "GeometryOpaque-PS", | ||
"ShaderType": "PIXEL" | ||
}, | ||
"SourceLanguage": "HLSL", | ||
"FilePath": "GeometryOpaque.hlsl", | ||
"EntryPoint": "PSMain", | ||
"UseCombinedTextureSamplers": true | ||
} | ||
], | ||
"Pipeleines": [ | ||
{ | ||
"GraphicsPipeline": { | ||
"DepthStencilDesc": { | ||
"DepthEnable": true, | ||
"DepthWriteEnable": true, | ||
"DepthFunc": "LESS" | ||
}, | ||
"RasterizerDesc": { | ||
"FillMode": "SOLID", | ||
"CullMode": "BACK", | ||
"FrontCounterClockwise": true, | ||
"DepthClipEnable": true | ||
}, | ||
"SmplDesc": { | ||
"Count": 4, | ||
"Quality": 0 | ||
}, | ||
"NumRenderTargets": 1, | ||
"RTVFormats": { | ||
"0": "RGBA8_UNORM_SRGB" | ||
}, | ||
"DSVFormat": "D32_FLOAT", | ||
"PrimitiveTopology": "TRIANGLE_LIST" | ||
|
||
}, | ||
"PSODesc": { | ||
"Name": "GeometryOpaque", | ||
"PipelineType": "GRAPHICS" | ||
}, | ||
"pVS": "GeometryOpaque-VS", | ||
"pPS": "GeometryOpaque-PS" | ||
} | ||
] | ||
} |
30 changes: 30 additions & 0 deletions
30
Tests/DiligentToolsTest/assets/RenderStates/RenderStateNotationParser/GeometryResolve.drsn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"Shaders": [ | ||
{ | ||
"Desc": { | ||
"Name": "GeometryResolve-CS", | ||
"ShaderType": "COMPUTE" | ||
}, | ||
"SourceLanguage": "HLSL", | ||
"FilePath": "GeometryResolve.hlsl", | ||
"EntryPoint": "CSMain", | ||
"UseCombinedTextureSamplers": true | ||
} | ||
], | ||
"Pipeleines": [ | ||
{ | ||
"PSODesc": { | ||
"Name": "GeometryResolve", | ||
"PipelineType": "COMPUTE", | ||
"ResourceLayout": { | ||
"Variables": [ | ||
{ "ShaderStages": "COMPUTE", "Name": "TextureColor", "Type": "DYNAMIC" }, | ||
{ "ShaderStages": "COMPUTE", "Name": "TextureHead", "Type": "DYNAMIC" }, | ||
{ "ShaderStages": "COMPUTE", "Name": "BufferLinkedList", "Type": "DYNAMIC" } | ||
] | ||
} | ||
}, | ||
"pCS": "GeometryResolve-CS" | ||
} | ||
] | ||
} |
63 changes: 63 additions & 0 deletions
63
.../DiligentToolsTest/assets/RenderStates/RenderStateNotationParser/GeometryTransparent.drsn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ | ||
"Shaders": [ | ||
{ | ||
"Desc": { | ||
"Name": "GeometryTransparent-VS", | ||
"ShaderType": "VERTEX" | ||
}, | ||
"SourceLanguage": "HLSL", | ||
"FilePath": "GeometryTransparent.hlsl", | ||
"EntryPoint": "VSMain", | ||
"UseCombinedTextureSamplers": true | ||
}, | ||
{ | ||
"Desc": { | ||
"Name": "GeometryTransparent-PS", | ||
"ShaderType": "PIXEL" | ||
}, | ||
"SourceLanguage": "HLSL", | ||
"FilePath": "GeometryTransparent.hlsl", | ||
"EntryPoint": "PSMain", | ||
"UseCombinedTextureSamplers": true | ||
} | ||
], | ||
"Pipeleines": [ | ||
{ | ||
"GraphicsPipeline": { | ||
"DepthStencilDesc": { | ||
"DepthEnable": true, | ||
"DepthWriteEnable": false, | ||
"DepthFunc": "LESS" | ||
}, | ||
"RasterizerDesc": { | ||
"FillMode": "SOLID", | ||
"CullMode": "NONE", | ||
"FrontCounterClockwise": true, | ||
"DepthClipEnable": true | ||
}, | ||
"SmplDesc": { | ||
"Count": 4, | ||
"Quality": 0 | ||
}, | ||
"NumRenderTargets": 0, | ||
"DSVFormat": "D32_FLOAT", | ||
"PrimitiveTopology": "TRIANGLE_LIST" | ||
|
||
}, | ||
"PSODesc": { | ||
"Name": "GeometryTransparent", | ||
"PipelineType": "GRAPHICS", | ||
"ResourceLayout": { | ||
"DefaultVariableMergeStages": "PIXEL", | ||
"Variables": [ | ||
{ "ShaderStages": [ "PIXEL" ], "Name": "TextureHead", "Type": "DYNAMIC" }, | ||
{ "ShaderStages": [ "PIXEL" ], "Name": "BufferLinkedList", "Type": "DYNAMIC" }, | ||
{ "ShaderStages": [ "PIXEL" ], "Name": "BufferLinkedListCounter", "Type": "DYNAMIC" } | ||
] | ||
} | ||
}, | ||
"pVS": "GeometryTransparent-VS", | ||
"pPS": "GeometryTransparent-PS" | ||
} | ||
] | ||
} |
103 changes: 103 additions & 0 deletions
103
...s/DiligentToolsTest/assets/RenderStates/RenderStateNotationParser/GraphicsPrimitives.drsn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
{ | ||
"Shaders": [ | ||
{ | ||
"Desc": { | ||
"Name": "BlitTexture-VS", | ||
"ShaderType": "VERTEX" | ||
}, | ||
"SourceLanguage": "HLSL", | ||
"FilePath": "GraphicsPrimitives.hlsl", | ||
"EntryPoint": "VSBlitTexture", | ||
"UseCombinedTextureSamplers": true | ||
}, | ||
{ | ||
"Desc": { | ||
"Name": "BlitTexture-PS", | ||
"ShaderType": "PIXEL" | ||
}, | ||
"SourceLanguage": "HLSL", | ||
"FilePath": "GraphicsPrimitives.hlsl", | ||
"EntryPoint": "PSBlitTexture", | ||
"UseCombinedTextureSamplers": true | ||
}, | ||
{ | ||
"Desc": { | ||
"Name": "ClearUnorderedAccessViewUint-CS", | ||
"ShaderType": "COMPUTE" | ||
}, | ||
"SourceLanguage": "HLSL", | ||
"FilePath": "GraphicsPrimitives.hlsl", | ||
"EntryPoint": "CSClearUnorderedAccessViewUint", | ||
"UseCombinedTextureSamplers": true | ||
}, | ||
{ | ||
"Desc": { | ||
"Name": "ClearBufferCounter-CS", | ||
"ShaderType": "COMPUTE" | ||
}, | ||
"SourceLanguage": "HLSL", | ||
"FilePath": "GraphicsPrimitives.hlsl", | ||
"EntryPoint": "CSClearBufferCounter", | ||
"UseCombinedTextureSamplers": true | ||
} | ||
], | ||
"Pipeleines": [ | ||
{ | ||
"GraphicsPipeline": { | ||
"DepthStencilDesc": { | ||
"DepthEnable": false | ||
}, | ||
"RasterizerDesc": { | ||
"FillMode": "SOLID", | ||
"CullMode": "NONE" | ||
}, | ||
"NumRenderTargets": 1, | ||
"RTVFormats": { | ||
"0": "RGBA8_UNORM_SRGB" | ||
}, | ||
"PrimitiveTopology": "TRIANGLE_LIST" | ||
|
||
}, | ||
"PSODesc": { | ||
"Name": "BlitTexture", | ||
"PipelineType": "GRAPHICS", | ||
"ResourceLayout": { | ||
"Variables": [ | ||
{ "ShaderStages": "PIXEL", "Name": "TextureSRV", "Type": "DYNAMIC" } | ||
], | ||
"ImmutableSamplers": [ | ||
{ "SamplerOrTextureName": "TextureSRV", "ShaderStages": "PIXEL", "Desc": { "MinFilter" : "POINT", "MagFilter": "POINT", "MipFilter": "POINT" } } | ||
] | ||
} | ||
}, | ||
"pVS": "BlitTexture-VS", | ||
"pPS": "BlitTexture-PS" | ||
}, | ||
{ | ||
"PSODesc": { | ||
"Name": "ClearUnorderedAccessViewUint", | ||
"PipelineType": "COMPUTE", | ||
"ResourceLayout": { | ||
"DefaultVariableMergeStages": "COMPUTE", | ||
"Variables": [ | ||
{ "ShaderStages": [ "COMPUTE" ], "Name": "TextureUAV", "Type": "DYNAMIC" } | ||
] | ||
} | ||
}, | ||
"pCS": "ClearUnorderedAccessViewUint-CS" | ||
}, | ||
{ | ||
"PSODesc": { | ||
"Name": "ClearBufferCounter", | ||
"PipelineType": "COMPUTE", | ||
"ResourceLayout": { | ||
"DefaultVariableMergeStages": "COMPUTE", | ||
"Variables": [ | ||
{ "ShaderStages": [ "COMPUTE" ], "Name": "BufferUAV", "Type": "DYNAMIC" } | ||
] | ||
} | ||
}, | ||
"pCS": "ClearBufferCounter-CS" | ||
} | ||
] | ||
} |
8 changes: 8 additions & 0 deletions
8
.../DiligentToolsTest/assets/RenderStates/RenderStateNotationParser/RenderStatesLibrary.drsn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Imports": [ | ||
"GeometryOpaque.drsn", | ||
"GeometryResolve.drsn", | ||
"GeometryTransparent.drsn", | ||
"GraphicsPrimitives.drsn" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#define TEXTURE_UINT_CLEAR 0xFFFFFFFF | ||
#define BUFFER_UINT_CLEAR 0 | ||
|
||
struct ListNode { | ||
uint Next; | ||
uint Color; | ||
uint Depth; | ||
uint Coverage; | ||
}; | ||
|
||
struct ListSubNode { | ||
float Depth; | ||
uint Color; | ||
}; | ||
|
||
uint PackColor(float4 color) { | ||
return (uint(color.r * 255) << 24) | (uint(color.g * 255) << 16) | (uint(color.b * 255) << 8) | uint(color.a * 255); | ||
} | ||
|
||
float4 UnpackColor(uint color) { | ||
float4 result; | ||
result.r = float((color >> 24) & 0x000000FF) / 255.0f; | ||
result.g = float((color >> 16) & 0x000000FF) / 255.0f; | ||
result.b = float((color >> 8) & 0x000000FF) / 255.0f; | ||
result.a = float((color >> 0) & 0x000000FF) / 255.0f; | ||
return saturate(result); | ||
} |
15 changes: 15 additions & 0 deletions
15
Tests/DiligentToolsTest/assets/Shaders/GeometryOpaque.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "Common.hlsli" | ||
|
||
void VSMain(uint vertexID: SV_VertexID, uint instanceID: SV_InstanceID, out float4 position: SV_Position, out float4 color: TEXCOORD) { | ||
float2 vertexPositions[] = { float2(-0.5, -0.5), float2(+0.5, -0.5), float2(+0.0, +0.5) }; | ||
|
||
float4 vertexColors[] = { float4(1.0, 0.0, 0.0, 1.0), float4(0.0, 1.0, 0.0, 1.0), float4(0.0, 0.0, 1.0, 1.0) }; | ||
float2 instancePositionOffsets[] = { float2(.0, 0.0), float2(0.5, 0.5), float2(-0.5, -0.5), float2(-0.5, 0.5), float2(0.5, -0.5) }; | ||
|
||
color = vertexColors[vertexID]; | ||
position = float4(vertexPositions[vertexID] + instancePositionOffsets[instanceID], 0.8, 1.0f); | ||
} | ||
|
||
float4 PSMain(float4 position : SV_Position, float4 color : TEXCOORD) : SV_Target { | ||
return float4(color); | ||
} |
56 changes: 56 additions & 0 deletions
56
Tests/DiligentToolsTest/assets/Shaders/GeometryResolve.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
#include "Common.hlsli" | ||
|
||
#define FRAGMENT_COUNT 4 | ||
#define MSAA_SAMPLE_COUNT 4 | ||
|
||
RWTexture2D<unorm float4> TextureColor; | ||
Texture2D<uint> TextureHead; | ||
StructuredBuffer<ListNode> BufferLinkedList; | ||
|
||
[numthreads(8, 8, 1)] | ||
void CSMain(uint3 id: SV_DispatchThreadID) { | ||
|
||
float4 backBuffer = TextureColor[id.xy]; | ||
float4 resolveBuffer = float4(0.0, 0.0, 0.0, 0.0f); | ||
|
||
uint nodeHead = TextureHead[id.xy]; | ||
if (nodeHead == TEXTURE_UINT_CLEAR) | ||
return; | ||
|
||
ListSubNode nodes[FRAGMENT_COUNT]; | ||
for (uint sampleIdx = 0; sampleIdx < MSAA_SAMPLE_COUNT; sampleIdx++) { | ||
|
||
uint count = 0; | ||
uint nodeIdx = nodeHead; | ||
|
||
while (nodeIdx != TEXTURE_UINT_CLEAR && count < FRAGMENT_COUNT) { | ||
ListNode node = BufferLinkedList[nodeIdx]; | ||
if (node.Coverage & (1 << sampleIdx)) { | ||
nodes[count].Depth = asfloat(node.Depth); | ||
nodes[count].Color = node.Color; | ||
count++; | ||
} | ||
nodeIdx = node.Next; | ||
} | ||
|
||
for (uint i = 1; i < count; i++) { | ||
ListSubNode t = nodes[i]; | ||
uint j = i; | ||
while (j > 0 && (nodes[j - 1].Depth < t.Depth)) { | ||
nodes[j] = nodes[j - 1]; | ||
j--; | ||
} | ||
nodes[j] = t; | ||
} | ||
|
||
float4 dstPixelColor = backBuffer; | ||
for (uint index = 0; index < count; index++) { | ||
float4 srcPixelColor = UnpackColor(nodes[index].Color); | ||
dstPixelColor = lerp(dstPixelColor, srcPixelColor, srcPixelColor.a); | ||
} | ||
resolveBuffer += dstPixelColor; | ||
} | ||
TextureColor[id.xy] = resolveBuffer / MSAA_SAMPLE_COUNT; | ||
} | ||
|
Oops, something went wrong.