Skip to content

Commit 0e82a6f

Browse files
committed
FidelityFX SPD release v1.0
1 parent 8370800 commit 0e82a6f

35 files changed

+734
-609
lines changed

.gitlab-ci.yml

Lines changed: 35 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,57 @@
11
variables:
22
SampleName: SPDSample
3-
SolutionDirDX12: sample\build\DX12
4-
SolutionDX12: SPDSample_DX12.sln
5-
SolutionDirVK: sample\build\VK
6-
SolutionVK: SPDSample_VK.sln
73
GIT_SUBMODULE_STRATEGY: normal
8-
9-
before_script:
10-
- 'for /f "usebackq delims=" %%i in (`vswhere.exe -version "[15.0,16.0)" -products Microsoft.VisualStudio.Product.BuildTools -property installationPath`) do set MSBUILD_PATH=%%i'
11-
- 'call "%MSBUILD_PATH%\VC\Auxiliary\Build\vcvars64.bat"'
12-
- 'cd sample\build'
13-
- 'call GenerateSolutions.bat -T v141'
14-
- 'cd ..\..'
154

165
stages:
176
- build
187
- deploy
198

20-
build d3d12 and vulkan sample release:
9+
build_dx12:
2110
tags:
2211
- windows
2312
- amd64
24-
stage: deploy
25-
except:
26-
- tags
13+
stage: build
2714
script:
28-
- echo Building "%SolutionVK%"
29-
- cd %SolutionDirVK%
30-
- 'msbuild.exe "%SolutionVK%" /p:Configuration=Release /p:Platform=x64'
31-
- cd ../../..
32-
- echo Building "%SolutionDX12%"
33-
- cd %SolutionDirDX12%
34-
- 'msbuild.exe "%SolutionDX12%" /p:Configuration=Release /p:Platform=x64'
35-
- cd ../../..
36-
- mkdir %SampleName%
37-
- move sample\bin %SampleName%
38-
- move sample\media %SampleName%
39-
- move sample\README.md %SampleName%
40-
- echo cd .\%SampleName%\bin\ > %SampleName%_VK.bat
41-
- echo start %SampleName%_VK.exe >> %SampleName%_VK.bat
42-
- echo cd .\%SampleName%\bin\ > %SampleName%_DX12.bat
43-
- echo start %SampleName%_DX12.exe >> %SampleName%_DX12.bat
15+
- 'cmake -S sample -B sample/build/DX12 -G "Visual Studio 15 2017" -A x64 -DGFX_API=DX12'
16+
- 'cmake --build sample/build/DX12 --config Release'
4417
artifacts:
45-
name: "%SampleName%-%CI_COMMIT_REF_NAME%-%CI_COMMIT_SHORT_SHA%"
46-
paths:
47-
- "%SampleName%/bin/"
48-
- "%SampleName%/media/"
49-
- "%SampleName%/README.md"
50-
- "%SampleName%_DX12.bat"
51-
- "%SampleName%_VK.bat"
18+
paths:
19+
- sample/bin/
20+
21+
build_vk:
22+
tags:
23+
- windows
24+
- amd64
25+
stage: build
26+
script:
27+
- 'cmake -S sample -B sample/build/VK -G "Visual Studio 15 2017" -A x64 -DGFX_API=VK'
28+
- 'cmake --build sample/build/VK --config Release'
29+
artifacts:
30+
paths:
31+
- sample/bin/
5232

53-
build d3d12 and vulkan sample release tagged:
33+
package_sample:
5434
tags:
5535
- windows
5636
- amd64
5737
stage: deploy
58-
only:
59-
- tags
38+
dependencies:
39+
- build_dx12
40+
- build_vk
6041
script:
61-
- echo Building "%SolutionVK%"
62-
- cd %SolutionDirVK%
63-
- 'msbuild.exe "%SolutionVK%" /p:Configuration=Release /p:Platform=x64'
64-
- cd ../../..
65-
- echo Building "%SolutionDX12%"
66-
- cd %SolutionDirDX12%
67-
- 'msbuild.exe "%SolutionDX12%" /p:Configuration=Release /p:Platform=x64'
68-
- cd ../../..
69-
- mkdir %SampleName%
70-
- move sample\bin %SampleName%
71-
- move sample\media %SampleName%
72-
- move sample\README.md %SampleName%
73-
- move sample\screenshot.png %SampleName%
74-
- move NOTICES.txt %SampleName%
75-
- echo cd .\%SampleName%\bin\ > %SampleName%_VK.bat
76-
- echo start %SampleName%_VK.exe >> %SampleName%_VK.bat
77-
- echo cd .\%SampleName%\bin\ > %SampleName%_DX12.bat
78-
- echo start %SampleName%_DX12.exe >> %SampleName%_DX12.bat
42+
- echo "Packaging build"
43+
- copy %VULKAN_SDK%\Bin\glslc.exe .\sample\bin
44+
- echo cd .\sample\bin\ > %SampleName%_VK.bat
45+
- echo start %SampleName%_VK.exe >> %SampleName%_VK.bat
46+
- echo cd .\sample\bin\ > %SampleName%_DX12.bat
47+
- echo start %SampleName%_DX12.exe >> %SampleName%_DX12.bat
7948
artifacts:
80-
name: "%SampleName%-%CI_COMMIT_TAG%"
49+
name: "%SampleName%-%CI_COMMIT_TAG%-%CI_COMMIT_REF_NAME%-%CI_COMMIT_SHORT_SHA%"
8150
paths:
82-
- "%SampleName%/bin/"
83-
- "%SampleName%/media/"
84-
- "%SampleName%/NOTICES.txt"
85-
- "%SampleName%/README.md"
86-
- "%SampleName%/screenshot.png"
51+
- "NOTICES.txt"
52+
- "sample/bin/"
53+
- "sample/media/"
54+
- "docs/"
55+
- "readme.md"
56+
- "%SampleName%_VK.bat"
8757
- "%SampleName%_DX12.bat"
88-
- "%SampleName%_VK.bat"

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

