Procházet zdrojové kódy

Make sure vertex buffers don't overlap on GPU between frames

Karl Zylinski před 6 měsíci
rodič
revize
ca5a1e60d5
2 změnil soubory, kde provedl 8 přidání a 2 odebrání
  1. 1 1
      README.md
  2. 7 1
      backend_d3d11.odin

+ 1 - 1
README.md

@@ -19,7 +19,7 @@ Here follows my near-future TODO list
 * Is the 1/zoom in set_camera wrong? Is the matrix multiply order wrong? Hmmmm...
 * Textures: Make the sampler state configurable
 * Textures D3D11: Do we need the SRV in the texture?
-* Flashing textures in Abyss
+* Flashing textures in Abyss -- Better now but still flashes when you use nose... Check the "odd_frame" stuff in d3d backend
 * Do proper checks of vertex count and dispatch rendering when full
 	* What happens when list is full? We can't just empty the vertex list due to being used by input assembler etc.
 * Should we sort by depth? Maybe we should use Vec3 because some 2D games rely on it?

+ 7 - 1
backend_d3d11.odin

@@ -174,7 +174,10 @@ clear = proc(color: Color) {
 
 present = proc() {
 	ch(s.swapchain->Present(1, {}))
-	s.vertex_buffer_offset = 0
+	if s.odd_frame {
+		s.vertex_buffer_offset = 0
+	}
+	s.odd_frame = !s.odd_frame
 },
 
 draw = proc(shd: Shader, texture: Texture_Handle, view_proj: Mat4, vertex_buffer: []u8) {
@@ -535,6 +538,9 @@ D3D11_State :: struct {
 	blend_state: ^d3d11.IBlendState,
 	sampler_state: ^d3d11.ISamplerState,
 
+	// 0 or 1
+	odd_frame: bool,
+
 	textures: hm.Handle_Map(D3D11_Texture, Texture_Handle, 1024*10),
 	shaders: hm.Handle_Map(D3D11_Shader, Shader_Handle, 1024*10),