-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVpuShader.c
60 lines (46 loc) · 1.3 KB
/
VpuShader.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifdef _WINDLL
#include <SDKDDKVer.h>
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files
#include <windows.h>
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
extern __declspec(dllexport) void shader_main();
#endif
#include "VpuShaderLib.h"
void shader_main()
{
int32_t threadId = dx_op_threadId_i32();
dx_types_Handle rUav = dx_op_createHandle(kVpuResourceClassUAV, 2, 2, 0);
dx_types_Handle bUav = dx_op_createHandle(kVpuResourceClassUAV, 1, 1, 0);
dx_types_Handle aUav = dx_op_createHandle(kVpuResourceClassUAV, 0, 0, 0);
{
dx_types_ResRet_i32 a;
dx_types_ResRet_i32 b;
dx_op_bufferLoad_i32(&a, aUav, threadId, 0);
dx_op_bufferLoad_i32(&b, bUav, threadId, 0);
int32_t i = a.v0 + b.v0;
dx_op_bufferStore_i32(rUav, threadId, 0, i, 0, 0, 0, 1);
}
{
dx_types_ResRet_f32 a;
dx_types_ResRet_f32 b;
dx_op_bufferLoad_f32(&a, aUav, threadId, 4);
dx_op_bufferLoad_f32(&b, bUav, threadId, 4);
float f = a.v0 + b.v0;
dx_op_bufferStore_f32(rUav, threadId, 4, f, 0, 0, 0, 1);
}
}