NOTICES.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,12 @@ Downsampler
2424
- SPD CS linear sampler: uses the SPD library and for sampling the source texture a linear sampler
2525

2626
SPD Versions
27-
- WaveOps: uses Intrinsics and LDS to share the data between threads - this is the recommended version
2827
- NO-WaveOps: uses only LDS to share the data between threads
28+
- WaveOps: uses Intrinsics and LDS to share the data between threads
2929

3030
SPD Non-Packed / Packed Version
3131
- Non-Packed: uses fp32
3232
- Packed: uses fp16, reduced register pressure
3333

34-
# Known issues
35-
DX12, No-WaveOps, Non-Packed: Corruptions on Nvidia when using DXC compiler.
36-
3734
# Recommendations
3835
We recommend to use the WapeOps path when supported. If higher precision is not needed, you can enable the packed mode - it has less register pressure and can run a bit faster as well.

docs/FidelityFX_SPD.pdf

651 KB
Binary file not shown.

ffx-spd/ffx_spd.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
// // global atomic counter - MUST be initialized to 0
6262
// // GLSL:
63-
// layout(std430, set=0, binding=2) buffer globalAtomicBuffer
63+
// layout(std430, set=0, binding=2) coherent buffer globalAtomicBuffer
6464
// {
6565
// uint counter;
6666
// } globalAtomic;
@@ -69,7 +69,7 @@
6969
// {
7070
// uint counter;
7171
// };
72-
// [[vk::binding(2)]] RWStructuredBuffer<globalAtomicBuffer> globalAtomic;
72+
// [[vk::binding(2)]] globallycoherent RWStructuredBuffer<globalAtomicBuffer> globalAtomic;
7373

7474
// // [SAMPLER] add sampler
7575
// GLSL: layout(set=0, binding=3) uniform sampler srcSampler;
@@ -81,7 +81,7 @@
8181
// // GLSL:
8282
// layout(push_constant) uniform pushConstants {
8383
// uint mips; // needed to opt out earlier if mips are < 12
84-
// uint numWorkGroups; // number of total thread groups, so numWorkGroupsX * numWorkGroupsY * numWorkGroupsZ
84+
// uint numWorkGroups; // number of total thread groups, so numWorkGroupsX * numWorkGroupsY * 1
8585
// } spdConstants;
8686
// // HLSL:
8787
// [[vk::push_constant]]

sample/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,12 @@ Downsampler
2424
- SPD CS linear sampler: uses the SPD library and for sampling the source texture a linear sampler
2525

2626
SPD Versions
27-
- WaveOps: uses Intrinsics and LDS to share the data between threads - this is the recommended version
2827
- NO-WaveOps: uses only LDS to share the data between threads
28+
- WaveOps: uses Intrinsics and LDS to share the data between threads
2929

3030
SPD Non-Packed / Packed Version
3131
- Non-Packed: uses fp32
3232
- Packed: uses fp16, reduced register pressure
3333

34-
# Known issues
35-
DX12, No-WaveOps, Non-Packed: Corruptions on Nvidia when using DXC compiler.
36-
3734
# Recommendations
3835
We recommend to use the WapeOps path when supported. If higher precision is not needed, you can enable the packed mode - it has less register pressure and can run a bit faster as well.

sample/libs/cauldron

sample/src/DX12/CSDownsampler.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ namespace CAULDRON_DX12
142142
1,
143143
0,
144144
D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS),
145-
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
145+
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
146146

147147
// Create views for the mip chain
148148
//
@@ -172,7 +172,17 @@ namespace CAULDRON_DX12
172172

173173
void CSDownsampler::OnDestroy()
174174
{
175-
m_pRootSignature->Release();
175+
if (m_pPipeline != NULL)
176+
{
177+
m_pPipeline->Release();
178+
m_pPipeline = NULL;
179+
}
180+
181+
if (m_pRootSignature != NULL)
182+
{
183+
m_pRootSignature->Release();
184+
m_pRootSignature = NULL;
185+
}
176186
}
177187

178188
void CSDownsampler::Draw(ID3D12GraphicsCommandList* pCommandList)
@@ -183,7 +193,7 @@ namespace CAULDRON_DX12
183193
//
184194
for (int i = 0; i < m_mipCount; i++)
185195
{
186-
pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_result.GetResource(), D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, i));
196+
pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_result.GetResource(), D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, i));
187197

