mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
demos/triangle: Recompile shaders with our compiler.
This commit is contained in:
parent
1655d309bd
commit
763f7dfa61
Notes:
Alexandre Julliard
2022-10-18 00:13:00 +02:00
Approved-by: Zebediah Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/23
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <vkd3d_dxgi1_4.h>
|
||||
#include <vkd3d_d3dcompiler.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -45,8 +45,7 @@
|
||||
#include <assert.h>
|
||||
#include "demo.h"
|
||||
|
||||
#include "triangle_vs.h"
|
||||
#include "triangle_ps.h"
|
||||
#include "triangle_hlsl.h"
|
||||
|
||||
struct cxt_fence
|
||||
{
|
||||
@ -277,6 +276,7 @@ static void cxt_load_assets(struct cx_triangle *cxt)
|
||||
D3D12_RESOURCE_DESC resource_desc;
|
||||
D3D12_HEAP_PROPERTIES heap_desc;
|
||||
D3D12_RANGE read_range = {0, 0};
|
||||
ID3DBlob *vs, *ps;
|
||||
HRESULT hr;
|
||||
void *data;
|
||||
|
||||
@ -285,14 +285,19 @@ static void cxt_load_assets(struct cx_triangle *cxt)
|
||||
hr = demo_create_root_signature(cxt->device, &root_signature_desc, &cxt->root_signature);
|
||||
assert(SUCCEEDED(hr));
|
||||
|
||||
hr = D3DCompile(triangle_hlsl, strlen(triangle_hlsl), NULL, NULL, NULL, "vs_main", "vs_5_0", 0, 0, &vs, NULL);
|
||||
assert(SUCCEEDED(hr));
|
||||
hr = D3DCompile(triangle_hlsl, strlen(triangle_hlsl), NULL, NULL, NULL, "ps_main", "ps_5_0", 0, 0, &ps, NULL);
|
||||
assert(SUCCEEDED(hr));
|
||||
|
||||
memset(&pso_desc, 0, sizeof(pso_desc));
|
||||
pso_desc.InputLayout.pInputElementDescs = il_desc;
|
||||
pso_desc.InputLayout.NumElements = ARRAY_SIZE(il_desc);
|
||||
pso_desc.pRootSignature = cxt->root_signature;
|
||||
pso_desc.VS.pShaderBytecode = g_vs_main;
|
||||
pso_desc.VS.BytecodeLength = sizeof(g_vs_main);
|
||||
pso_desc.PS.pShaderBytecode = g_ps_main;
|
||||
pso_desc.PS.BytecodeLength = sizeof(g_ps_main);
|
||||
pso_desc.VS.pShaderBytecode = ID3D10Blob_GetBufferPointer(vs);
|
||||
pso_desc.VS.BytecodeLength = ID3D10Blob_GetBufferSize(vs);
|
||||
pso_desc.PS.pShaderBytecode = ID3D10Blob_GetBufferPointer(ps);
|
||||
pso_desc.PS.BytecodeLength = ID3D10Blob_GetBufferSize(ps);
|
||||
demo_rasterizer_desc_init_default(&pso_desc.RasterizerState);
|
||||
demo_blend_desc_init_default(&pso_desc.BlendState);
|
||||
pso_desc.DepthStencilState.DepthEnable = FALSE;
|
||||
@ -306,6 +311,9 @@ static void cxt_load_assets(struct cx_triangle *cxt)
|
||||
&IID_ID3D12PipelineState, (void **)&cxt->pipeline_state);
|
||||
assert(SUCCEEDED(hr));
|
||||
|
||||
ID3D10Blob_Release(vs);
|
||||
ID3D10Blob_Release(ps);
|
||||
|
||||
hr = ID3D12Device_CreateCommandList(cxt->device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT, cxt->command_allocator,
|
||||
cxt->pipeline_state, &IID_ID3D12GraphicsCommandList, (void **)&cxt->command_list);
|
||||
assert(SUCCEEDED(hr));
|
||||
|
@ -1,20 +0,0 @@
|
||||
struct ps_in
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float4 colour : COLOR;
|
||||
};
|
||||
|
||||
struct ps_in vs_main(float4 position : POSITION, float4 colour : COLOR)
|
||||
{
|
||||
struct ps_in o;
|
||||
|
||||
o.position = position;
|
||||
o.colour = colour;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 ps_main(struct ps_in i) : SV_TARGET
|
||||
{
|
||||
return i.colour;
|
||||
}
|
21
demos/triangle_hlsl.h
Normal file
21
demos/triangle_hlsl.h
Normal file
@ -0,0 +1,21 @@
|
||||
static const char triangle_hlsl[] =
|
||||
"struct ps_in\n"
|
||||
"{\n"
|
||||
" float4 position : SV_POSITION;\n"
|
||||
" float4 colour : COLOR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct ps_in vs_main(float4 position : POSITION, float4 colour : COLOR)\n"
|
||||
"{\n"
|
||||
" struct ps_in o;\n"
|
||||
"\n"
|
||||
" o.position = position;\n"
|
||||
" o.colour = colour;\n"
|
||||
"\n"
|
||||
" return o;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"float4 ps_main(struct ps_in i) : SV_TARGET\n"
|
||||
"{\n"
|
||||
" return i.colour;\n"
|
||||
"}\n";
|
@ -1,73 +0,0 @@
|
||||
#if 0
|
||||
//
|
||||
// Generated by Microsoft (R) D3D Shader Disassembler
|
||||
//
|
||||
//
|
||||
// Input signature:
|
||||
//
|
||||
// Name Index Mask Register SysValue Format Used
|
||||
// -------------------- ----- ------ -------- -------- ------- ------
|
||||
// SV_POSITION 0 xyzw 0 POS float
|
||||
// COLOR 0 xyzw 1 NONE float xyzw
|
||||
//
|
||||
//
|
||||
// Output signature:
|
||||
//
|
||||
// Name Index Mask Register SysValue Format Used
|
||||
// -------------------- ----- ------ -------- -------- ------- ------
|
||||
// SV_TARGET 0 xyzw 0 TARGET float xyzw
|
||||
//
|
||||
ps_5_0
|
||||
dcl_globalFlags refactoringAllowed
|
||||
dcl_input_ps linear v1.xyzw
|
||||
dcl_output o0.xyzw
|
||||
mov o0.xyzw, v1.xyzw
|
||||
ret
|
||||
// Approximately 0 instruction slots used
|
||||
#endif
|
||||
|
||||
const BYTE g_ps_main[] =
|
||||
{
|
||||
68, 88, 66, 67, 80, 239,
|
||||
109, 26, 0, 147, 6, 156,
|
||||
240, 104, 206, 124, 185, 57,
|
||||
18, 98, 1, 0, 0, 0,
|
||||
248, 0, 0, 0, 3, 0,
|
||||
0, 0, 44, 0, 0, 0,
|
||||
128, 0, 0, 0, 180, 0,
|
||||
0, 0, 73, 83, 71, 78,
|
||||
76, 0, 0, 0, 2, 0,
|
||||
0, 0, 8, 0, 0, 0,
|
||||
56, 0, 0, 0, 0, 0,
|
||||
0, 0, 1, 0, 0, 0,
|
||||
3, 0, 0, 0, 0, 0,
|
||||
0, 0, 15, 0, 0, 0,
|
||||
68, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
3, 0, 0, 0, 1, 0,
|
||||
0, 0, 15, 15, 0, 0,
|
||||
83, 86, 95, 80, 79, 83,
|
||||
73, 84, 73, 79, 78, 0,
|
||||
67, 79, 76, 79, 82, 0,
|
||||
171, 171, 79, 83, 71, 78,
|
||||
44, 0, 0, 0, 1, 0,
|
||||
0, 0, 8, 0, 0, 0,
|
||||
32, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
3, 0, 0, 0, 0, 0,
|
||||
0, 0, 15, 0, 0, 0,
|
||||
83, 86, 95, 84, 65, 82,
|
||||
71, 69, 84, 0, 171, 171,
|
||||
83, 72, 69, 88, 60, 0,
|
||||
0, 0, 80, 0, 0, 0,
|
||||
15, 0, 0, 0, 106, 8,
|
||||
0, 1, 98, 16, 0, 3,
|
||||
242, 16, 16, 0, 1, 0,
|
||||
0, 0, 101, 0, 0, 3,
|
||||
242, 32, 16, 0, 0, 0,
|
||||
0, 0, 54, 0, 0, 5,
|
||||
242, 32, 16, 0, 0, 0,
|
||||
0, 0, 70, 30, 16, 0,
|
||||
1, 0, 0, 0, 62, 0,
|
||||
0, 1
|
||||
};
|
@ -1,89 +0,0 @@
|
||||
#if 0
|
||||
//
|
||||
// Generated by Microsoft (R) D3D Shader Disassembler
|
||||
//
|
||||
//
|
||||
// Input signature:
|
||||
//
|
||||
// Name Index Mask Register SysValue Format Used
|
||||
// -------------------- ----- ------ -------- -------- ------- ------
|
||||
// POSITION 0 xyzw 0 NONE float xyzw
|
||||
// COLOR 0 xyzw 1 NONE float xyzw
|
||||
//
|
||||
//
|
||||
// Output signature:
|
||||
//
|
||||
// Name Index Mask Register SysValue Format Used
|
||||
// -------------------- ----- ------ -------- -------- ------- ------
|
||||
// SV_POSITION 0 xyzw 0 POS float xyzw
|
||||
// COLOR 0 xyzw 1 NONE float xyzw
|
||||
//
|
||||
vs_5_0
|
||||
dcl_globalFlags refactoringAllowed
|
||||
dcl_input v0.xyzw
|
||||
dcl_input v1.xyzw
|
||||
dcl_output_siv o0.xyzw, position
|
||||
dcl_output o1.xyzw
|
||||
mov o0.xyzw, v0.xyzw
|
||||
mov o1.xyzw, v1.xyzw
|
||||
ret
|
||||
// Approximately 0 instruction slots used
|
||||
#endif
|
||||
|
||||
const BYTE g_vs_main[] =
|
||||
{
|
||||
68, 88, 66, 67, 17, 201,
|
||||
143, 165, 233, 56, 0, 40,
|
||||
84, 255, 207, 20, 40, 195,
|
||||
63, 228, 1, 0, 0, 0,
|
||||
68, 1, 0, 0, 3, 0,
|
||||
0, 0, 44, 0, 0, 0,
|
||||
124, 0, 0, 0, 208, 0,
|
||||
0, 0, 73, 83, 71, 78,
|
||||
72, 0, 0, 0, 2, 0,
|
||||
0, 0, 8, 0, 0, 0,
|
||||
56, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
3, 0, 0, 0, 0, 0,
|
||||
0, 0, 15, 15, 0, 0,
|
||||
65, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
3, 0, 0, 0, 1, 0,
|
||||
0, 0, 15, 15, 0, 0,
|
||||
80, 79, 83, 73, 84, 73,
|
||||
79, 78, 0, 67, 79, 76,
|
||||
79, 82, 0, 171, 79, 83,
|
||||
71, 78, 76, 0, 0, 0,
|
||||
2, 0, 0, 0, 8, 0,
|
||||
0, 0, 56, 0, 0, 0,
|
||||
0, 0, 0, 0, 1, 0,
|
||||
0, 0, 3, 0, 0, 0,
|
||||
0, 0, 0, 0, 15, 0,
|
||||
0, 0, 68, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 3, 0, 0, 0,
|
||||
1, 0, 0, 0, 15, 0,
|
||||
0, 0, 83, 86, 95, 80,
|
||||
79, 83, 73, 84, 73, 79,
|
||||
78, 0, 67, 79, 76, 79,
|
||||
82, 0, 171, 171, 83, 72,
|
||||
69, 88, 108, 0, 0, 0,
|
||||
80, 0, 1, 0, 27, 0,
|
||||
0, 0, 106, 8, 0, 1,
|
||||
95, 0, 0, 3, 242, 16,
|
||||
16, 0, 0, 0, 0, 0,
|
||||
95, 0, 0, 3, 242, 16,
|
||||
16, 0, 1, 0, 0, 0,
|
||||
103, 0, 0, 4, 242, 32,
|
||||
16, 0, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 101, 0,
|
||||
0, 3, 242, 32, 16, 0,
|
||||
1, 0, 0, 0, 54, 0,
|
||||
0, 5, 242, 32, 16, 0,
|
||||
0, 0, 0, 0, 70, 30,
|
||||
16, 0, 0, 0, 0, 0,
|
||||
54, 0, 0, 5, 242, 32,
|
||||
16, 0, 1, 0, 0, 0,
|
||||
70, 30, 16, 0, 1, 0,
|
||||
0, 0, 62, 0, 0, 1
|
||||
};
|
Loading…
Reference in New Issue
Block a user