Fixes bad resource usage in rendering

D3D11 is quite strict about how resources are supposed to be used - read/write & CPU access.
This changes Tex2DKind and BufferKind into one uniform ResourceKind (because it's the same thing really).

And it is more strict about usage:
1) Static is not allowed to update, resource is immutable, data provided at creation
2) Dynamic allows CPU to update GPU resource occasionally via UpdateSubresource
3) Stream allows CPU to update GPU resource often via Map/Unmap (currently unused)
This commit is contained in:
Martins Mozeiko
2024-05-24 14:04:42 -07:00
committed by Ryan Fleury
parent 7e0611e7f1
commit fd982d38fc
11 changed files with 80 additions and 87 deletions
+3 -2
View File
@@ -63,7 +63,7 @@ struct R_D3D11_Tex2D
U64 generation;
ID3D11Texture2D *texture;
ID3D11ShaderResourceView *view;
R_Tex2DKind kind;
R_ResourceKind kind;
Vec2S32 size;
R_Tex2DFormat format;
};
@@ -73,7 +73,7 @@ struct R_D3D11_Buffer
R_D3D11_Buffer *next;
U64 generation;
ID3D11Buffer *buffer;
R_BufferKind kind;
R_ResourceKind kind;
U64 size;
};
@@ -173,5 +173,6 @@ internal R_Handle r_d3d11_handle_from_tex2d(R_D3D11_Tex2D *texture);
internal R_D3D11_Buffer *r_d3d11_buffer_from_handle(R_Handle handle);
internal R_Handle r_d3d11_handle_from_buffer(R_D3D11_Buffer *buffer);
internal ID3D11Buffer *r_d3d11_instance_buffer_from_size(U64 size);
internal void r_res_kind_to_usage(R_ResourceKind kind, D3D11_USAGE* d3d11_usage, UINT* cpu_access_flags);
#endif // RENDER_D3D11_H