188198
D3D12_GPU_VIRTUAL_ADDRESS cbHandle;
189199
uint32_t* pConstMem;
@@ -219,7 +229,7 @@ namespace CAULDRON_DX12
219229
uint32_t dispatchZ = 1;
220230
pCommandList->Dispatch(dispatchX, dispatchY, dispatchZ);
221231

222-
pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_result.GetResource(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, i));
232+
pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_result.GetResource(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, i));
223233
}
224234
}
225235

sample/src/DX12/SPD_CS.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ namespace CAULDRON_DX12
153153
1,
154154
0,
155155
D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS),
156-
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
156+
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
157157

158158
// Create views for the mip chain
159159
//
@@ -178,12 +178,23 @@ namespace CAULDRON_DX12
178178

179179
void SPD_CS::OnDestroyWindowSizeDependentResources()
180180
{
181+
m_globalCounterBuffer.OnDestroy();
181182
m_result.OnDestroy();
182183
}
183184

184185
void SPD_CS::OnDestroy()
185186
{
186-
m_pRootSignature->Release();
187+
if (m_pPipeline != NULL)
188+
{
189+
m_pPipeline->Release();
190+
m_pPipeline = NULL;
191+
}
192+
193+
if (m_pRootSignature != NULL)
194+
{
195+
m_pRootSignature->Release();
196+
m_pRootSignature = NULL;
197+
}
187198
}
188199

189200
void SPD_CS::Draw(ID3D12GraphicsCommandList2* pCommandList)
@@ -229,13 +240,16 @@ namespace CAULDRON_DX12
229240
D3D12_WRITEBUFFERIMMEDIATE_PARAMETER pParams = { m_globalCounterBuffer.GetResource()->GetGPUVirtualAddress(), 0 };
230241
pCommandList->WriteBufferImmediate(1, &pParams, NULL);
231242

232-
pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_globalCounterBuffer.GetResource(), D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, 0));
243+
D3D12_RESOURCE_BARRIER resourceBarriers[2] = {
244+
CD3DX12_RESOURCE_BARRIER::Transition(m_globalCounterBuffer.GetResource(), D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, 0),
245+
CD3DX12_RESOURCE_BARRIER::Transition(m_result.GetResource(), D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS)
246+
};
247+
pCommandList->ResourceBarrier(2, resourceBarriers);
233248

234249
// Dispatch
235250
//
236-
pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_result.GetResource(), D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS));
237251
pCommandList->Dispatch(dispatchX, dispatchY, dispatchZ);
238-
pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_result.GetResource(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE));
252+
pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_result.GetResource(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE));
239253
}
240254

241255
void SPD_CS::Gui()

sample/src/DX12/SPD_CS_Linear_Sampler.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ namespace CAULDRON_DX12
168168
1,
169169
0,
170170
D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS),
171-
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
171+
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
172172

173173
// Create views for the mip chain
174174
//
@@ -193,12 +193,23 @@ namespace CAULDRON_DX12
193193

194194
void SPD_CS_Linear_Sampler::OnDestroyWindowSizeDependentResources()
195195
{
196+
m_globalCounterBuffer.OnDestroy();
196197
m_result.OnDestroy();
197198
}
198199

199200
void SPD_CS_Linear_Sampler::OnDestroy()
200201
{
201-
m_pRootSignature->Release();
202+
if (m_pPipeline != NULL)
203+
{
204+
m_pPipeline->Release();
205+
m_pPipeline = NULL;
206+
}
207+
208+
if (m_pRootSignature != NULL)
209+
{
210+
m_pRootSignature->Release();
211+
m_pRootSignature = NULL;
212+
}
202213
}
203214

204215
void SPD_CS_Linear_Sampler::Draw(ID3D12GraphicsCommandList2* pCommandList)
@@ -246,13 +257,16 @@ namespace CAULDRON_DX12
246257
D3D12_WRITEBUFFERIMMEDIATE_PARAMETER pParams = { m_globalCounterBuffer.GetResource()->GetGPUVirtualAddress(), 0 };
247258
pCommandList->WriteBufferImmediate(1, &pParams, NULL);
248259

249-
pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_globalCounterBuffer.GetResource(), D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, 0));
260+
D3D12_RESOURCE_BARRIER resourceBarriers[2] = {
261+
CD3DX12_RESOURCE_BARRIER::Transition(m_globalCounterBuffer.GetResource(), D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, 0),
262+
CD3DX12_RESOURCE_BARRIER::Transition(m_result.GetResource(), D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS)
263+
};
264+
pCommandList->ResourceBarrier(2, resourceBarriers);
250265

251266
// Dispatch
252267
//
253-
pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_result.GetResource(), D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS));
254268
pCommandList->Dispatch(dispatchX, dispatchY, dispatchZ);
255-
pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_result.GetResource(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE));
269+
pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_result.GetResource(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE));
256270
}
257271

258272
void SPD_CS_Linear_Sampler::Gui()

0 commit comments

Comments
 (0)