forked from eden-emu/eden
		
	gl_rasterizer: Move index buffer uploading to its own method
This commit is contained in:
		
							parent
							
								
									772c86a260
								
							
						
					
					
						commit
						2e39c20da5
					
				
					 2 changed files with 18 additions and 7 deletions
				
			
		|  | @ -215,7 +215,15 @@ void RasterizerOpenGL::SetupVertexBuffer(GLuint vao) { | ||||||
|     gpu.dirty_flags.vertex_array.reset(); |     gpu.dirty_flags.vertex_array.reset(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| DrawParameters RasterizerOpenGL::SetupDraw() { | GLintptr RasterizerOpenGL::SetupIndexBuffer() { | ||||||
|  |     if (accelerate_draw != AccelDraw::Indexed) { | ||||||
|  |         return 0; | ||||||
|  |     } | ||||||
|  |     const auto& regs = system.GPU().Maxwell3D().regs; | ||||||
|  |     return buffer_cache.UploadMemory(regs.index_array.IndexStart(), CalculateIndexBufferSize()); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | DrawParameters RasterizerOpenGL::SetupDraw(GLintptr index_buffer_offset) { | ||||||
|     const auto& gpu = system.GPU().Maxwell3D(); |     const auto& gpu = system.GPU().Maxwell3D(); | ||||||
|     const auto& regs = gpu.regs; |     const auto& regs = gpu.regs; | ||||||
|     const bool is_indexed = accelerate_draw == AccelDraw::Indexed; |     const bool is_indexed = accelerate_draw == AccelDraw::Indexed; | ||||||
|  | @ -230,8 +238,7 @@ DrawParameters RasterizerOpenGL::SetupDraw() { | ||||||
|         MICROPROFILE_SCOPE(OpenGL_Index); |         MICROPROFILE_SCOPE(OpenGL_Index); | ||||||
|         params.index_format = MaxwellToGL::IndexFormat(regs.index_array.format); |         params.index_format = MaxwellToGL::IndexFormat(regs.index_array.format); | ||||||
|         params.count = regs.index_array.count; |         params.count = regs.index_array.count; | ||||||
|         params.index_buffer_offset = |         params.index_buffer_offset = index_buffer_offset; | ||||||
|             buffer_cache.UploadMemory(regs.index_array.IndexStart(), CalculateIndexBufferSize()); |  | ||||||
|         params.base_vertex = static_cast<GLint>(regs.vb_element_base); |         params.base_vertex = static_cast<GLint>(regs.vb_element_base); | ||||||
|     } else { |     } else { | ||||||
|         params.count = regs.vertex_buffer.count; |         params.count = regs.vertex_buffer.count; | ||||||
|  | @ -643,10 +650,12 @@ void RasterizerOpenGL::DrawArrays() { | ||||||
|         gpu.dirty_flags.vertex_array.set(); |         gpu.dirty_flags.vertex_array.set(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const GLuint vao = SetupVertexFormat(); |     const GLuint vertex_array = SetupVertexFormat(); | ||||||
|     SetupVertexBuffer(vao); |  | ||||||
| 
 | 
 | ||||||
|     DrawParameters params = SetupDraw(); |     SetupVertexBuffer(vertex_array); | ||||||
|  |     const GLintptr index_buffer_offset = SetupIndexBuffer(); | ||||||
|  | 
 | ||||||
|  |     DrawParameters params = SetupDraw(index_buffer_offset); | ||||||
|     texture_cache.GuardSamplers(true); |     texture_cache.GuardSamplers(true); | ||||||
|     SetupShaders(params.primitive_mode); |     SetupShaders(params.primitive_mode); | ||||||
|     texture_cache.GuardSamplers(false); |     texture_cache.GuardSamplers(false); | ||||||
|  |  | ||||||
|  | @ -220,7 +220,9 @@ private: | ||||||
| 
 | 
 | ||||||
|     void SetupVertexBuffer(GLuint vao); |     void SetupVertexBuffer(GLuint vao); | ||||||
| 
 | 
 | ||||||
|     DrawParameters SetupDraw(); |     GLintptr SetupIndexBuffer(); | ||||||
|  | 
 | ||||||
|  |     DrawParameters SetupDraw(GLintptr index_buffer_offset); | ||||||
| 
 | 
 | ||||||
|     void SetupShaders(GLenum primitive_mode); |     void SetupShaders(GLenum primitive_mode); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 ReinUsesLisp
						ReinUsesLisp