diff --git a/d3d11/texcube-d3d11.c b/d3d11/texcube-d3d11.c index 3327857a..346c60c3 100644 --- a/d3d11/texcube-d3d11.c +++ b/d3d11/texcube-d3d11.c @@ -100,46 +100,56 @@ int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ // create shader sg_shader shd = sg_make_shader(&(sg_shader_desc){ - .attrs = { - [0] = { .sem_name="POSITION" }, - [1] = { .sem_name="COLOR", .sem_index=1 }, - [2] = { .sem_name="TEXCOORD", .sem_index=1 } + .vertex_func.source = + "cbuffer params: register(b0) {\n" + " float4x4 mvp;\n" + "};\n" + "struct vs_in {\n" + " float4 pos: POSITION;\n" + " float4 color: COLOR1;\n" + " float2 uv: TEXCOORD1;\n" + "};\n" + "struct vs_out {\n" + " float4 color: COLOR0;\n" + " float2 uv: TEXCOORD0;\n" + " float4 pos: SV_Position;\n" + "};\n" + "vs_out main(vs_in inp) {\n" + " vs_out outp;\n" + " outp.pos = mul(mvp, inp.pos);\n" + " outp.color = inp.color;\n" + " outp.uv = inp.uv * 5.0;\n" + " return outp;\n" + "};\n", + .fragment_func.source = + "Texture2D tex: register(t0);\n" + "sampler smp: register(s0);\n" + "float4 main(float4 color: COLOR0, float2 uv: TEXCOORD0): SV_Target0 {\n" + " return tex.Sample(smp, uv) * color;\n" + "}\n", + .vertex_attrs = { + [0] = { .hlsl_sem_name="POSITION" }, + [1] = { .hlsl_sem_name="COLOR", .hlsl_sem_index=1 }, + [2] = { .hlsl_sem_name="TEXCOORD", .hlsl_sem_index=1 } }, - .vs = { - .uniform_blocks[0].size = sizeof(vs_params_t), - .source = - "cbuffer params: register(b0) {\n" - " float4x4 mvp;\n" - "};\n" - "struct vs_in {\n" - " float4 pos: POSITION;\n" - " float4 color: COLOR1;\n" - " float2 uv: TEXCOORD1;\n" - "};\n" - "struct vs_out {\n" - " float4 color: COLOR0;\n" - " float2 uv: TEXCOORD0;\n" - " float4 pos: SV_Position;\n" - "};\n" - "vs_out main(vs_in inp) {\n" - " vs_out outp;\n" - " outp.pos = mul(mvp, inp.pos);\n" - " outp.color = inp.color;\n" - " outp.uv = inp.uv * 5.0;\n" - " return outp;\n" - "};\n", + .uniform_blocks[0] = { + .stage = SG_SHADERSTAGE_VERTEX, + .size = sizeof(vs_params_t), + .hlsl_register_b_n = 0, + }, + .images[0] = { + .stage = SG_SHADERSTAGE_FRAGMENT, + .hlsl_register_t_n = 0, + }, + .samplers[0] = { + .stage = SG_SHADERSTAGE_FRAGMENT, + .hlsl_register_s_n = 0, + }, + .image_sampler_pairs[0] = { + .stage = SG_SHADERSTAGE_FRAGMENT, + .image_slot = 0, + .sampler_slot = 0, }, - .fs = { - .images[0].used = true, - .samplers[0].used = true, - .image_sampler_pairs[0] = { .used = true, .image_slot = 0, .sampler_slot = 0 }, - .source = - "Texture2D tex: register(t0);\n" - "sampler smp: register(s0);\n" - "float4 main(float4 color: COLOR0, float2 uv: TEXCOORD0): SV_Target0 {\n" - " return tex.Sample(smp, uv) * color;\n" - "}\n" - } }); // pipeline object @@ -167,10 +177,8 @@ int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ sg_bindings bind = { .vertex_buffers[0] = vbuf, .index_buffer = ibuf, - .fs = { - .images[0] = img, - .samplers[0] = smp, - }, + .images[0] = img, + .samplers[0] = smp, }; // view-projection matrix @@ -192,7 +200,7 @@ int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _ sg_begin_pass(&(sg_pass){ .action = pass_action, .swapchain = d3d11_swapchain() }); sg_apply_pipeline(pip); sg_apply_bindings(&bind); - sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, &SG_RANGE(vs_params)); + sg_apply_uniforms(0, &SG_RANGE(vs_params)); sg_draw(0, 36, 1); sg_end_pass(); sg_commit();