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

Eliminated zoned clearing, in favour of a complete buffer clear on each load and attempted to reduce locking. But imperfectly.

This commit is contained in:
Thomas Harte 2016-11-16 10:59:12 +08:00
parent ccedb6bea6
commit 294adde344
2 changed files with 4 additions and 27 deletions

View File

@ -194,12 +194,14 @@ void CRT::advance_cycles(unsigned int number_of_cycles, unsigned int source_divi
}
else
{
_openGL_output_builder->lock_output();
uint8_t *next_run = _openGL_output_builder->get_next_output_run();
output_x1() = _output_run.x1;
output_position_y() = _output_run.y;
output_tex_y() = _output_run.tex_y;
output_x2() = (uint16_t)_horizontal_flywheel->get_current_output_position();
_openGL_output_builder->complete_output_run();
_openGL_output_builder->unlock_output();
}
_is_writing_composite_run ^= true;
}
@ -218,11 +220,7 @@ void CRT::advance_cycles(unsigned int number_of_cycles, unsigned int source_divi
_frames_since_last_delegate_call++;
if(_frames_since_last_delegate_call == 20)
{
// Yuck: to deal with the permitted ability of the delegate to make CRT changes that require the lock to be
// asserted during the delegate call, temporarily release the lock. TODO: find a less blunt instrument.
_openGL_output_builder->unlock_output();
_delegate->crt_did_end_batch_of_frames(this, _frames_since_last_delegate_call, _vertical_flywheel->get_and_reset_number_of_surprises());
_openGL_output_builder->lock_output();
_frames_since_last_delegate_call = 0;
}
}
@ -283,29 +281,24 @@ void CRT::output_scan(const Scan *const scan)
*/
void CRT::output_sync(unsigned int number_of_cycles)
{
_openGL_output_builder->lock_output();
Scan scan{
.type = Scan::Type::Sync,
.number_of_cycles = number_of_cycles
};
output_scan(&scan);
_openGL_output_builder->unlock_output();
}
void CRT::output_blank(unsigned int number_of_cycles)
{
_openGL_output_builder->lock_output();
Scan scan {
.type = Scan::Type::Blank,
.number_of_cycles = number_of_cycles
};
output_scan(&scan);
_openGL_output_builder->unlock_output();
}
void CRT::output_level(unsigned int number_of_cycles)
{
_openGL_output_builder->lock_output();
if(!_openGL_output_builder->input_buffer_is_full())
{
Scan scan {
@ -324,12 +317,10 @@ void CRT::output_level(unsigned int number_of_cycles)
};
output_scan(&scan);
}
_openGL_output_builder->unlock_output();
}
void CRT::output_colour_burst(unsigned int number_of_cycles, uint8_t phase, uint8_t amplitude)
{
_openGL_output_builder->lock_output();
Scan scan {
.type = Scan::Type::ColourBurst,
.number_of_cycles = number_of_cycles,
@ -337,12 +328,10 @@ void CRT::output_colour_burst(unsigned int number_of_cycles, uint8_t phase, uint
.amplitude = amplitude
};
output_scan(&scan);
_openGL_output_builder->unlock_output();
}
void CRT::output_data(unsigned int number_of_cycles, unsigned int source_divider)
{
_openGL_output_builder->lock_output();
if(!_openGL_output_builder->input_buffer_is_full())
{
_openGL_output_builder->reduce_previous_allocation_to(number_of_cycles / source_divider);
@ -363,7 +352,6 @@ void CRT::output_data(unsigned int number_of_cycles, unsigned int source_divider
};
output_scan(&scan);
}
_openGL_output_builder->unlock_output();
}
Outputs::CRT::Rect CRT::get_rect_for_area(int first_line_after_sync, int number_of_lines, int first_cycle_after_sync, int number_of_cycles, float aspect_ratio)

View File

@ -281,26 +281,15 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
// all drawing will be from the source vertex array and without blending
glBindVertexArray(source_vertex_array);
glDisable(GL_BLEND);
glClearColor(active_pipeline->clear_colour[0], active_pipeline->clear_colour[1], active_pipeline->clear_colour[2], 1.0);
while(active_pipeline->target)
{
// switch to the initial texture
active_pipeline->target->bind_framebuffer();
glClear(GL_COLOR_BUFFER_BIT);
active_pipeline->shader->bind();
// clear as desired
if(number_of_clearing_zones)
{
glEnable(GL_SCISSOR_TEST);
glClearColor(active_pipeline->clear_colour[0], active_pipeline->clear_colour[1], active_pipeline->clear_colour[2], 1.0);
for(int c = 0; c < number_of_clearing_zones; c++)
{
glScissor(0, clearing_zones[c].location, IntermediateBufferWidth, clearing_zones[c].length);
glClear(GL_COLOR_BUFFER_BIT);
}
glDisable(GL_SCISSOR_TEST);
}
// draw as desired
glDrawArraysInstanced(GL_LINES, 0, 2, submitted_source_data / SourceVertexSize);