1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-06 01:28:57 +00:00

Corrections back towards composite output: fixed misnamed constant, ensured the CRT doesn't write nonsense to the output buffer, ensured it grows three vertices at a time rather than six when desired. Net effect should be that the output stage is working again, with the input processing remaining to fill in.

This commit is contained in:
Thomas Harte 2016-04-10 22:56:52 -04:00
parent 8701366277
commit bdb99ba92f
5 changed files with 19 additions and 13 deletions

View File

@ -64,6 +64,7 @@ void Machine::setup_output()
"uint texValue = texture(sampler, coordinate).r;"
"texValue >>= 4 - (int(icoordinate.x * 2) & 1)*4;"
"return vec4(texValue & 4u, texValue & 2u, texValue & 1u, 1.0);"
// "return vec4(1.0);"
"}");
_crt->set_output_device(Outputs::CRT::Monitor);

View File

@ -132,7 +132,7 @@ void CRT::advance_cycles(unsigned int number_of_cycles, unsigned int source_divi
uint8_t *next_run = nullptr;
if(is_output_segment)
{
next_run = _openGL_output_builder->get_next_output_run();
next_run = (_openGL_output_builder->get_output_device() == Monitor) ? _openGL_output_builder->get_next_output_run() : _openGL_output_builder->get_next_source_run();
}
// Vertex output is arranged for triangle strips, as:
@ -195,18 +195,22 @@ void CRT::advance_cycles(unsigned int number_of_cycles, unsigned int source_divi
output_position_y(3) = output_position_y(4) = output_position_y(5) = (uint16_t)(_vertical_flywheel->get_current_output_position() / _vertical_flywheel_output_divider);
output_timestamp(3) = output_timestamp(4) = output_timestamp(5) = _openGL_output_builder->get_current_field_time();
output_tex_x(3) = output_tex_x(4) = output_tex_x(5) = tex_x;
_openGL_output_builder->complete_output_run(6);
}
else
{
source_input_position_x(1) = tex_x;
source_output_position_x(1) = (uint16_t)_horizontal_flywheel->get_current_output_position();
_openGL_output_builder->complete_source_run();
}
}
if(is_output_segment)
{
_openGL_output_builder->complete_output_run();
}
// if(is_output_segment)
// {
// _openGL_output_builder->complete_output_run(6);
// }
// if this is horizontal retrace then advance the output line counter and bookend an output run
if(_openGL_output_builder->get_output_device() == Television)
@ -230,8 +234,9 @@ void CRT::advance_cycles(unsigned int number_of_cycles, unsigned int source_divi
output_lateral(0) = 0;
output_lateral(1) = _is_writing_composite_run ? 1 : 0;
output_lateral(2) = 1;
output_frame_id(0) = output_frame_id(1) = output_frame_id(2) = (uint8_t)_openGL_output_builder->get_current_field();
_openGL_output_builder->complete_output_run();
_openGL_output_builder->complete_output_run(3);
_is_writing_composite_run ^= true;
}

View File

@ -43,7 +43,7 @@ const int IntermediateBufferWidth = 2048;
const int IntermediateBufferHeight = 2048;
// Some internal
const GLsizeiptr InputVertexBufferDataSize = 262080; // a multiple of 6 * OutputVertexSize
const GLsizeiptr OutputVertexBufferDataSize = 262080; // a multiple of 6 * OutputVertexSize
// Runs are divided discretely by vertical syncs in order to put a usable bounds on the uniform used to track

View File

@ -112,7 +112,7 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
glBindBuffer(GL_ARRAY_BUFFER, output_array_buffer);
glBufferData(GL_ARRAY_BUFFER, InputVertexBufferDataSize, NULL, GL_STREAM_DRAW);
glBufferData(GL_ARRAY_BUFFER, OutputVertexBufferDataSize, NULL, GL_STREAM_DRAW);
_output_buffer_data_pointer = 0;
glBindVertexArray(output_vertex_array);
@ -216,7 +216,7 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
{
// draw
GLsizei primitive_count = (GLsizei)(count / OutputVertexSize);
GLsizei max_count = (GLsizei)((InputVertexBufferDataSize - start) / OutputVertexSize);
GLsizei max_count = (GLsizei)((OutputVertexBufferDataSize - start) / OutputVertexSize);
if(primitive_count < max_count)
{
glDrawArrays(GL_TRIANGLE_STRIP, (GLint)(start / OutputVertexSize), primitive_count);
@ -231,7 +231,7 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
// drawing commands having been issued, reclaim the array buffer pointer
// _buffer_builder->move_to_new_line();
_output_buffer_data = (uint8_t *)glMapBufferRange(GL_ARRAY_BUFFER, 0, InputVertexBufferDataSize, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
_output_buffer_data = (uint8_t *)glMapBufferRange(GL_ARRAY_BUFFER, 0, OutputVertexBufferDataSize, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
_input_texture_data = (uint8_t *)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, _input_texture_array_size, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
_output_mutex->unlock();
}

View File

@ -117,13 +117,13 @@ class OpenGLOutputBuilder {
{
_output_mutex->lock();
uint8_t *pointer = &_output_buffer_data[_output_buffer_data_pointer];
_output_buffer_data_pointer = (_output_buffer_data_pointer + 6 * OutputVertexSize) % InputVertexBufferDataSize;
return pointer;
}
inline void complete_output_run()
inline void complete_output_run(size_t vertices_written)
{
_run_builders[_run_write_pointer]->amount_of_data += 6 * OutputVertexSize;
_run_builders[_run_write_pointer]->amount_of_data += vertices_written * OutputVertexSize;
_output_buffer_data_pointer = (_output_buffer_data_pointer + vertices_written * OutputVertexSize) % OutputVertexBufferDataSize;
_output_mutex->unlock();
}