From 3684c6404f6faea71e48092428ab2ac9b58081d8 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 3 May 2016 22:22:12 -0400 Subject: [PATCH] Proven through deliberate inefficiency: the issues are (i) texture upload; and (ii) buffer wraparound. --- Outputs/CRT/Internals/CRTConstants.hpp | 4 ++-- .../CRT/Internals/CRTInputBufferBuilder.hpp | 2 +- Outputs/CRT/Internals/CRTOpenGL.cpp | 19 ++++++++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Outputs/CRT/Internals/CRTConstants.hpp b/Outputs/CRT/Internals/CRTConstants.hpp index b6edb5013..743fa4b57 100644 --- a/Outputs/CRT/Internals/CRTConstants.hpp +++ b/Outputs/CRT/Internals/CRTConstants.hpp @@ -40,8 +40,8 @@ const GLsizei IntermediateBufferWidth = 2048; const GLsizei IntermediateBufferHeight = 2048; // Some internal buffer sizes -const GLsizeiptr OutputVertexBufferDataSize = 59904; // a multiple of 6 * OutputVertexSize -const GLsizeiptr SourceVertexBufferDataSize = 87360; // a multiple of 2 * SourceVertexSize +const GLsizeiptr OutputVertexBufferDataSize = 5990400; // a multiple of 6 * OutputVertexSize +const GLsizeiptr SourceVertexBufferDataSize = 8736000; // a multiple of 2 * SourceVertexSize } } diff --git a/Outputs/CRT/Internals/CRTInputBufferBuilder.hpp b/Outputs/CRT/Internals/CRTInputBufferBuilder.hpp index 5e053f817..a65182887 100644 --- a/Outputs/CRT/Internals/CRTInputBufferBuilder.hpp +++ b/Outputs/CRT/Internals/CRTInputBufferBuilder.hpp @@ -46,7 +46,7 @@ struct CRTInputBufferBuilder { inline uint16_t get_last_write_y_position() { - return _write_y_position; + return _write_y_position % InputBufferBuilderHeight; } inline size_t get_bytes_per_pixel() diff --git a/Outputs/CRT/Internals/CRTOpenGL.cpp b/Outputs/CRT/Internals/CRTOpenGL.cpp index 8c6b5b6d7..e5ee9206c 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.cpp +++ b/Outputs/CRT/Internals/CRTOpenGL.cpp @@ -270,14 +270,19 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out } // upload new source pixels - glActiveTexture(source_data_texture_unit); - for(int c = 0; c < number_of_texture_upload_zones; c++) + if(number_of_texture_upload_zones) { - glTexSubImage2D( GL_TEXTURE_2D, 0, - 0, texture_upload_zones[c*2], - InputBufferBuilderWidth, texture_upload_zones[c*2 + 1], - formatForDepth(_buffer_builder->get_bytes_per_pixel()), GL_UNSIGNED_BYTE, - (void *)((size_t)texture_upload_zones[c*2] * InputBufferBuilderWidth * _buffer_builder->get_bytes_per_pixel())); + glActiveTexture(source_data_texture_unit); + glTexImage2D(GL_TEXTURE_2D, 0, internalFormatForDepth(_buffer_builder->get_bytes_per_pixel()), InputBufferBuilderWidth, InputBufferBuilderHeight, 0, formatForDepth(_buffer_builder->get_bytes_per_pixel()), GL_UNSIGNED_BYTE, (void *)0); +// for(int c = 0; c < number_of_texture_upload_zones; c++) +// { +// glTexSubImage2D( GL_TEXTURE_2D, 0, +// 0, texture_upload_zones[c*2], +// InputBufferBuilderWidth, texture_upload_zones[c*2 + 1], +// formatForDepth(_buffer_builder->get_bytes_per_pixel()), GL_UNSIGNED_BYTE, +// (void *)((size_t)texture_upload_zones[c*2] * InputBufferBuilderWidth * _buffer_builder->get_bytes_per_pixel())); +// } +// glFinish(); } struct RenderStage {