From 47ae402f7e1c4568ccce55d12f4c3660a48e8d76 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 10 May 2016 19:11:48 -0400 Subject: [PATCH 1/5] Introduced a shorthand for setting up array attributes. --- Outputs/CRT/Internals/CRTOpenGL.cpp | 17 ++--------------- Outputs/CRT/Internals/Shaders/Shader.cpp | 8 ++++++++ Outputs/CRT/Internals/Shaders/Shader.hpp | 8 ++++++++ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Outputs/CRT/Internals/CRTOpenGL.cpp b/Outputs/CRT/Internals/CRTOpenGL.cpp index 29c9fd896..a7691a8ec 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.cpp +++ b/Outputs/CRT/Internals/CRTOpenGL.cpp @@ -426,21 +426,8 @@ void OpenGLOutputBuilder::prepare_output_vertex_array() { glBindVertexArray(output_vertex_array); glBindBuffer(GL_ARRAY_BUFFER, output_array_buffer); - - const GLsizei vertexStride = OutputVertexSize; - size_t offset = 0; - - const char *attributes[] = {"horizontal", "vertical", nullptr}; - const char **attribute = attributes; - while(*attribute) - { - GLint attributeLocation = output_shader_program->get_attrib_location(*attribute); - glEnableVertexAttribArray((GLuint)attributeLocation); - glVertexAttribPointer((GLuint)attributeLocation, 2, GL_UNSIGNED_SHORT, GL_FALSE, vertexStride, (void *)offset); - glVertexAttribDivisor((GLuint)attributeLocation, 1); - offset += 4; - attribute++; - } + output_shader_program->enable_vertex_attribute_with_pointer("horizontal", 2, GL_UNSIGNED_SHORT, GL_FALSE, OutputVertexSize, (void *)OutputVertexOffsetOfHorizontal, 1); + output_shader_program->enable_vertex_attribute_with_pointer("vertical", 2, GL_UNSIGNED_SHORT, GL_FALSE, OutputVertexSize, (void *)OutputVertexOffsetOfVertical, 1); } } diff --git a/Outputs/CRT/Internals/Shaders/Shader.cpp b/Outputs/CRT/Internals/Shaders/Shader.cpp index cfb69a48d..78dd2fe8e 100644 --- a/Outputs/CRT/Internals/Shaders/Shader.cpp +++ b/Outputs/CRT/Internals/Shaders/Shader.cpp @@ -112,3 +112,11 @@ GLint Shader::get_uniform_location(const GLchar *name) { return glGetUniformLocation(_shader_program, name); } + +void Shader::enable_vertex_attribute_with_pointer(const char *name, GLint size, GLenum type, GLboolean normalised, GLsizei stride, const GLvoid *pointer, GLuint divisor) +{ + GLint location = get_attrib_location(name); + glEnableVertexAttribArray((GLuint)location); + glVertexAttribPointer((GLuint)location, size, type, normalised, stride, pointer); + glVertexAttribDivisor((GLuint)location, divisor); +} diff --git a/Outputs/CRT/Internals/Shaders/Shader.hpp b/Outputs/CRT/Internals/Shaders/Shader.hpp index 42ca1a099..94d24cb2f 100644 --- a/Outputs/CRT/Internals/Shaders/Shader.hpp +++ b/Outputs/CRT/Internals/Shaders/Shader.hpp @@ -66,6 +66,14 @@ public: */ GLint get_uniform_location(const GLchar *name); + /*! + Shorthand for an appropriate sequence of: + * @c get_attrib_location; + * @c glEnableVertexAttribArray; + * @c glVertexAttribPointer; + * @c glVertexAttribDivisor. + */ + void enable_vertex_attribute_with_pointer(const char *name, GLint size, GLenum type, GLboolean normalised, GLsizei stride, const GLvoid *pointer, GLuint divisor); private: GLuint compile_shader(const char *source, GLenum type); From 7369139f7e919f7426466845c61d54b3ed4043cd Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 10 May 2016 19:14:57 -0400 Subject: [PATCH 2/5] =?UTF-8?q?Realised=20that=20phase=20time=20can=20fit?= =?UTF-8?q?=20inside=20a=20single=20byte,=20since=20it's=20always=20(well)?= =?UTF-8?q?=20within=20the=20first=20quarter=20of=20the=20line=20=E2=80=94?= =?UTF-8?q?=20and=20if=20it=20somehow=20weren't=20(=3F)=20then=20taking=20?= =?UTF-8?q?it=20modulo=20the=20frequency=20would=20do.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Outputs/CRT/CRT.cpp | 2 +- Outputs/CRT/Internals/CRTOpenGL.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Outputs/CRT/CRT.cpp b/Outputs/CRT/CRT.cpp index 74c50d7e4..1d62830e9 100644 --- a/Outputs/CRT/CRT.cpp +++ b/Outputs/CRT/CRT.cpp @@ -106,7 +106,7 @@ Flywheel::SyncEvent CRT::get_next_horizontal_sync_event(bool hsync_is_requested, #define source_output_position_y(v) (*(uint16_t *)&next_run[SourceVertexSize*v + SourceVertexOffsetOfOutputPosition + 2]) #define source_phase(v) next_run[SourceVertexSize*v + SourceVertexOffsetOfPhaseAndAmplitude + 0] #define source_amplitude(v) next_run[SourceVertexSize*v + SourceVertexOffsetOfPhaseAndAmplitude + 1] -#define source_phase_time(v) (*(uint16_t *)&next_run[SourceVertexSize*v + SourceVertexOffsetOfPhaseTime]) +#define source_phase_time(v) next_run[SourceVertexSize*v + SourceVertexOffsetOfPhaseTime] void CRT::advance_cycles(unsigned int number_of_cycles, unsigned int source_divider, bool hsync_requested, bool vsync_requested, const bool vsync_charging, const Scan::Type type, uint16_t tex_x, uint16_t tex_y) { diff --git a/Outputs/CRT/Internals/CRTOpenGL.cpp b/Outputs/CRT/Internals/CRTOpenGL.cpp index a7691a8ec..f89401b55 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.cpp +++ b/Outputs/CRT/Internals/CRTOpenGL.cpp @@ -410,7 +410,7 @@ void OpenGLOutputBuilder::prepare_source_vertex_array() glVertexAttribPointer((GLuint)inputPositionAttribute, 2, GL_UNSIGNED_SHORT, GL_FALSE, vertexStride, (void *)SourceVertexOffsetOfInputPosition); glVertexAttribPointer((GLuint)outputPositionAttribute, 2, GL_UNSIGNED_SHORT, GL_FALSE, vertexStride, (void *)SourceVertexOffsetOfOutputPosition); glVertexAttribPointer((GLuint)phaseAndAmplitudeAttribute, 2, GL_UNSIGNED_BYTE, GL_TRUE, vertexStride, (void *)SourceVertexOffsetOfPhaseAndAmplitude); - glVertexAttribPointer((GLuint)phaseTimeAttribute, 2, GL_UNSIGNED_SHORT, GL_FALSE, vertexStride, (void *)SourceVertexOffsetOfPhaseTime); + glVertexAttribPointer((GLuint)phaseTimeAttribute, 1, GL_UNSIGNED_BYTE, GL_FALSE, vertexStride, (void *)SourceVertexOffsetOfPhaseTime); } } From b6d2c8cb63c218db250b423b9924d9b0665a1086 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 10 May 2016 19:50:12 -0400 Subject: [PATCH 3/5] Switched to instaced drawing for source[/intermediate] runs too, reducing that data transfer footprint by 50%. --- Outputs/CRT/CRT.cpp | 55 +++++++++---------- Outputs/CRT/Internals/CRTConstants.hpp | 10 ++-- Outputs/CRT/Internals/CRTOpenGL.cpp | 24 ++------ .../Internals/Shaders/IntermediateShader.cpp | 20 ++++--- 4 files changed, 50 insertions(+), 59 deletions(-) diff --git a/Outputs/CRT/CRT.cpp b/Outputs/CRT/CRT.cpp index 1d62830e9..92f2c7a96 100644 --- a/Outputs/CRT/CRT.cpp +++ b/Outputs/CRT/CRT.cpp @@ -100,13 +100,15 @@ Flywheel::SyncEvent CRT::get_next_horizontal_sync_event(bool hsync_is_requested, #define output_position_y() (*(uint16_t *)&next_run[OutputVertexOffsetOfVertical + 0]) #define output_tex_y() (*(uint16_t *)&next_run[OutputVertexOffsetOfVertical + 2]) -#define source_input_position_x(v) (*(uint16_t *)&next_run[SourceVertexSize*v + SourceVertexOffsetOfInputPosition + 0]) -#define source_input_position_y(v) (*(uint16_t *)&next_run[SourceVertexSize*v + SourceVertexOffsetOfInputPosition + 2]) -#define source_output_position_x(v) (*(uint16_t *)&next_run[SourceVertexSize*v + SourceVertexOffsetOfOutputPosition + 0]) -#define source_output_position_y(v) (*(uint16_t *)&next_run[SourceVertexSize*v + SourceVertexOffsetOfOutputPosition + 2]) -#define source_phase(v) next_run[SourceVertexSize*v + SourceVertexOffsetOfPhaseAndAmplitude + 0] -#define source_amplitude(v) next_run[SourceVertexSize*v + SourceVertexOffsetOfPhaseAndAmplitude + 1] -#define source_phase_time(v) next_run[SourceVertexSize*v + SourceVertexOffsetOfPhaseTime] +#define source_input_position_x1() (*(uint16_t *)&next_run[SourceVertexOffsetOfInputStart + 0]) +#define source_input_position_y() (*(uint16_t *)&next_run[SourceVertexOffsetOfInputStart + 2]) +#define source_input_position_x2() (*(uint16_t *)&next_run[SourceVertexOffsetOfEnds + 0]) +#define source_output_position_x1() (*(uint16_t *)&next_run[SourceVertexOffsetOfOutputStart + 0]) +#define source_output_position_y() (*(uint16_t *)&next_run[SourceVertexOffsetOfOutputStart + 2]) +#define source_output_position_x2() (*(uint16_t *)&next_run[SourceVertexOffsetOfEnds + 2]) +#define source_phase() next_run[SourceVertexOffsetOfPhaseTimeAndAmplitude + 0] +#define source_amplitude() next_run[SourceVertexOffsetOfPhaseTimeAndAmplitude + 2] +#define source_phase_time() next_run[SourceVertexOffsetOfPhaseTimeAndAmplitude + 1] void CRT::advance_cycles(unsigned int number_of_cycles, unsigned int source_divider, bool hsync_requested, bool vsync_requested, const bool vsync_charging, const Scan::Type type, uint16_t tex_x, uint16_t tex_y) { @@ -134,20 +136,15 @@ void CRT::advance_cycles(unsigned int number_of_cycles, unsigned int source_divi next_run = _openGL_output_builder->get_next_source_run(); } - // Vertex output is arranged for triangle strips, as: - // - // 2 [4/5] - // - // [0/1] 3 if(next_run) { - source_input_position_x(0) = tex_x; - source_input_position_y(0) = source_input_position_y(1) = tex_y; - source_output_position_x(0) = (uint16_t)_horizontal_flywheel->get_current_output_position(); - source_output_position_y(0) = source_output_position_y(1) = _openGL_output_builder->get_composite_output_y(); - source_phase(0) = source_phase(1) = _colour_burst_phase; - source_amplitude(0) = source_amplitude(1) = _colour_burst_amplitude; - source_phase_time(0) = source_phase_time(1) = _colour_burst_time; + source_input_position_x1() = tex_x; + source_input_position_y() = tex_y; + source_output_position_x1() = (uint16_t)_horizontal_flywheel->get_current_output_position(); + source_output_position_y() = _openGL_output_builder->get_composite_output_y(); + source_phase() = _colour_burst_phase; + source_amplitude() = _colour_burst_amplitude; + source_phase_time() = (uint8_t)_colour_burst_time; // assumption: burst was within the first 1/16 of the line } // decrement the number of cycles left to run for and increment the @@ -169,8 +166,8 @@ void CRT::advance_cycles(unsigned int number_of_cycles, unsigned int source_divi // if this is a data run then advance the buffer pointer if(type == Scan::Type::Data && source_divider) tex_x += next_run_length / (_time_multiplier * source_divider); - source_input_position_x(1) = tex_x; - source_output_position_x(1) = (uint16_t)_horizontal_flywheel->get_current_output_position(); + source_input_position_x2() = tex_x; + source_output_position_x2() = (uint16_t)_horizontal_flywheel->get_current_output_position(); _openGL_output_builder->complete_source_run(); } @@ -234,13 +231,15 @@ void CRT::advance_cycles(unsigned int number_of_cycles, unsigned int source_divi #undef output_position_y #undef output_tex_y -#undef input_input_position_x -#undef input_input_position_y -#undef input_output_position_x -#undef input_output_position_y -#undef input_phase -#undef input_amplitude -#undef input_phase_age +#undef source_input_position_x1 +#undef source_input_position_y +#undef source_input_position_x2 +#undef source_output_position_x1 +#undef source_output_position_y +#undef source_output_position_x2 +#undef source_phase +#undef source_amplitude +#undef source_phase_time #pragma mark - stream feeding methods diff --git a/Outputs/CRT/Internals/CRTConstants.hpp b/Outputs/CRT/Internals/CRTConstants.hpp index e1c8a3207..77bc11a9c 100644 --- a/Outputs/CRT/Internals/CRTConstants.hpp +++ b/Outputs/CRT/Internals/CRTConstants.hpp @@ -24,10 +24,10 @@ const GLsizei OutputVertexSize = 8; // Input vertices, used only in composite mode, map from the input buffer to temporary buffer locations; such // remapping occurs to ensure a continous stream of data for each scan, giving correct out-of-bounds behaviour -const GLsizei SourceVertexOffsetOfInputPosition = 0; -const GLsizei SourceVertexOffsetOfOutputPosition = 4; -const GLsizei SourceVertexOffsetOfPhaseAndAmplitude = 8; -const GLsizei SourceVertexOffsetOfPhaseTime = 12; +const GLsizei SourceVertexOffsetOfInputStart = 0; +const GLsizei SourceVertexOffsetOfOutputStart = 4; +const GLsizei SourceVertexOffsetOfEnds = 8; +const GLsizei SourceVertexOffsetOfPhaseTimeAndAmplitude = 12; const GLsizei SourceVertexSize = 16; @@ -41,7 +41,7 @@ const GLsizei IntermediateBufferHeight = 1024; // Some internal buffer sizes const GLsizeiptr OutputVertexBufferDataSize = OutputVertexSize * IntermediateBufferHeight; // i.e. the maximum number of scans of output that can be created between draws -const GLsizeiptr SourceVertexBufferDataSize = 2 * SourceVertexSize * IntermediateBufferHeight * 2; // a multiple of 2 * SourceVertexSize +const GLsizeiptr SourceVertexBufferDataSize = SourceVertexSize * IntermediateBufferHeight * 2; // a multiple of 2 * SourceVertexSize } } diff --git a/Outputs/CRT/Internals/CRTOpenGL.cpp b/Outputs/CRT/Internals/CRTOpenGL.cpp index f89401b55..d5cfed7cc 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.cpp +++ b/Outputs/CRT/Internals/CRTOpenGL.cpp @@ -298,7 +298,7 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out } // draw as desired - glDrawArrays(GL_LINES, 0, submitted_source_data / SourceVertexSize); + glDrawArraysInstanced(GL_LINES, 0, 2, submitted_source_data / SourceVertexSize); active_pipeline++; } @@ -324,7 +324,6 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out output_shader_program->bind(); // draw -// glDrawArrays(GL_TRIANGLE_STRIP, 0, submitted_output_data / OutputVertexSize); glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, submitted_output_data / OutputVertexSize); } @@ -393,24 +392,13 @@ void OpenGLOutputBuilder::prepare_source_vertex_array() { if(composite_input_shader_program) { - GLint inputPositionAttribute = composite_input_shader_program->get_attrib_location("inputPosition"); - GLint outputPositionAttribute = composite_input_shader_program->get_attrib_location("outputPosition"); - GLint phaseAndAmplitudeAttribute = composite_input_shader_program->get_attrib_location("phaseAndAmplitude"); - GLint phaseTimeAttribute = composite_input_shader_program->get_attrib_location("phaseTime"); - glBindVertexArray(source_vertex_array); - - glEnableVertexAttribArray((GLuint)inputPositionAttribute); - glEnableVertexAttribArray((GLuint)outputPositionAttribute); - glEnableVertexAttribArray((GLuint)phaseAndAmplitudeAttribute); - glEnableVertexAttribArray((GLuint)phaseTimeAttribute); - - const GLsizei vertexStride = SourceVertexSize; glBindBuffer(GL_ARRAY_BUFFER, source_array_buffer); - glVertexAttribPointer((GLuint)inputPositionAttribute, 2, GL_UNSIGNED_SHORT, GL_FALSE, vertexStride, (void *)SourceVertexOffsetOfInputPosition); - glVertexAttribPointer((GLuint)outputPositionAttribute, 2, GL_UNSIGNED_SHORT, GL_FALSE, vertexStride, (void *)SourceVertexOffsetOfOutputPosition); - glVertexAttribPointer((GLuint)phaseAndAmplitudeAttribute, 2, GL_UNSIGNED_BYTE, GL_TRUE, vertexStride, (void *)SourceVertexOffsetOfPhaseAndAmplitude); - glVertexAttribPointer((GLuint)phaseTimeAttribute, 1, GL_UNSIGNED_BYTE, GL_FALSE, vertexStride, (void *)SourceVertexOffsetOfPhaseTime); + + composite_input_shader_program->enable_vertex_attribute_with_pointer("inputStart", 2, GL_UNSIGNED_SHORT, GL_FALSE, SourceVertexSize, (void *)SourceVertexOffsetOfInputStart, 1); + composite_input_shader_program->enable_vertex_attribute_with_pointer("outputStart", 2, GL_UNSIGNED_SHORT, GL_FALSE, SourceVertexSize, (void *)SourceVertexOffsetOfOutputStart, 1); + composite_input_shader_program->enable_vertex_attribute_with_pointer("ends", 2, GL_UNSIGNED_SHORT, GL_FALSE, SourceVertexSize, (void *)SourceVertexOffsetOfEnds, 1); + composite_input_shader_program->enable_vertex_attribute_with_pointer("phaseTimeAndAmplitude", 3, GL_UNSIGNED_BYTE, GL_FALSE, SourceVertexSize, (void *)SourceVertexOffsetOfPhaseTimeAndAmplitude, 1); } } diff --git a/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp b/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp index 5db05c572..ea5aaba11 100644 --- a/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp +++ b/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp @@ -35,10 +35,10 @@ std::unique_ptr IntermediateShader::make_shader(const char * asprintf(&vertex_shader, "#version 150\n" - "in vec2 inputPosition;" - "in vec2 outputPosition;" - "in vec2 phaseAndAmplitude;" - "in float phaseTime;" + "in vec2 inputStart;" + "in vec2 outputStart;" + "in vec2 ends;" + "in vec3 phaseTimeAndAmplitude;" "uniform float phaseCyclesPerTick;" "uniform ivec2 outputTextureSize;" @@ -53,8 +53,12 @@ std::unique_ptr IntermediateShader::make_shader(const char * "void main(void)" "{" - "float direction = float(gl_VertexID & 1);" - "vec2 extensionVector = vec2(extension, 0.0) * 2.0 * (direction - 0.5);" + "float extent = float(gl_VertexID & 1);" + + "vec2 inputPosition = vec2(mix(inputStart.x, ends.x, extent), inputStart.y);" + "vec2 outputPosition = vec2(mix(outputStart.x, ends.y, extent), outputStart.y);" + "vec2 extensionVector = vec2(extension, 0.0) * 2.0 * (extent - 0.5);" + "vec2 extendedInputPosition = %s + extensionVector;" "vec2 extendedOutputPosition = outputPosition + extensionVector;" @@ -75,8 +79,8 @@ std::unique_ptr IntermediateShader::make_shader(const char * "inputPositionsVarying[10] = mappedInputPosition + (vec2(offsets[0], 0.0) / textureSize);" "delayLinePositionVarying = mappedInputPosition - vec2(0.0, 1.0);" - "phaseAndAmplitudeVarying.x = (phaseCyclesPerTick * (extendedOutputPosition.x - phaseTime) + phaseAndAmplitude.x) * 2.0 * 3.141592654;" - "phaseAndAmplitudeVarying.y = 0.33;" // TODO: reinstate connection with phaseAndAmplitude + "phaseAndAmplitudeVarying.x = (phaseCyclesPerTick * (extendedOutputPosition.x - phaseTimeAndAmplitude.y) + (phaseTimeAndAmplitude.x / 256.0)) * 2.0 * 3.141592654;" + "phaseAndAmplitudeVarying.y = 0.33;" // TODO: reinstate connection with (phaseTimeAndAmplitude.y/256.0) "vec2 eyePosition = 2.0*(extendedOutputPosition / outputTextureSize) - vec2(1.0) + vec2(1.0)/outputTextureSize;" "gl_Position = vec4(eyePosition, 0.0, 1.0);" From 0d2d6a452d4de160ec9469c277fd15771c5f20d4 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 10 May 2016 19:55:34 -0400 Subject: [PATCH 4/5] Fixed some dangling buffer management issues. --- Outputs/CRT/Internals/CRTOpenGL.cpp | 16 ++++------------ Outputs/CRT/Internals/CRTOpenGL.hpp | 11 +++-------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/Outputs/CRT/Internals/CRTOpenGL.cpp b/Outputs/CRT/Internals/CRTOpenGL.cpp index d5cfed7cc..ecd1eb6f4 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.cpp +++ b/Outputs/CRT/Internals/CRTOpenGL.cpp @@ -80,11 +80,9 @@ static int getCircularRanges(GLsizei *start_pointer, GLsizei *end_pointer, GLsiz } } -static GLsizei submitArrayData(GLuint buffer, uint8_t *source, GLsizei *length_pointer, GLsizei chunk_size) +static GLsizei submitArrayData(GLuint buffer, uint8_t *source, GLsizei *length_pointer) { GLsizei length = *length_pointer; - GLsizei residue = length % chunk_size; - length -= residue; glBindBuffer(GL_ARRAY_BUFFER, buffer); uint8_t *data = (uint8_t *)glMapBufferRange(GL_ARRAY_BUFFER, 0, length, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_FLUSH_EXPLICIT_BIT); @@ -92,13 +90,7 @@ static GLsizei submitArrayData(GLuint buffer, uint8_t *source, GLsizei *length_p glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, length); glUnmapBuffer(GL_ARRAY_BUFFER); - if(residue) - { - memmove(source, &source[length], (size_t)residue); - *length_pointer = residue; - } - else - *length_pointer = 0; + *length_pointer = 0; return length; } @@ -204,10 +196,10 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out } // release the mapping, giving up on trying to draw if data has been lost - GLsizei submitted_output_data = submitArrayData(output_array_buffer, _output_buffer_data.get(), &_output_buffer_data_pointer, 6*OutputVertexSize); + GLsizei submitted_output_data = submitArrayData(output_array_buffer, _output_buffer_data.get(), &_output_buffer_data_pointer); // bind and flush the source array buffer - GLsizei submitted_source_data = submitArrayData(source_array_buffer, _source_buffer_data.get(), &_source_buffer_data_pointer, 2*SourceVertexSize); + GLsizei submitted_source_data = submitArrayData(source_array_buffer, _source_buffer_data.get(), &_source_buffer_data_pointer); // determine how many lines are newly reclaimed; they'll need to be cleared Range clearing_zones[2]; diff --git a/Outputs/CRT/Internals/CRTOpenGL.hpp b/Outputs/CRT/Internals/CRTOpenGL.hpp index 6da343c13..12c4c79eb 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.hpp +++ b/Outputs/CRT/Internals/CRTOpenGL.hpp @@ -107,12 +107,12 @@ class OpenGLOutputBuilder { inline uint8_t *get_next_source_run() { if(_source_buffer_data_pointer == SourceVertexBufferDataSize) return nullptr; - return &_source_buffer_data.get()[_source_buffer_data_pointer % SourceVertexBufferDataSize]; + return &_source_buffer_data.get()[_source_buffer_data_pointer]; } inline void complete_source_run() { - _source_buffer_data_pointer += 2 * SourceVertexSize; + _source_buffer_data_pointer += SourceVertexSize; } inline bool composite_output_run_has_room_for_vertex() @@ -123,7 +123,7 @@ class OpenGLOutputBuilder { inline uint8_t *get_next_output_run() { if(_output_buffer_data_pointer == OutputVertexBufferDataSize) return nullptr; - return &_output_buffer_data.get()[_output_buffer_data_pointer % OutputVertexBufferDataSize]; + return &_output_buffer_data.get()[_output_buffer_data_pointer]; } inline void complete_output_run() @@ -146,11 +146,6 @@ class OpenGLOutputBuilder { return _output_device; } - inline bool composite_output_buffer_has_room_for_vertices(GLsizei vertices_to_write) - { - return _composite_src_output_y <= _cleared_composite_output_y + IntermediateBufferHeight - vertices_to_write * OutputVertexSize; - } - inline uint16_t get_composite_output_y() { return _composite_src_output_y % IntermediateBufferHeight; From a8ce0211368061aa74b6a43f07b00ddc82d3dfab Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 10 May 2016 19:59:03 -0400 Subject: [PATCH 5/5] Fixed comment. --- Outputs/CRT/Internals/CRTConstants.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Outputs/CRT/Internals/CRTConstants.hpp b/Outputs/CRT/Internals/CRTConstants.hpp index 77bc11a9c..d0e3b1c78 100644 --- a/Outputs/CRT/Internals/CRTConstants.hpp +++ b/Outputs/CRT/Internals/CRTConstants.hpp @@ -41,7 +41,7 @@ const GLsizei IntermediateBufferHeight = 1024; // Some internal buffer sizes const GLsizeiptr OutputVertexBufferDataSize = OutputVertexSize * IntermediateBufferHeight; // i.e. the maximum number of scans of output that can be created between draws -const GLsizeiptr SourceVertexBufferDataSize = SourceVertexSize * IntermediateBufferHeight * 2; // a multiple of 2 * SourceVertexSize +const GLsizeiptr SourceVertexBufferDataSize = SourceVertexSize * IntermediateBufferHeight * 2; // (the maximum number of scans) * conservative, high guess at a maximumum number of events likely to occur within a scan } }