use float2x3 for xforms in shaders

This commit is contained in:
jacob 2025-05-28 03:24:26 -05:00
parent dc46fb270d
commit 8aa9f1402b
5 changed files with 11 additions and 18 deletions

View File

@ -23,8 +23,3 @@ float4 linear_from_srgb32(uint srgb32)
res.a = ((srgb32 >> 24) & 0xFF) / 255.0;
return linear_from_srgb(res);
}
float2 xform_mul(struct xform xf, float2 v)
{
return xf.bx * v.x + xf.by * v.y + xf.og;
}

View File

@ -1,7 +1,7 @@
#include "shaders/common.hlsl"
struct vs_instance {
struct xform xf;
float2x3 xf;
float line_thickness;
float line_spacing;
float2 offset;
@ -51,12 +51,10 @@ ps_input vs_main(uint instance_id : SV_InstanceID, uint vertex_id : SV_VertexID)
{
vs_instance instance = G_instance_buffer[G_instance_offset + instance_id];
float2 vert = G_quad_verts[vertex_id];
float2 world_pos = xform_mul(instance.xf, vert);
float4 screen_pos = mul(G_projection, float4(world_pos, 0, 1));
float2 world_pos = mul(instance.xf, float3(vert, 1)).xy;
ps_input output;
output.screen_pos = screen_pos;
output.screen_pos = mul(G_projection, float4(world_pos, 0, 1));
output.line_thickness = instance.line_thickness;
output.line_spacing = instance.line_spacing;
output.offset = instance.offset;

View File

@ -1,7 +1,7 @@
#include "shaders/common.hlsl"
struct vs_instance {
struct xform xf;
float2x3 xf;
float2 uv0;
float2 uv1;
uint tint_srgb;
@ -51,13 +51,11 @@ ps_input vs_main(uint instance_id : SV_InstanceID, uint vertex_id : SV_VertexID)
{
vs_instance instance = G_instance_buffer[G_instance_offset + instance_id];
float2 vert = G_quad_verts[vertex_id];
float2 world_pos = mul(instance.xf, float3(vert, 1)).xy;
float2 uv_factor = G_uv_factors[vertex_id];
float2 world_pos = xform_mul(instance.xf, vert);
float4 screen_pos = mul(G_projection, float4(world_pos, 0, 1));
ps_input output;
output.screen_pos = screen_pos;
output.screen_pos = mul(G_projection, float4(world_pos, 0, 1));
output.uv = instance.uv0 + uv_factor * (instance.uv1 - instance.uv0);
output.tint_lin = linear_from_srgb32(instance.tint_srgb);

View File

@ -655,7 +655,7 @@ INLINE void __prof_dx11_zone_cleanup_func(TracyCD3D11ZoneCtx *ctx) { ___tracy_d3
#define __profalloc(ptr, size) TracyCAlloc((ptr), (size))
#define __proffree(ptr) TracyCFree((ptr))
#define __profmsg(txt, len, col) TracyCMessageC((txt), (len), (col));
#define __profmsg(txt, len, col) TracyCMessageC((txt), (len), BGR(col));
#define __profframe(name) TracyCFrameMarkNamed((name))
#define __profthread(name) TracyCSetThreadName((name))

View File

@ -731,7 +731,7 @@ INTERNAL struct string shader_alloc(struct arena *arena, struct dx11_shader *sha
struct dx11_include_handler include_handler = dx11_include_handler_alloc(shader);
u32 flags = D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR;
u32 flags = 0;
#if DX11_SHADER_DEBUG
flags |= D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION | D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_WARNINGS_ARE_ERRORS;
#else
@ -952,7 +952,6 @@ INTERNAL void dx11_buffer_release(struct dx11_buffer *buffer)
INTERNAL void *dx11_buffer_push(struct dx11_buffer *buffer, u64 size)
{
__prof;
void *data = arena_push_array_no_zero(&buffer->cpu_buffer_arena, u8, size);
return data;
}
@ -1017,6 +1016,7 @@ INTERNAL void dx11_buffer_submit(struct dx11_buffer *buffer)
struct gpu_cmd_store gpu_cmd_store_alloc(void)
{
__prof;
struct dx11_cmd_store *store = NULL;
{
struct arena cpu_cmds_arena = ZI;
@ -1107,12 +1107,14 @@ struct gpu_cmd_store gpu_cmd_store_alloc(void)
void gpu_cmd_store_release(struct gpu_cmd_store gpu_cmd_store)
{
__prof;
/* TODO */
(UNUSED)gpu_cmd_store;
}
void gpu_push_cmd(struct gpu_cmd_store gpu_cmd_store, struct gpu_cmd_params params)
{
__prof;
struct dx11_cmd_store *store = (struct dx11_cmd_store *)gpu_cmd_store.handle;
switch (params.kind) {