use float2x3 for xforms in shaders
This commit is contained in:
parent
dc46fb270d
commit
8aa9f1402b
@ -23,8 +23,3 @@ float4 linear_from_srgb32(uint srgb32)
|
|||||||
res.a = ((srgb32 >> 24) & 0xFF) / 255.0;
|
res.a = ((srgb32 >> 24) & 0xFF) / 255.0;
|
||||||
return linear_from_srgb(res);
|
return linear_from_srgb(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
float2 xform_mul(struct xform xf, float2 v)
|
|
||||||
{
|
|
||||||
return xf.bx * v.x + xf.by * v.y + xf.og;
|
|
||||||
}
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
#include "shaders/common.hlsl"
|
#include "shaders/common.hlsl"
|
||||||
|
|
||||||
struct vs_instance {
|
struct vs_instance {
|
||||||
struct xform xf;
|
float2x3 xf;
|
||||||
float line_thickness;
|
float line_thickness;
|
||||||
float line_spacing;
|
float line_spacing;
|
||||||
float2 offset;
|
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];
|
vs_instance instance = G_instance_buffer[G_instance_offset + instance_id];
|
||||||
float2 vert = G_quad_verts[vertex_id];
|
float2 vert = G_quad_verts[vertex_id];
|
||||||
|
float2 world_pos = mul(instance.xf, float3(vert, 1)).xy;
|
||||||
float2 world_pos = xform_mul(instance.xf, vert);
|
|
||||||
float4 screen_pos = mul(G_projection, float4(world_pos, 0, 1));
|
|
||||||
|
|
||||||
ps_input output;
|
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_thickness = instance.line_thickness;
|
||||||
output.line_spacing = instance.line_spacing;
|
output.line_spacing = instance.line_spacing;
|
||||||
output.offset = instance.offset;
|
output.offset = instance.offset;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#include "shaders/common.hlsl"
|
#include "shaders/common.hlsl"
|
||||||
|
|
||||||
struct vs_instance {
|
struct vs_instance {
|
||||||
struct xform xf;
|
float2x3 xf;
|
||||||
float2 uv0;
|
float2 uv0;
|
||||||
float2 uv1;
|
float2 uv1;
|
||||||
uint tint_srgb;
|
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];
|
vs_instance instance = G_instance_buffer[G_instance_offset + instance_id];
|
||||||
float2 vert = G_quad_verts[vertex_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 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;
|
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.uv = instance.uv0 + uv_factor * (instance.uv1 - instance.uv0);
|
||||||
output.tint_lin = linear_from_srgb32(instance.tint_srgb);
|
output.tint_lin = linear_from_srgb32(instance.tint_srgb);
|
||||||
|
|
||||||
|
|||||||
@ -655,7 +655,7 @@ INLINE void __prof_dx11_zone_cleanup_func(TracyCD3D11ZoneCtx *ctx) { ___tracy_d3
|
|||||||
|
|
||||||
#define __profalloc(ptr, size) TracyCAlloc((ptr), (size))
|
#define __profalloc(ptr, size) TracyCAlloc((ptr), (size))
|
||||||
#define __proffree(ptr) TracyCFree((ptr))
|
#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 __profframe(name) TracyCFrameMarkNamed((name))
|
||||||
#define __profthread(name) TracyCSetThreadName((name))
|
#define __profthread(name) TracyCSetThreadName((name))
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
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
|
#if DX11_SHADER_DEBUG
|
||||||
flags |= D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION | D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_WARNINGS_ARE_ERRORS;
|
flags |= D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION | D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_WARNINGS_ARE_ERRORS;
|
||||||
#else
|
#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)
|
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);
|
void *data = arena_push_array_no_zero(&buffer->cpu_buffer_arena, u8, size);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -1017,6 +1016,7 @@ INTERNAL void dx11_buffer_submit(struct dx11_buffer *buffer)
|
|||||||
|
|
||||||
struct gpu_cmd_store gpu_cmd_store_alloc(void)
|
struct gpu_cmd_store gpu_cmd_store_alloc(void)
|
||||||
{
|
{
|
||||||
|
__prof;
|
||||||
struct dx11_cmd_store *store = NULL;
|
struct dx11_cmd_store *store = NULL;
|
||||||
{
|
{
|
||||||
struct arena cpu_cmds_arena = ZI;
|
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)
|
void gpu_cmd_store_release(struct gpu_cmd_store gpu_cmd_store)
|
||||||
{
|
{
|
||||||
|
__prof;
|
||||||
/* TODO */
|
/* TODO */
|
||||||
(UNUSED)gpu_cmd_store;
|
(UNUSED)gpu_cmd_store;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpu_push_cmd(struct gpu_cmd_store gpu_cmd_store, struct gpu_cmd_params params)
|
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;
|
struct dx11_cmd_store *store = (struct dx11_cmd_store *)gpu_cmd_store.handle;
|
||||||
|
|
||||||
switch (params.kind) {
|
switch (params.kind) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user