Sfoglia il codice sorgente

Fix how vertex buffer offsets work

Karl Zylinski 6 mesi fa
parent
commit
b891ccd9c5
2 ha cambiato i file con 5 aggiunte e 5 eliminazioni
  1. 2 1
      README.md
  2. 3 4
      backend_d3d11.odin

+ 2 - 1
README.md

@@ -18,7 +18,7 @@ Here follows my near-future TODO list
 
 * Textures: Make the sampler state configurable
 * Textures D3D11: Do we need the SRV in the texture?
-* 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?
@@ -26,6 +26,7 @@ Here follows my near-future TODO list
 * Shaders: Reflect and expose samplers
 
 ## DONE
+* Flashing textures in Abyss -- Better now but still flashes when you use nose... Check the "odd_frame" stuff in d3d backend
 * Is the 1/zoom in set_camera wrong? Is the matrix multiply order wrong? Hmmmm...
 * Fix the depedency on D3D stuff so we can move load_shader etc
 * Shaders: Basic loading

+ 3 - 4
backend_d3d11.odin

@@ -200,7 +200,7 @@ draw = proc(shd: Shader, texture: Texture_Handle, view_proj: Mat4, vertex_buffer
 	dc := s.device_context
 
 	vb_data: d3d11.MAPPED_SUBRESOURCE
-	ch(dc->Map(s.vertex_buffer_gpu, 0, .WRITE_NO_OVERWRITE, {}, &vb_data))
+	ch(dc->Map(s.vertex_buffer_gpu, 0, .WRITE_DISCARD, {}, &vb_data))
 	{
 		gpu_map := slice.from_ptr((^u8)(vb_data.pData), VERTEX_BUFFER_MAX)
 		copy(
@@ -210,11 +210,10 @@ draw = proc(shd: Shader, texture: Texture_Handle, view_proj: Mat4, vertex_buffer
 	}
 	dc->Unmap(s.vertex_buffer_gpu, 0)
 
-
 	dc->IASetPrimitiveTopology(.TRIANGLELIST)
 
 	dc->IASetInputLayout(d3d_shd.input_layout)
-	vertex_buffer_offset := u32(0)
+	vertex_buffer_offset := u32(s.vertex_buffer_offset)
 	vertex_buffer_stride := u32(shd.vertex_size)
 	dc->IASetVertexBuffers(0, 1, &s.vertex_buffer_gpu, &vertex_buffer_stride, &vertex_buffer_offset)
 
@@ -267,7 +266,7 @@ draw = proc(shd: Shader, texture: Texture_Handle, view_proj: Mat4, vertex_buffer
 	dc->OMSetDepthStencilState(s.depth_stencil_state, 0)
 	dc->OMSetBlendState(s.blend_state, nil, ~u32(0))
 
-	dc->Draw(u32(len(vertex_buffer)/shd.vertex_size), u32(s.vertex_buffer_offset/shd.vertex_size))
+	dc->Draw(u32(len(vertex_buffer)/shd.vertex_size), 0)
 	s.vertex_buffer_offset += len(vertex_buffer)
 	log_messages()
 },