Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tests for the FFT compute shaders #118

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
cb6e563
New FFT test
Fletterio Jun 13, 2024
fbff6cc
Update CMakeLists.txt
Fletterio Jun 13, 2024
82242e9
Changing the test to use the memAdaptor layout for coalesced accesses
Fletterio Jun 23, 2024
edecfca
Layout changes ongoing
Fletterio Jun 24, 2024
d5b05ed
Refactoring
Fletterio Jun 25, 2024
b822d8e
Update example
Fletterio Jun 25, 2024
ecfef2b
Updating example
Fletterio Jun 26, 2024
bfae67a
shared mem and accessor now use uint
Fletterio Jun 26, 2024
5db5694
Changing data layout
Fletterio Jun 27, 2024
64e9d01
Changing example following refactor of workgroup FFT
Fletterio Jul 4, 2024
c33e720
Merge branch 'master' into FFT_test
Fletterio Jul 4, 2024
2fd0796
Merge branch 'master' into FFT_test
Fletterio Jul 10, 2024
034dc98
Merge branch 'master' into FFT_test
Fletterio Jul 15, 2024
1d62ee9
Merge branch 'master' into FFT_test
Fletterio Aug 5, 2024
427327e
Accessor changes
Fletterio Aug 5, 2024
3978a0c
Refactored test a bit to use new accessor convention
Fletterio Aug 6, 2024
000d579
Minor refactors
Fletterio Aug 7, 2024
8e7c20d
Cleanup
Fletterio Aug 9, 2024
d9452c7
Merge branch 'master' into FFT_test
Fletterio Aug 9, 2024
876a3fa
Changed RawBuffer calls to directly use complex_t
Fletterio Aug 9, 2024
cb5d074
set the required subgroup size and explain why the example crashes
Aug 17, 2024
a88834d
fix more of my review comments
Aug 17, 2024
b789bf0
Fixed barrier, update some comments
Fletterio Aug 20, 2024
f326eab
Merge branch 'master' into FFT_test
Fletterio Aug 20, 2024
551728e
Update example to use doubleBdaAccessor
Fletterio Aug 20, 2024
48ecc16
Roll back Accessor, BdaAccessor not working with complex_t
Fletterio Aug 21, 2024
442f79f
Used legacy bda accessor for complex
Fletterio Aug 23, 2024
fdc2bb5
Checkpoint to merge master
Fletterio Aug 27, 2024
78cdfa5
Merge branch 'master' into FFT_test
Fletterio Aug 27, 2024
47cdd90
Changed to use new utils, workgroup size is now template parameter co…
Fletterio Aug 28, 2024
eeda3b6
Shared mem size name changed, reflecting that
Fletterio Sep 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions 64_FFT/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
include(common RESULT_VARIABLE RES)
if(NOT RES)
message(FATAL_ERROR "common.cmake not found. Should be in {repo_root}/cmake directory")
endif()

nbl_create_executable_project("" "" "" "" "${NBL_EXECUTABLE_PROJECT_CREATION_PCH_TARGET}")

if(NBL_EMBED_BUILTIN_RESOURCES)
set(_BR_TARGET_ ${EXECUTABLE_NAME}_builtinResourceData)
set(RESOURCE_DIR "app_resources")

get_filename_component(_SEARCH_DIRECTORIES_ "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE)
get_filename_component(_OUTPUT_DIRECTORY_SOURCE_ "${CMAKE_CURRENT_BINARY_DIR}/src" ABSOLUTE)
get_filename_component(_OUTPUT_DIRECTORY_HEADER_ "${CMAKE_CURRENT_BINARY_DIR}/include" ABSOLUTE)

file(GLOB_RECURSE BUILTIN_RESOURCE_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_DIR}" CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_DIR}/*")
foreach(RES_FILE ${BUILTIN_RESOURCE_FILES})
LIST_BUILTIN_RESOURCE(RESOURCES_TO_EMBED "${RES_FILE}")
endforeach()

ADD_CUSTOM_BUILTIN_RESOURCES(${_BR_TARGET_} RESOURCES_TO_EMBED "${_SEARCH_DIRECTORIES_}" "${RESOURCE_DIR}" "nbl::this_example::builtin" "${_OUTPUT_DIRECTORY_HEADER_}" "${_OUTPUT_DIRECTORY_SOURCE_}")

LINK_BUILTIN_RESOURCES_TO_TARGET(${EXECUTABLE_NAME} ${_BR_TARGET_})
endif()
19 changes: 19 additions & 0 deletions 64_FFT/app_resources/common.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "nbl/builtin/hlsl/cpp_compat.hlsl"

