my question concerns ComputeShader, HLSL code in particular. So, DeviceContext.Dispath(X, Y, Z) spawns X * Y * Z groups, each of which has x * y * z individual threads set in attribute [numthreads(x,y,z)]. The question is, how can I get total number of ThreadGroups dispatched and number of threads in a group? Let me explain why I want it - the amount of data I intend to process may vary significantly, so my methods should adapt to the size of input arrays. Of course I can send Dispath arguments in constant buffer to make it available from HLSL code, but what about number of threads in a group? I am looking for methods like GetThreadGroupNumber() and GetThreadNumberInGroup(). I appreciate any help.
HLSL Get number of threadGroups and numthreads in code
3.9k Views Asked by Ilia At
1
There are 1 best solutions below
Related Questions in C++
- C++ using std::vector across boundaries
- Linked list without struct
- Connecting Signal QML to C++ (Qt5)
- how to get the reference of struct soap inherited in C++ Proxy/Service class
- Why we can't assign value to pointer
- Conversion of objects in c++
- shared_ptr: "is not a type" error
- C++ template using pointer and non pointer arguments in a QVector
- C++ SFML 2.2 vectors
- Lifetime of temporary objects
- I want to be able to use 4 different variables in a select statement in c ++
- segmentation fault: 11, extracting data in vector
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- How can I print all the values in this linked list inside a hash table?
- Configured TTL for A record(s) backing CNAME records
Related Questions in DIRECTX
- Make screenshot of DirectX window that is hidden and doesn't have focus
- Draw a sphere on a billboard with world normal from a pointlist
- DirectX - Pixel Shader 3.0 doesn't work
- D3D11 Post Shader Results in Dark Image
- Drawing a textured quad looks distorted
- DirectX 9 vertex colors ingored when lighting is enabled?
- Constant buffer is empty when passed HLSL C++
- D3DX11CompileFromFile Invalid Arguments C++
- DirectX libs in x64 program
- How to use a huge array in HLSL (error X4505)
- Relationship between AFX_WM_DRAW2D and WM_PAINT in MFC Application
- Textured cube renders blank in DirectX
- Invoke button in a game / external program C#
- DirectX VSIX Installer Installation Failed
- Normals are not transfered to DirectX 11 shader correctly - random, time-dependent values?
Related Questions in HLSL
- Draw a sphere on a billboard with world normal from a pointlist
- D3D11 Post Shader Results in Dark Image
- Constant buffer is empty when passed HLSL C++
- How to use a huge array in HLSL (error X4505)
- Rendering a circle with a Vertex shader in DirectX
- Normals are not transfered to DirectX 11 shader correctly - random, time-dependent values?
- Doing 64bit addition with 2 high 32bit integers and 2 low 32bit integers. Are there more efficient ways of getting the carry bit?
- DirectX shader linking error
- Does #pragma exclude_renderers increase performance?
- HLSL mul and D3DXMATRIX order mismatch
- Force field shader unwrap texture not working
- HLSL - organizing shaders and techniques and not getting lost
- DirectX 11: Z-Fighting
- HLSL TextureSampler Color returning white
- using Kinect Depth View to show an Object inside the Human Body
Related Questions in COMPUTE-SHADER
- OpenGL Compute Shader synchronization between groups
- How do GPUs handle random access?
- Are there DirectX guidelines for binding and unbinding resources between draw calls?
- OpenGL Compute shader atomic operations
- Unity Compute Shaders Vertex Index error
- GPU returning randoms floats instead of buffer content - DirectX 11
- How would I use rasterization to create a texel to primitive texture-map - DirectX 11
- Ping pong propagation in glsl compute shader possible in one call?
- Debugging Metal compute shaders with Xcode
- How to execute parallel compute shaders across multiple compute queues in Vulkan?
- Unity Compute Shader, Array Indexing through SV_DispatchThreadID
- Why is the data written by imageStore for integer Sampler interpretted as Float?
- Mapping between Compute Shaders and Cuda
- Compute Shader write to texture
- OpenGL Shader exception in Vncviewer
Related Questions in DIRECTCOMPUTE
- Set counter of append/consume buffer on GPU?
- Unity Compute Shader, Array Indexing through SV_DispatchThreadID
- DirectX on WPF Geometry
- Create R32_UINT view from R8G8B8A8_UNORM resource
- DirectCompute and Multiple Devices?
- How to unwrap this recursive function into a loop?
- directcompute hlsl numthreads?
- Threads on the GPU
- Warp threads not SIMD synchronous
- GPU frustum culling : why using scan?
- Compute Shader basics in dx11
- HLSL Get number of threadGroups and numthreads in code
- D3D12 Use backbuffer surface as unordered access view (UAV)
- DirectX 11 - Compute shader: Writing to an output resource
- HLSL Compiler omitting crucial statements
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The number of threads in a group is simply the product of the
numthreadsdimensions. For example,numthreads(32,8,4)will have32*8*4 = 1024threads per group. This can be determined statically at compile time.The ID for a particular thread-group can be determined by adding a
uint3input argument with theSV_GroupIdsemantic.The ID for a particular thread within a thread-group can be determined by adding a
uint3input argument with theSV_GroupThreadIDsemantic, oruintSV_GroupIndexif you prefer a flattened version.As far as providing information to each thread on the total size of the dispatch, using a constant buffer is your best bet. This is analogous to the graphics pipeline, where the pixel shader doesn't naturally know the viewport dimensions.
It's also worth mentioning that if you do find yourself in a position where each thread needs to know the overall dispatch size, you should consider restructuring your algorithm. In general, it's better to dispatch a variable numbers of thread groups, each with a fixed amount of work, rather than dispatching a fixed number of threads with a variable amount of work. There are of course exceptions but this will tend provide better utilization of the hardware.