Skip to content

Commit d7f1738

Browse files
authored
Merge pull request #874 from therathatter/master
Fix D3D12 pixel shader not passing texture index
2 parents 9afb3dd + ac86844 commit d7f1738

3 files changed

Lines changed: 48 additions & 33 deletions

File tree

demo/d3d12/nuklear_d3d12.hlsl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ cbuffer buffer0 : register(b0)
1717
{
1818
float4x4 ProjectionMatrix;
1919
};
20-
static uint texture_index : register(b1);
20+
cbuffer buffer1 : register(b1)
21+
{
22+
uint texture_index;
23+
};
2124

2225
sampler sampler0 : register(s0);
2326
Texture2D<float4> textures[] : register(t0);

demo/d3d12/nuklear_d3d12_pixel_shader.h

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,30 @@
2020
//
2121
ps_5_1
2222
dcl_globalFlags refactoringAllowed
23+
dcl_constantbuffer CB0[1:1][1], immediateIndexed, space=0
2324
dcl_sampler S0[0:0], mode_default, space=0
2425
dcl_resource_texture2d (float,float,float,float) T0[0:*], space=0
2526
dcl_input_ps linear v1.xyzw
2627
dcl_input_ps linear v2.xy
2728
dcl_output o0.xyzw
2829
dcl_temps 1
29-
sample r0.xyzw, v2.xyxx, T0[0].xyzw, S0[0]
30+
mov r0.x, CB0[1][0].x
31+
sample r0.xyzw, v2.xyxx, T0[r0.x + 0].xyzw, S0[0]
3032
mul o0.xyzw, r0.xyzw, v1.xyzw
3133
ret
3234
// Approximately 0 instruction slots used
3335
#endif
3436