// Unfortunately not every piece of C++14 metaprogramming syntax is available in HLSL 202x
// https://github.com/microsoft/DirectXShaderCompiler/issues/5751#issuecomment-1800847954
devshgraphicsprogramming marked this conversation as resolved.
Show resolved Hide resolved
using input_t = nbl::hlsl::float32_t;

struct PushConstantData
{
uint64_t inputAddress;
uint64_t outputAddress;
devshgraphicsprogramming marked this conversation as resolved.
Show resolved Hide resolved
uint32_t dataElementCount;
};

#define _NBL_HLSL_WORKGROUP_SIZE_ 128
NBL_CONSTEXPR uint32_t WorkgroupSize = _NBL_HLSL_WORKGROUP_SIZE_;
NBL_CONSTEXPR uint32_t ElementsPerThread = 4;
NBL_CONSTEXPR uint32_t complexElementCount = WorkgroupSize * ElementsPerThread;

#include "nbl/builtin/hlsl/random/xoroshiro.hlsl"
devshgraphicsprogramming marked this conversation as resolved.
Show resolved Hide resolved
72 changes: 72 additions & 0 deletions 64_FFT/app_resources/shader.comp.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include "common.hlsl"
#include "nbl/builtin/hlsl/workgroup/fft.hlsl"
//#include "nbl/builtin/hlsl/subgroup/fft.hlsl"
#include "nbl/builtin/hlsl/glsl_compat/subgroup_basic.hlsl"

[[vk::push_constant]] PushConstantData pushConstants;

// careful: change size according to Scalar type
groupshared uint32_t sharedmem[4 * WorkgroupSize];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make a thing like the workgroup scans have for working out the smem size with nbl::hlsl::mpl


// Users MUST define this method for FFT to work
namespace nbl { namespace hlsl { namespace glsl
{
uint32_t3 gl_WorkGroupSize() { return uint32_t3(WorkgroupSize, 1, 1); }
} } }

struct SharedMemoryAccessor {
void set(uint32_t idx, uint32_t value)
{
sharedmem[idx] = value;
}

void get(uint32_t idx, NBL_REF_ARG(uint32_t) value)
{
value = sharedmem[idx];
}

void workgroupExecutionAndMemoryBarrier()
{
AllMemoryBarrierWithGroupSync();
}

};

struct Accessor {
void set(uint32_t idx, nbl::hlsl::complex_t<input_t> value)
{
vk::RawBufferStore< vector<input_t, 2> >(pushConstants.outputAddress + sizeof(vector<input_t, 2>) * idx, vector<input_t, 2>(value.real(), value.imag()));
}

void get(uint32_t idx, NBL_REF_ARG(nbl::hlsl::complex_t<input_t>) value)
{
vector<input_t, 2> aux = vk::RawBufferLoad< vector<input_t, 2> >(pushConstants.inputAddress + sizeof(vector<input_t, 2>) * idx);
value.real(aux.x);
value.imag(aux.y);
}

void workgroupExecutionAndMemoryBarrier()
{
AllMemoryBarrierWithGroupSync();
}

void memoryBarrier()
{
AllMemoryBarrier();
}
};

[numthreads(WorkgroupSize,1,1)]
void main(uint32_t3 ID : SV_DispatchThreadID)
{

Accessor accessor;
SharedMemoryAccessor sharedmemAccessor;

// Workgroup

nbl::hlsl::workgroup::FFT<ElementsPerThread, true, input_t>::template __call<Accessor, SharedMemoryAccessor>(accessor, sharedmemAccessor);
accessor.workgroupExecutionAndMemoryBarrier();
nbl::hlsl::workgroup::FFT<ElementsPerThread, false, input_t>::template __call<Accessor, SharedMemoryAccessor>(accessor, sharedmemAccessor);

}
28 changes: 28 additions & 0 deletions 64_FFT/config.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"enableParallelBuild": true,
"threadsPerBuildProcess" : 2,
"isExecuted": false,
"scriptPath": "",
"cmake": {
"configurations": [ "Release", "Debug", "RelWithDebInfo" ],
"buildModes": [],
"requiredOptions": []
},
"profiles": [
{
"backend": "vulkan", // should be none
"platform": "windows",
"buildModes": [],
"runConfiguration": "Release", // we also need to run in Debug nad RWDI because foundational example
"gpuArchitectures": []
}
],
"dependencies": [],
"data": [
{
"dependencies": [],
"command": [""],
"outputs": []
}
]
}
Loading