mirror of
https://github.com/TomHarte/CLK.git
synced 2024-07-11 04:28:58 +00:00
Switched back to broad locking for CRT updates. To eliminate one more thing.
This commit is contained in:
parent
95ee2fffdb
commit
a82fa31370
@ -279,24 +279,29 @@ void CRT::output_scan(const Scan *const scan)
|
|||||||
*/
|
*/
|
||||||
void CRT::output_sync(unsigned int number_of_cycles)
|
void CRT::output_sync(unsigned int number_of_cycles)
|
||||||
{
|
{
|
||||||
|
_openGL_output_builder->lock_output();
|
||||||
Scan scan{
|
Scan scan{
|
||||||
.type = Scan::Type::Sync,
|
.type = Scan::Type::Sync,
|
||||||
.number_of_cycles = number_of_cycles
|
.number_of_cycles = number_of_cycles
|
||||||
};
|
};
|
||||||
output_scan(&scan);
|
output_scan(&scan);
|
||||||
|
_openGL_output_builder->unlock_output();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRT::output_blank(unsigned int number_of_cycles)
|
void CRT::output_blank(unsigned int number_of_cycles)
|
||||||
{
|
{
|
||||||
|
_openGL_output_builder->lock_output();
|
||||||
Scan scan {
|
Scan scan {
|
||||||
.type = Scan::Type::Blank,
|
.type = Scan::Type::Blank,
|
||||||
.number_of_cycles = number_of_cycles
|
.number_of_cycles = number_of_cycles
|
||||||
};
|
};
|
||||||
output_scan(&scan);
|
output_scan(&scan);
|
||||||
|
_openGL_output_builder->unlock_output();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRT::output_level(unsigned int number_of_cycles)
|
void CRT::output_level(unsigned int number_of_cycles)
|
||||||
{
|
{
|
||||||
|
_openGL_output_builder->lock_output();
|
||||||
Scan scan {
|
Scan scan {
|
||||||
.type = Scan::Type::Level,
|
.type = Scan::Type::Level,
|
||||||
.number_of_cycles = number_of_cycles,
|
.number_of_cycles = number_of_cycles,
|
||||||
@ -304,10 +309,12 @@ void CRT::output_level(unsigned int number_of_cycles)
|
|||||||
.tex_y = _openGL_output_builder->get_last_write_y_posititon()
|
.tex_y = _openGL_output_builder->get_last_write_y_posititon()
|
||||||
};
|
};
|
||||||
output_scan(&scan);
|
output_scan(&scan);
|
||||||
|
_openGL_output_builder->unlock_output();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRT::output_colour_burst(unsigned int number_of_cycles, uint8_t phase, uint8_t amplitude)
|
void CRT::output_colour_burst(unsigned int number_of_cycles, uint8_t phase, uint8_t amplitude)
|
||||||
{
|
{
|
||||||
|
_openGL_output_builder->lock_output();
|
||||||
Scan scan {
|
Scan scan {
|
||||||
.type = Scan::Type::ColourBurst,
|
.type = Scan::Type::ColourBurst,
|
||||||
.number_of_cycles = number_of_cycles,
|
.number_of_cycles = number_of_cycles,
|
||||||
@ -315,10 +322,12 @@ void CRT::output_colour_burst(unsigned int number_of_cycles, uint8_t phase, uint
|
|||||||
.amplitude = amplitude
|
.amplitude = amplitude
|
||||||
};
|
};
|
||||||
output_scan(&scan);
|
output_scan(&scan);
|
||||||
|
_openGL_output_builder->unlock_output();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRT::output_data(unsigned int number_of_cycles, unsigned int source_divider)
|
void CRT::output_data(unsigned int number_of_cycles, unsigned int source_divider)
|
||||||
{
|
{
|
||||||
|
_openGL_output_builder->lock_output();
|
||||||
if(_openGL_output_builder->reduce_previous_allocation_to(number_of_cycles / source_divider))
|
if(_openGL_output_builder->reduce_previous_allocation_to(number_of_cycles / source_divider))
|
||||||
{
|
{
|
||||||
Scan scan {
|
Scan scan {
|
||||||
@ -334,6 +343,7 @@ void CRT::output_data(unsigned int number_of_cycles, unsigned int source_divider
|
|||||||
{
|
{
|
||||||
output_blank(number_of_cycles);
|
output_blank(number_of_cycles);
|
||||||
}
|
}
|
||||||
|
_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)
|
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)
|
||||||
|
@ -107,14 +107,12 @@ class OpenGLOutputBuilder {
|
|||||||
inline uint8_t *get_next_source_run()
|
inline uint8_t *get_next_source_run()
|
||||||
{
|
{
|
||||||
if(_source_buffer_data_pointer == _drawn_source_buffer_data_pointer + SourceVertexBufferDataSize) return nullptr;
|
if(_source_buffer_data_pointer == _drawn_source_buffer_data_pointer + SourceVertexBufferDataSize) return nullptr;
|
||||||
_output_mutex->lock();
|
|
||||||
return &_source_buffer_data.get()[_source_buffer_data_pointer % SourceVertexBufferDataSize];
|
return &_source_buffer_data.get()[_source_buffer_data_pointer % SourceVertexBufferDataSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void complete_source_run()
|
inline void complete_source_run()
|
||||||
{
|
{
|
||||||
_source_buffer_data_pointer += 2 * SourceVertexSize;
|
_source_buffer_data_pointer += 2 * SourceVertexSize;
|
||||||
_output_mutex->unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool composite_output_run_has_room_for_vertices(GLsizei vertices_to_write)
|
inline bool composite_output_run_has_room_for_vertices(GLsizei vertices_to_write)
|
||||||
@ -125,13 +123,21 @@ class OpenGLOutputBuilder {
|
|||||||
inline uint8_t *get_next_output_run()
|
inline uint8_t *get_next_output_run()
|
||||||
{
|
{
|
||||||
if(_output_buffer_data_pointer == _drawn_output_buffer_data_pointer + OutputVertexBufferDataSize) return nullptr;
|
if(_output_buffer_data_pointer == _drawn_output_buffer_data_pointer + OutputVertexBufferDataSize) return nullptr;
|
||||||
_output_mutex->lock();
|
|
||||||
return &_output_buffer_data.get()[_output_buffer_data_pointer % OutputVertexBufferDataSize];
|
return &_output_buffer_data.get()[_output_buffer_data_pointer % OutputVertexBufferDataSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void complete_output_run(GLsizei vertices_written)
|
inline void complete_output_run(GLsizei vertices_written)
|
||||||
{
|
{
|
||||||
_output_buffer_data_pointer += vertices_written * OutputVertexSize;
|
_output_buffer_data_pointer += vertices_written * OutputVertexSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void lock_output()
|
||||||
|
{
|
||||||
|
_output_mutex->lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void unlock_output()
|
||||||
|
{
|
||||||
_output_mutex->unlock();
|
_output_mutex->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user