mirror of
https://github.com/TomHarte/CLK.git
synced 2026-04-21 17:16:44 +00:00
Permitted a wider error window on vertical sync, tidied things up a little and started trying to move towards full implementation of the OpenGL contract.
This commit is contained in:
+2
-2
@@ -38,8 +38,8 @@ void CRT::set_new_timing(unsigned int cycles_per_line, unsigned int height_of_di
|
||||
_sync_capacitor_charge_threshold = (int)(syncCapacityLineChargeThreshold * _cycles_per_line);
|
||||
|
||||
// create the two flywheels
|
||||
_horizontal_flywheel = std::unique_ptr<Flywheel>(new Flywheel(_cycles_per_line, (millisecondsHorizontalRetraceTime * _cycles_per_line) >> 6));
|
||||
_vertical_flywheel = std::unique_ptr<Flywheel>(new Flywheel(_cycles_per_line * height_of_display, scanlinesVerticalRetraceTime * _cycles_per_line));
|
||||
_horizontal_flywheel = std::unique_ptr<Flywheel>(new Flywheel(_cycles_per_line, (millisecondsHorizontalRetraceTime * _cycles_per_line) >> 6, _cycles_per_line >> 6));
|
||||
_vertical_flywheel = std::unique_ptr<Flywheel>(new Flywheel(_cycles_per_line * height_of_display, scanlinesVerticalRetraceTime * _cycles_per_line, (_cycles_per_line * height_of_display) >> 3));
|
||||
|
||||
// figure out the divisor necessary to get the horizontal flywheel into a 16-bit range
|
||||
unsigned int real_clock_scan_period = (_cycles_per_line * height_of_display) / (_time_multiplier * _common_output_divisor);
|
||||
|
||||
@@ -325,28 +325,47 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
|
||||
glViewport(0, 0, (GLsizei)output_width, (GLsizei)output_height);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glActiveTexture(pixel_accumulation_texture_unit);
|
||||
framebuffer->bind_texture();
|
||||
framebuffer->draw((float)output_width / (float)output_height);
|
||||
|
||||
_fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
_output_mutex->unlock();
|
||||
}
|
||||
|
||||
void OpenGLOutputBuilder::reset_all_OpenGL_state()
|
||||
{
|
||||
composite_input_shader_program = nullptr;
|
||||
composite_separation_filter_program = nullptr;
|
||||
composite_y_filter_shader_program = nullptr;
|
||||
composite_chrominance_filter_shader_program = nullptr;
|
||||
rgb_input_shader_program = nullptr;
|
||||
rgb_filter_shader_program = nullptr;
|
||||
output_shader_program = nullptr;
|
||||
framebuffer = nullptr;
|
||||
}
|
||||
|
||||
void OpenGLOutputBuilder::set_openGL_context_will_change(bool should_delete_resources)
|
||||
{
|
||||
_output_mutex->lock();
|
||||
reset_all_OpenGL_state();
|
||||
_output_mutex->unlock();
|
||||
}
|
||||
|
||||
void OpenGLOutputBuilder::set_composite_sampling_function(const char *shader)
|
||||
{
|
||||
_output_mutex->lock();
|
||||
_composite_shader = strdup(shader);
|
||||
output_shader_program = nullptr;
|
||||
framebuffer = nullptr;
|
||||
reset_all_OpenGL_state();
|
||||
_output_mutex->unlock();
|
||||
}
|
||||
|
||||
void OpenGLOutputBuilder::set_rgb_sampling_function(const char *shader)
|
||||
{
|
||||
_output_mutex->lock();
|
||||
_rgb_shader = strdup(shader);
|
||||
reset_all_OpenGL_state();
|
||||
_output_mutex->unlock();
|
||||
}
|
||||
|
||||
#pragma mark - Program compilation
|
||||
|
||||
@@ -85,6 +85,9 @@ class OpenGLOutputBuilder {
|
||||
void set_timing_uniforms();
|
||||
void set_colour_space_uniforms();
|
||||
|
||||
void establish_OpenGL_state();
|
||||
void reset_all_OpenGL_state();
|
||||
|
||||
public:
|
||||
OpenGLOutputBuilder(unsigned int buffer_depth);
|
||||
~OpenGLOutputBuilder();
|
||||
|
||||
@@ -27,13 +27,13 @@ struct Flywheel
|
||||
Constructs an instance of @c Flywheel.
|
||||
|
||||
@param standard_period The expected amount of time between one synchronisation and the next.
|
||||
|
||||
@param retrace_time The amount of time it takes to complete a retrace.
|
||||
@param sync_error_window The permitted deviation of sync timings from the norm.
|
||||
*/
|
||||
Flywheel(unsigned int standard_period, unsigned int retrace_time) :
|
||||
Flywheel(unsigned int standard_period, unsigned int retrace_time, unsigned int sync_error_window) :
|
||||
_standard_period(standard_period),
|
||||
_retrace_time(retrace_time),
|
||||
_sync_error_window(standard_period >> 7),
|
||||
_sync_error_window(sync_error_window),
|
||||
_counter(0),
|
||||
_expected_next_sync(standard_period),
|
||||
_counter_before_retrace(standard_period - retrace_time),
|
||||
|
||||
Reference in New Issue
Block a user