1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-28 09:54:49 +00:00

Corrects vertical event announcement, and adjusts namespaces for OpenGL primitives.

This commit is contained in:
Thomas Harte 2018-11-11 15:11:32 -05:00
parent b70227ac1b
commit be12d78c83
9 changed files with 44 additions and 11 deletions

View File

@ -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,

View File

@ -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_(

View File

@ -13,6 +13,8 @@
#include "Shader.hpp"
#include <memory>
namespace Outputs {
namespace Display {
namespace OpenGL {
/*!
@ -36,6 +38,8 @@ class Rectangle {
GLint colour_uniform_;
};
}
}
}
#endif /* Rectangle_hpp */

View File

@ -11,7 +11,7 @@
#include <cstdio>
#include <cstring>
using namespace OpenGL;
using namespace Outputs::Display::OpenGL;
namespace {
// The below is disabled because it isn't context/thread-specific. Which makes it

View File

@ -16,6 +16,8 @@
#include <string>
#include <vector>
namespace Outputs {
namespace Display {
namespace OpenGL {
/*!
@ -118,6 +120,8 @@ protected:
void enqueue_function(std::function<void(void)> function);
};
}
}
}
#endif /* Shader_hpp */

View File

@ -11,7 +11,7 @@
#include <cstdlib>
#include <vector>
using namespace OpenGL;
using namespace Outputs::Display::OpenGL;
TextureTarget::TextureTarget(GLsizei width, GLsizei height, GLenum texture_unit, GLint mag_filter) :
width_(width),

View File

@ -13,6 +13,8 @@
#include "Shader.hpp"
#include <memory>
namespace Outputs {
namespace Display {
namespace OpenGL {
/*!
@ -87,6 +89,8 @@ class TextureTarget {
GLint threshold_uniform_;
};
}
}
}
#endif /* TextureTarget_hpp */

View File

@ -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();

View File

@ -11,6 +11,7 @@
#include "../ScanTarget.hpp"
#include "OpenGL.hpp"
#include "Primitives/TextureTarget.hpp"
#include <array>
#include <atomic>
@ -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, 3072> 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<CompositeLine, 2048> composite_line_buffer_;
TextureTarget composite_line_texture_;
GLuint composite_line_vertex_array_ = 0;
// Uses a texture to vend write areas.
std::vector<uint8_t> write_area_texture_;