From ef87d9416e95d2a99bb530dc84dafcfcc1ffaf0a Mon Sep 17 00:00:00 2001 From: Charlie Malmqvist Date: Wed, 17 Jul 2024 14:16:23 +0200 Subject: [PATCH] Simplify vertex data --- TODO | 3 + oogabooga/d3d11_image_shader_bytecode.c | 117 ++++++++++++------------ oogabooga/dev/d3d11_image_shader.hlsl | 10 +- oogabooga/drawing.c | 1 + oogabooga/gfx_impl_d3d11.c | 26 +++++- 5 files changed, 92 insertions(+), 65 deletions(-) diff --git a/TODO b/TODO index 2b60ac8..1416536 100644 --- a/TODO +++ b/TODO @@ -24,6 +24,9 @@ - Renderer - Custom shaders (just do hlsl for now, later we transpile) - Still compile a default that's set by default and we can set with set_shader_for_basic_2d + +- Fonts + - Atlases are way too big, render atlases with size depending on font_height (say, 128 codepoints per atlas) - Needs testing: - Audio format channel conversions diff --git a/oogabooga/d3d11_image_shader_bytecode.c b/oogabooga/d3d11_image_shader_bytecode.c index 37332cf..2964655 100644 --- a/oogabooga/d3d11_image_shader_bytecode.c +++ b/oogabooga/d3d11_image_shader_bytecode.c @@ -6,7 +6,9 @@ struct VS_INPUT float4 position : POSITION; float2 uv : TEXCOORD; float4 color : COLOR; - int data1: DATA1_; + int texture_index : TEXTURE_INDEX; + uint type : TYPE; + uint sampler_index : SAMPLER_INDEX; // s8 texture_index // u8 type // u8 sampler_index @@ -29,9 +31,9 @@ PS_INPUT vs_main(VS_INPUT input) output.position = input.position; output.uv = input.uv; output.color = input.color; - output.texture_index = (input.data1) & 0xFF; - output.type = (input.data1 >> 8) & 0xFF; - output.sampler_index = (input.data1 >> 16) & 0xFF; + output.texture_index = input.texture_index; + output.type = input.type; + output.sampler_index = input.sampler_index; return output; } @@ -207,73 +209,76 @@ float4 ps_main(PS_INPUT input) : SV_TARGET */ const u8 IMAGE_SHADER_VERTEX_BLOB_BYTES[]= { -0x44, 0x58, 0x42, 0x43, 0xd2, 0xac, 0xdf, 0x4b, 0xa1, 0xc2, 0x52, 0x69, 0x40, 0xd6, 0x72, 0x45, -0xd0, 0xb6, 0xe4, 0xbb, 0x01, 0x00, 0x00, 0x00, 0xec, 0x03, 0x00, 0x00, 0x05, 0x00, 0x00, -0x00, 0x34, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x30, 0x01, 0x00, 0x00, 0x0c, 0x02, -0x00, 0x00, 0x50, 0x03, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x64, 0x00, 0x00, 0x00, 0x00, +0x44, 0x58, 0x42, 0x43, 0xfc, 0xe0, 0x4b, 0x9f, 0x60, 0x91, 0x1d, 0xc8, 0xd9, 0xba, 0xdf, 0xf1, +0x5a, 0xd5, 0x8d, 0x2f, 0x01, 0x00, 0x00, 0x00, 0x18, 0x04, 0x00, 0x00, 0x05, 0x00, 0x00, +0x00, 0x34, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x7c, 0x01, 0x00, 0x00, 0x58, 0x02, +0x00, 0x00, 0x7c, 0x03, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x05, 0xfe, 0xff, 0x00, 0x01, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x52, 0x44, 0x31, 0x31, 0x3c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, -0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, 0x31, 0x00, 0x49, 0x53, 0x47, 0x4e, 0x88, 0x00, -0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, +0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, 0x31, 0x00, 0x49, 0x53, 0x47, 0x4e, 0xd4, 0x00, +0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0f, 0x0f, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x7a, 0x00, +0x0f, 0x0f, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, -0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, -0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, -0x4f, 0x52, 0x44, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x44, 0x41, 0x54, 0x41, 0x31, -0x5f, 0x00, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0xd4, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, -0x08, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, -0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xa4, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, -0x00, 0x00, 0x00, 0x03, 0x0c, 0x00, 0x00, 0xad, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, -0x00, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, -0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x0e, 0x00, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, -0x02, 0x0d, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x0b, 0x00, 0x00, 0x53, 0x56, -0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, -0x4f, 0x52, 0x44, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54, 0x45, 0x58, 0x54, 0x55, -0x52, 0x45, 0x5f, 0x49, 0x4e, 0x44, 0x45, 0x58, 0x00, 0x54, 0x59, 0x50, 0x45, 0x00, 0x53, -0x41, 0x4d, 0x50, 0x4c, 0x45, 0x52, 0x5f, 0x49, 0x4e, 0x44, 0x45, 0x58, 0x00, 0x53, 0x48, -0x45, 0x58, 0x3c, 0x01, 0x00, 0x00, 0x50, 0x00, 0x01, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x6a, -0x08, 0x00, 0x01, 0x5f, 0x00, 0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x5f, 0x00, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, -0x03, 0xf2, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x12, 0x10, -0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, -0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0x32, 0x20, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, -0x00, 0x65, 0x00, 0x00, 0x03, 0x12, 0x20, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x65, 0x00, -0x00, 0x03, 0x22, 0x20, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0x42, -0x20, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, -0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, -0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x32, 0x20, 0x10, 0x00, 0x01, 0x00, -0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xf2, -0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x2a, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, -0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x0a, 0x62, -0x20, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07, 0x12, 0x20, 0x10, 0x00, 0x03, 0x00, -0x00, 0x00, 0x0a, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0xff, -0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x94, 0x00, 0x00, 0x00, -0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, +0x00, 0xbe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, +0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, +0x01, 0x01, 0x00, 0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45, +0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54, 0x45, +0x58, 0x54, 0x55, 0x52, 0x45, 0x5f, 0x49, 0x4e, 0x44, 0x45, 0x58, 0x00, 0x54, 0x59, 0x50, +0x45, 0x00, 0x53, 0x41, 0x4d, 0x50, 0x4c, 0x45, 0x52, 0x5f, 0x49, 0x4e, 0x44, 0x45, 0x58, +0x00, 0xab, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0xd4, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, +0x00, 0x08, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, +0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xa4, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, +0x01, 0x00, 0x00, 0x00, 0x03, 0x0c, 0x00, 0x00, 0xad, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0f, 0x00, +0x00, 0x00, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, +0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x0e, 0x00, 0x00, 0xc1, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, +0x00, 0x02, 0x0d, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x0b, 0x00, 0x00, 0x53, +0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45, 0x58, 0x43, +0x4f, 0x4f, 0x52, 0x44, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54, 0x45, 0x58, 0x54, +0x55, 0x52, 0x45, 0x5f, 0x49, 0x4e, 0x44, 0x45, 0x58, 0x00, 0x54, 0x59, 0x50, 0x45, 0x00, +0x53, 0x41, 0x4d, 0x50, 0x4c, 0x45, 0x52, 0x5f, 0x49, 0x4e, 0x44, 0x45, 0x58, 0x00, 0x53, +0x48, 0x45, 0x58, 0x1c, 0x01, 0x00, 0x00, 0x50, 0x00, 0x01, 0x00, 0x47, 0x00, 0x00, 0x00, +0x6a, 0x08, 0x00, 0x01, 0x5f, 0x00, 0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, +0x00, 0x5f, 0x00, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5f, 0x00, +0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x12, +0x10, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x12, 0x10, 0x10, 0x00, +0x04, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x12, 0x10, 0x10, 0x00, 0x05, 0x00, 0x00, +0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, +0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0x32, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, +0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, +0x12, 0x20, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0x22, 0x20, 0x10, +0x00, 0x03, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0x42, 0x20, 0x10, 0x00, 0x03, 0x00, +0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, +0x1e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x32, 0x20, 0x10, 0x00, +0x01, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, +0x05, 0xf2, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, 0x02, 0x00, +0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x12, 0x20, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0a, +0x10, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x22, 0x20, 0x10, 0x00, +0x03, 0x00, 0x00, 0x00, 0x0a, 0x10, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, +0x05, 0x42, 0x20, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0a, 0x10, 0x10, 0x00, 0x05, 0x00, +0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x94, 0x00, 0x00, 0x00, 0x07, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; const u8 IMAGE_SHADER_PIXEL_BLOB_BYTES[]= { 0x44, 0x58, 0x42, 0x43, 0x0a, 0x93, 0xe4, 0x42, 0xda, 0x43, 0x47, 0xb4, 0xcb, 0xf4, 0x07, 0x85, diff --git a/oogabooga/dev/d3d11_image_shader.hlsl b/oogabooga/dev/d3d11_image_shader.hlsl index e1dd68c..c1ce13c 100644 --- a/oogabooga/dev/d3d11_image_shader.hlsl +++ b/oogabooga/dev/d3d11_image_shader.hlsl @@ -3,7 +3,9 @@ struct VS_INPUT float4 position : POSITION; float2 uv : TEXCOORD; float4 color : COLOR; - int data1: DATA1_; + int texture_index : TEXTURE_INDEX; + uint type : TYPE; + uint sampler_index : SAMPLER_INDEX; // s8 texture_index // u8 type // u8 sampler_index @@ -26,9 +28,9 @@ PS_INPUT vs_main(VS_INPUT input) output.position = input.position; output.uv = input.uv; output.color = input.color; - output.texture_index = (input.data1) & 0xFF; - output.type = (input.data1 >> 8) & 0xFF; - output.sampler_index = (input.data1 >> 16) & 0xFF; + output.texture_index = input.texture_index; + output.type = input.type; + output.sampler_index = input.sampler_index; return output; } diff --git a/oogabooga/drawing.c b/oogabooga/drawing.c index 071fbd7..54ad895 100644 --- a/oogabooga/drawing.c +++ b/oogabooga/drawing.c @@ -147,6 +147,7 @@ Draw_Quad *draw_quad_projected(Draw_Quad quad, Matrix4 world_to_clip) { quad.image_min_filter = GFX_FILTER_MODE_NEAREST; quad.image_mag_filter = GFX_FILTER_MODE_NEAREST; + quad.z = 0; if (draw_frame.z_count > 0) quad.z = draw_frame.z_stack[draw_frame.z_count-1]; diff --git a/oogabooga/gfx_impl_d3d11.c b/oogabooga/gfx_impl_d3d11.c index ffa302f..3178405 100644 --- a/oogabooga/gfx_impl_d3d11.c +++ b/oogabooga/gfx_impl_d3d11.c @@ -480,7 +480,7 @@ void gfx_init() { - D3D11_INPUT_ELEMENT_DESC layout[4]; + D3D11_INPUT_ELEMENT_DESC layout[6]; memset(layout, 0, sizeof(layout)); layout[0].SemanticName = "POSITION"; @@ -507,15 +507,31 @@ void gfx_init() { layout[2].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; layout[2].InstanceDataStepRate = 0; - layout[3].SemanticName = "DATA1_"; + layout[3].SemanticName = "TEXTURE_INDEX"; layout[3].SemanticIndex = 0; - layout[3].Format = DXGI_FORMAT_R32_SINT; + layout[3].Format = DXGI_FORMAT_R8_SINT; layout[3].InputSlot = 0; - layout[3].AlignedByteOffset = offsetof(D3D11_Vertex, data1); + layout[3].AlignedByteOffset = offsetof(D3D11_Vertex, texture_index); layout[3].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; layout[3].InstanceDataStepRate = 0; - hr = ID3D11Device_CreateInputLayout(d3d11_device, layout, 4, vs_buffer, vs_size, &d3d11_image_vertex_layout); + layout[4].SemanticName = "TYPE"; + layout[4].SemanticIndex = 0; + layout[4].Format = DXGI_FORMAT_R8_UINT; + layout[4].InputSlot = 0; + layout[4].AlignedByteOffset = offsetof(D3D11_Vertex, type); + layout[4].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; + layout[4].InstanceDataStepRate = 0; + + layout[5].SemanticName = "SAMPLER_INDEX"; + layout[5].SemanticIndex = 0; + layout[5].Format = DXGI_FORMAT_R8_SINT; + layout[5].InputSlot = 0; + layout[5].AlignedByteOffset = offsetof(D3D11_Vertex, sampler); + layout[5].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; + layout[5].InstanceDataStepRate = 0; + + hr = ID3D11Device_CreateInputLayout(d3d11_device, layout, 6, vs_buffer, vs_size, &d3d11_image_vertex_layout); win32_check_hr(hr); #if OOGABOOGA_DEV