diff --git a/Outputs/CRT/CRT.cpp b/Outputs/CRT/CRT.cpp index 9e1867e56..3a34709cd 100644 --- a/Outputs/CRT/CRT.cpp +++ b/Outputs/CRT/CRT.cpp @@ -209,9 +209,9 @@ void CRT::advance_cycles(int number_of_cycles, bool hsync_requested, bool vsync_ } // Also announce vertical retrace events. - if(next_run_length == time_until_vertical_sync_event && next_horizontal_sync_event != Flywheel::SyncEvent::None) { + if(next_run_length == time_until_vertical_sync_event && next_vertical_sync_event != Flywheel::SyncEvent::None) { const auto event = - (next_horizontal_sync_event == Flywheel::SyncEvent::StartRetrace) + (next_vertical_sync_event == Flywheel::SyncEvent::StartRetrace) ? Outputs::Display::ScanTarget::Event::BeginVerticalRetrace : Outputs::Display::ScanTarget::Event::EndVerticalRetrace; scan_target_->announce( event, diff --git a/Outputs/OpenGL/Primitives/Rectangle.cpp b/Outputs/OpenGL/Primitives/Rectangle.cpp index 6600ef5bd..94fdf3db9 100644 --- a/Outputs/OpenGL/Primitives/Rectangle.cpp +++ b/Outputs/OpenGL/Primitives/Rectangle.cpp @@ -8,7 +8,7 @@ #include "Rectangle.hpp" -using namespace OpenGL; +using namespace Outputs::Display::OpenGL; Rectangle::Rectangle(float x, float y, float width, float height): pixel_shader_( diff --git a/Outputs/OpenGL/Primitives/Rectangle.hpp b/Outputs/OpenGL/Primitives/Rectangle.hpp index 07a5152d5..fc1a4e58a 100644 --- a/Outputs/OpenGL/Primitives/Rectangle.hpp +++ b/Outputs/OpenGL/Primitives/Rectangle.hpp @@ -13,6 +13,8 @@ #include "Shader.hpp" #include +namespace Outputs { +namespace Display { namespace OpenGL { /*! @@ -36,6 +38,8 @@ class Rectangle { GLint colour_uniform_; }; +} +} } #endif /* Rectangle_hpp */ diff --git a/Outputs/OpenGL/Primitives/Shader.cpp b/Outputs/OpenGL/Primitives/Shader.cpp index a82b7705d..879ca2167 100644 --- a/Outputs/OpenGL/Primitives/Shader.cpp +++ b/Outputs/OpenGL/Primitives/Shader.cpp @@ -11,7 +11,7 @@ #include #include -using namespace OpenGL; +using namespace Outputs::Display::OpenGL; namespace { // The below is disabled because it isn't context/thread-specific. Which makes it diff --git a/Outputs/OpenGL/Primitives/Shader.hpp b/Outputs/OpenGL/Primitives/Shader.hpp index 572218cb6..ca1cc17cf 100644 --- a/Outputs/OpenGL/Primitives/Shader.hpp +++ b/Outputs/OpenGL/Primitives/Shader.hpp @@ -16,6 +16,8 @@ #include #include +namespace Outputs { +namespace Display { namespace OpenGL { /*! @@ -118,6 +120,8 @@ protected: void enqueue_function(std::function function); }; +} +} } #endif /* Shader_hpp */ diff --git a/Outputs/OpenGL/Primitives/TextureTarget.cpp b/Outputs/OpenGL/Primitives/TextureTarget.cpp index c2d6f8f57..a4061b21a 100644 --- a/Outputs/OpenGL/Primitives/TextureTarget.cpp +++ b/Outputs/OpenGL/Primitives/TextureTarget.cpp @@ -11,7 +11,7 @@ #include #include -using namespace OpenGL; +using namespace Outputs::Display::OpenGL; TextureTarget::TextureTarget(GLsizei width, GLsizei height, GLenum texture_unit, GLint mag_filter) : width_(width), diff --git a/Outputs/OpenGL/Primitives/TextureTarget.hpp b/Outputs/OpenGL/Primitives/TextureTarget.hpp index c6b9b14f5..269477da5 100644 --- a/Outputs/OpenGL/Primitives/TextureTarget.hpp +++ b/Outputs/OpenGL/Primitives/TextureTarget.hpp @@ -13,6 +13,8 @@ #include "Shader.hpp" #include +namespace Outputs { +namespace Display { namespace OpenGL { /*! @@ -87,6 +89,8 @@ class TextureTarget { GLint threshold_uniform_; }; +} +} } #endif /* TextureTarget_hpp */ diff --git a/Outputs/OpenGL/ScanTarget.cpp b/Outputs/OpenGL/ScanTarget.cpp index 7a77da148..1cb9304db 100644 --- a/Outputs/OpenGL/ScanTarget.cpp +++ b/Outputs/OpenGL/ScanTarget.cpp @@ -16,6 +16,10 @@ namespace { constexpr int WriteAreaWidth = 2048; constexpr int WriteAreaHeight = 2048; +constexpr int CompositeLineBufferWidth = 2048; +constexpr int CompositeLineBufferHeight = 2048; +constexpr int CompositeLineBufferTextureUnit = 0; + #define TextureAddress(x, y) (((y) << 11) | (x)) #define TextureAddressGetY(v) uint16_t((v) >> 11) #define TextureAddressGetX(v) uint16_t((v) & 0x7ff) @@ -43,7 +47,9 @@ const GLenum formatForDepth(std::size_t depth) { } -ScanTarget::ScanTarget() { +ScanTarget::ScanTarget() : + composite_line_texture_(CompositeLineBufferWidth, CompositeLineBufferHeight, CompositeLineBufferTextureUnit, GL_LINEAR) { + // Allocate space for the scans. glGenBuffers(1, &scan_buffer_name_); glBindBuffer(GL_ARRAY_BUFFER, scan_buffer_name_); @@ -56,14 +62,13 @@ ScanTarget::ScanTarget() { // write straight into it. glGenTextures(1, &write_area_texture_name_); - glGenVertexArrays(1, &vertex_array_); + glGenVertexArrays(1, &scan_vertex_array_); } ScanTarget::~ScanTarget() { - // Release scan space. glDeleteBuffers(1, &scan_buffer_name_); glDeleteTextures(1, &write_area_texture_name_); - glDeleteVertexArrays(1, &vertex_array_); + glDeleteVertexArrays(1, &scan_vertex_array_); } void ScanTarget::set_modals(Modals modals) { @@ -174,6 +179,9 @@ void ScanTarget::submit() { allocation_has_failed_ = false; } +void ScanTarget::announce(Event event, uint16_t x, uint16_t y) { +} + void ScanTarget::draw() { // Grab the current read and submit pointers. const auto submit_pointers = submit_pointers_.load(); diff --git a/Outputs/OpenGL/ScanTarget.hpp b/Outputs/OpenGL/ScanTarget.hpp index 58bf5ed0e..7cf507478 100644 --- a/Outputs/OpenGL/ScanTarget.hpp +++ b/Outputs/OpenGL/ScanTarget.hpp @@ -11,6 +11,7 @@ #include "../ScanTarget.hpp" #include "OpenGL.hpp" +#include "Primitives/TextureTarget.hpp" #include #include @@ -27,6 +28,7 @@ class ScanTarget: public Outputs::Display::ScanTarget { ~ScanTarget(); void draw(); + private: // Outputs::Display::ScanTarget overrides. void set_modals(Modals) override; Scan *begin_scan() override; @@ -34,8 +36,8 @@ class ScanTarget: public Outputs::Display::ScanTarget { uint8_t *begin_data(size_t required_length, size_t required_alignment) override; void end_data(size_t actual_length) override; void submit() override; + void announce(Event event, uint16_t x, uint16_t y) override; - private: // Extends the definition of a Scan to include two extra fields, // relevant to the way that this scan target processes video. struct Scan: public Outputs::Display::ScanTarget::Scan { @@ -66,7 +68,18 @@ class ScanTarget: public Outputs::Display::ScanTarget { // Maintains a buffer of the most recent 3072 scans. std::array scan_buffer_; GLuint scan_buffer_name_ = 0; - GLuint vertex_array_; + GLuint scan_vertex_array_ = 0; + + // Maintains a list of composite scan buffer coordinates. + struct CompositeLine { + struct EndPoint { + uint16_t x, y; + } end_points[2]; + uint16_t composite_y; + }; + std::array composite_line_buffer_; + TextureTarget composite_line_texture_; + GLuint composite_line_vertex_array_ = 0; // Uses a texture to vend write areas. std::vector write_area_texture_;