3537
const BYTE nk_d3d12_pixel_shader[] =
3638
{
37-
68, 88, 66, 67, 228, 128,
38-
250, 93, 94, 248, 174, 160,
39-
102, 133, 107, 228, 84, 49,
40-
109, 253, 1, 0, 0, 0,
41-
72, 2, 0, 0, 4, 0,
39+
68, 88, 66, 67, 73, 133,
40+
25, 209, 159, 246, 67, 117,
41+
188, 99, 71, 63, 85, 121,
42+
246, 160, 1, 0, 0, 0,
43+
132, 2, 0, 0, 4, 0,
4244
0, 0, 48, 0, 0, 0,
4345
164, 0, 0, 0, 216, 0,
44-
0, 0, 152, 1, 0, 0,
46+
0, 0, 212, 1, 0, 0,
4547
73, 83, 71, 78, 108, 0,
4648
0, 0, 3, 0, 0, 0,
4749
8, 0, 0, 0, 80, 0,
@@ -70,30 +72,40 @@ const BYTE nk_d3d12_pixel_shader[] =
7072
0, 0, 15, 0, 0, 0,
7173
83, 86, 95, 84, 97, 114,
7274
103, 101, 116, 0, 171, 171,
73-
83, 72, 69, 88, 184, 0,
75+
83, 72, 69, 88, 244, 0,
7476
0, 0, 81, 0, 0, 0,
75-
46, 0, 0, 0, 106, 8,
76-
0, 1, 90, 0, 0, 6,
77-
70, 110, 48, 0, 0, 0,
78-
0, 0, 0, 0, 0, 0,
77+
61, 0, 0, 0, 106, 8,
78+
0, 1, 89, 0, 0, 7,
79+
70, 142, 48, 0, 0, 0,
80+
0, 0, 1, 0, 0, 0,
81+
1, 0, 0, 0, 1, 0,
7982
0, 0, 0, 0, 0, 0,
80-
0, 0, 88, 24, 0, 7,
81-
70, 126, 48, 0, 0, 0,
83+
90, 0, 0, 6, 70, 110,
84+
48, 0, 0, 0, 0, 0,
8285
0, 0, 0, 0, 0, 0,
83-
255, 255, 255, 255, 85, 85,
8486
0, 0, 0, 0, 0, 0,
85-
98, 16, 0, 3, 242, 16,
86-
16, 0, 1, 0, 0, 0,
87-
98, 16, 0, 3, 50, 16,
88-
16, 0, 2, 0, 0, 0,
89-
101, 0, 0, 3, 242, 32,
87+
88, 24, 0, 7, 70, 126,
88+
48, 0, 0, 0, 0, 0,
89+
0, 0, 0, 0, 255, 255,
90+
255, 255, 85, 85, 0, 0,
91+
0, 0, 0, 0, 98, 16,
92+
0, 3, 242, 16, 16, 0,
93+
1, 0, 0, 0, 98, 16,
94+
0, 3, 50, 16, 16, 0,
95+
2, 0, 0, 0, 101, 0,
96+
0, 3, 242, 32, 16, 0,
97+
0, 0, 0, 0, 104, 0,
98+
0, 2, 1, 0, 0, 0,
99+
54, 0, 0, 7, 18, 0,
90100
16, 0, 0, 0, 0, 0,
91-
104, 0, 0, 2, 1, 0,
92-
0, 0, 69, 0, 0, 11,
93-
242, 0, 16, 0, 0, 0,
94-
0, 0, 70, 16, 16, 0,
95-
2, 0, 0, 0, 70, 126,
96-
32, 0, 0, 0, 0, 0,
101+
10, 128, 48, 0, 0, 0,
102+
0, 0, 1, 0, 0, 0,
103+
0, 0, 0, 0, 69, 0,
104+
0, 12, 242, 0, 16, 0,
105+
0, 0, 0, 0, 70, 16,
106+
16, 0, 2, 0, 0, 0,
107+
70, 126, 32, 4, 0, 0,
108+
0, 0, 10, 0, 16, 0,
97109
0, 0, 0, 0, 0, 96,
98110
32, 0, 0, 0, 0, 0,
99111
0, 0, 0, 0, 56, 0,
@@ -122,7 +134,7 @@ const BYTE nk_d3d12_pixel_shader[] =
122134
0, 0, 1, 0, 0, 0,
123135
255, 255, 255, 255, 1, 0,
124136
0, 0, 0, 0, 0, 0,
125-
1, 0, 0, 0, 21, 0,
137+
1, 0, 0, 0, 0, 0,
126138
0, 0, 3, 0, 0, 0,
127139
3, 0, 0, 0, 3, 0,
128140
0, 0, 0, 0, 0, 0,

demo/d3d12/nuklear_d3d12_vertex_shader.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ ret
4141

4242
const BYTE nk_d3d12_vertex_shader[] =
4343
{
44-
68, 88, 66, 67, 187, 129,
45-
163, 57, 169, 94, 219, 158,
46-
174, 23, 30, 91, 108, 150,
47-
135, 141, 1, 0, 0, 0,
44+
68, 88, 66, 67, 10, 50,
45+
163, 106, 14, 182, 90, 117,
46+
132, 23, 91, 245, 57, 254,
47+
217, 51, 1, 0, 0, 0,
4848
232, 2, 0, 0, 4, 0,
4949
0, 0, 48, 0, 0, 0,
5050
160, 0, 0, 0, 20, 1,
@@ -156,7 +156,7 @@ const BYTE nk_d3d12_vertex_shader[] =
156156
1, 0, 0, 0, 255, 255,
157157
255, 255, 1, 0, 0, 0,
158158
0, 0, 0, 0, 1, 0,
159-
0, 0, 21, 0, 0, 0,
159+
0, 0, 0, 0, 0, 0,
160160
3, 0, 0, 0, 3, 0,
161161
0, 0, 3, 0, 0, 0,
162162
0, 0, 0, 0, 16, 0,

0 commit comments

Comments
 (0)