summaryrefslogtreecommitdiff
path: root/examples/heterogeneous-hello-world/shader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/heterogeneous-hello-world/shader.cpp')
-rw-r--r--examples/heterogeneous-hello-world/shader.cpp192
1 files changed, 98 insertions, 94 deletions
diff --git a/examples/heterogeneous-hello-world/shader.cpp b/examples/heterogeneous-hello-world/shader.cpp
index 396b78cb4..e8656bed7 100644
--- a/examples/heterogeneous-hello-world/shader.cpp
+++ b/examples/heterogeneous-hello-world/shader.cpp
@@ -1,126 +1,130 @@
#include "../../prelude/slang-cpp-prelude.h"
-namespace { // anonymous
+//namespace { // anonymous
#ifdef SLANG_PRELUDE_NAMESPACE
using namespace SLANG_PRELUDE_NAMESPACE;
#endif
-struct KernelContext;
+#line 21 "../../examples/heterogeneous-hello-world/shader.slang"
+struct gfx_Window_0
+{
+};
-#line 13 "shader.slang"
-struct UniformState
+
+#line 22
+struct gfx_Renderer_0
{
+};
-#line 4
- RWStructuredBuffer<float> ioBuffer_0;
+#line 23
+struct gfx_BufferResource_0
+{
+};
+struct gfx_ShaderProgram_0
+{
};
-struct KernelContext
+
+#line 26
+struct gfx_DescriptorSetLayout_0
{
- UniformState* uniformState;
- uint3 dispatchThreadID;
- uint3 groupID;
- uint3 groupDispatchThreadID;
- uint3 calcGroupThreadID() const
- {
- uint3 v = { dispatchThreadID.x - groupDispatchThreadID.x, dispatchThreadID.y - groupDispatchThreadID.y, dispatchThreadID.z - groupDispatchThreadID.z };
- return v;
- }
+};
-#line 8
- void _computeMain()
- {
+#line 24
+struct gfx_PipelineLayout_0
+{
+};
-#line 10
- uint32_t tid_0 = dispatchThreadID.x;
- float i_0 = (uniformState->ioBuffer_0)[tid_0];
- bool _S1 = i_0 < 0.50000000000000000000f;
+#line 27
+struct gfx_DescriptorSet_0
+{
+};
-#line 13
- float _S2 = i_0 + i_0;
-#line 13
- float _S3 = (F32_sqrt((i_0)));
+#line 25
+struct gfx_PipelineState_0
+{
+};
-#line 13
- float o_0 = _S1 ? _S2 : _S3;
- (uniformState->ioBuffer_0)[tid_0] = o_0;
+#line 34
+gfx_Window_0* createWindow_0(int32_t _0, int32_t _1);
-#line 8
- return;
- }
-};
+#line 35
+gfx_Renderer_0* createRenderer_0(int32_t _0, int32_t _1, gfx_Window_0* _2);
-} // anonymous
-// [numthreads(4, 1, 1)]
-SLANG_PRELUDE_EXPORT
-void computeMain_Thread(ComputeThreadVaryingInput* varyingInput, void* params, void* uniformState)
-{
- KernelContext context = {};
- context.uniformState = (UniformState*)uniformState;
- context.dispatchThreadID = {
- varyingInput->groupID.x * 4 + varyingInput->groupThreadID.x,
- varyingInput->groupID.y * 1 + varyingInput->groupThreadID.y,
- varyingInput->groupID.z * 1 + varyingInput->groupThreadID.z
- };
- context._computeMain();
-}
-// [numthreads(4, 1, 1)]
-SLANG_PRELUDE_EXPORT
-void computeMain_Group(ComputeVaryingInput* varyingInput, void* params, void* uniformState)
-{
- KernelContext context = {};
- context.uniformState = (UniformState*)uniformState;
- const uint3 start = {
- varyingInput->startGroupID.x * 4,
- varyingInput->startGroupID.y * 1,
- varyingInput->startGroupID.z * 1
- };
- context.dispatchThreadID = start;
- for (uint32_t x = start.x; x < start.x + 4; ++x)
- {
- context.dispatchThreadID.x = x;
- context._computeMain();
- }
-}
-// [numthreads(4, 1, 1)]
-SLANG_PRELUDE_EXPORT
-void computeMain(ComputeVaryingInput* varyingInput, void* params, void* uniformState)
+
+gfx_BufferResource_0* createStructuredBuffer_0(gfx_Renderer_0* _0, FixedArray<float, 4> _1);
+
+
+#line 33
+gfx_ShaderProgram_0* loadShaderProgram_0(gfx_Renderer_0* _0);
+
+
+#line 40
+gfx_DescriptorSetLayout_0* buildDescriptorSetLayout_0(gfx_Renderer_0* _0);
+
+
+#line 41
+gfx_PipelineLayout_0* buildPipeline_0(gfx_Renderer_0* _0, gfx_DescriptorSetLayout_0* _1);
+
+
+#line 42
+gfx_DescriptorSet_0* buildDescriptorSet_0(gfx_Renderer_0* _0, gfx_DescriptorSetLayout_0* _1, gfx_BufferResource_0* _2);
+
+
+
+gfx_PipelineState_0* buildPipelineState_0(gfx_ShaderProgram_0* _0, gfx_Renderer_0* _1, gfx_PipelineLayout_0* _2);
+
+
+
+void printInitialValues_0(FixedArray<float, 4> _0, int32_t _1);
+
+
+#line 51
+void dispatchComputation_0(gfx_Renderer_0* _0, gfx_PipelineState_0* _1, gfx_PipelineLayout_0* _2, gfx_DescriptorSet_0* _3);
+
+
+
+
+void print_output_0(gfx_Renderer_0* _0, gfx_BufferResource_0* _1, int32_t _2);
+
+
+
+
+bool executeComputation_0()
{
- KernelContext context = {};
- context.uniformState = (UniformState*)uniformState;
- const uint3 start = {
- varyingInput->startGroupID.x * 4,
- varyingInput->startGroupID.y * 1,
- varyingInput->startGroupID.z * 1
- };
- const uint3 end = {
- varyingInput->endGroupID.x * 4,
- varyingInput->endGroupID.y * 1,
- varyingInput->endGroupID.z * 1
- };
- for (uint32_t z = start.z; z < end.z; ++z)
- {
- context.dispatchThreadID.z = z;
- for (uint32_t y = start.y; y < end.y; ++y)
- {
- context.dispatchThreadID.y = y;
- for (uint32_t x = start.x; x < end.x; ++x)
- {
- context.dispatchThreadID.x = x;
- context._computeMain();
- }
- }
- }
+
+
+
+ FixedArray<float, 4> initialArray_0 = { 3.00000000000000000000f, -20.00000000000000000000f, -6.00000000000000000000f, 8.00000000000000000000f };
+
+
+ gfx_Window_0* _S1 = createWindow_0(int(1024), int(768));
+ gfx_Renderer_0* _S2 = createRenderer_0(int(1024), int(768), _S1);
+ gfx_BufferResource_0* _S3 = createStructuredBuffer_0(_S2, initialArray_0);
+ gfx_ShaderProgram_0* _S4 = loadShaderProgram_0(_S2);
+ gfx_DescriptorSetLayout_0* _S5 = buildDescriptorSetLayout_0(_S2);
+ gfx_PipelineLayout_0* _S6 = buildPipeline_0(_S2, _S5);
+ gfx_DescriptorSet_0* _S7 = buildDescriptorSet_0(_S2, _S5, _S3);
+ gfx_PipelineState_0* _S8 = buildPipelineState_0(_S4, _S2, _S6);
+ printInitialValues_0(initialArray_0, int(4));
+ dispatchComputation_0(_S2, _S8, _S6, _S7);
+ print_output_0(_S2, _S3, int(4));
+
+
+ return true;
}
+
+//} // anonymous
+