1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-29 16:55:59 +00:00

Finally gets some pixels back on screen.

For now, just the raw scans, direct to the framebuffer, with no intermediate processing. But it seems to prove that at least some of the proper data is reaching the GPU.
This commit is contained in:
Thomas Harte 2018-11-11 23:23:42 -05:00
parent 3ae333fa84
commit dce52d740d
4 changed files with 51 additions and 11 deletions

View File

@ -624,8 +624,8 @@
4BD424E82193B5830097291A /* Rectangle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD424E22193B5820097291A /* Rectangle.cpp */; }; 4BD424E82193B5830097291A /* Rectangle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD424E22193B5820097291A /* Rectangle.cpp */; };
4BD468F71D8DF41D0084958B /* 1770.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD468F51D8DF41D0084958B /* 1770.cpp */; }; 4BD468F71D8DF41D0084958B /* 1770.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD468F51D8DF41D0084958B /* 1770.cpp */; };
4BD4A8D01E077FD20020D856 /* PCMTrackTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BD4A8CF1E077FD20020D856 /* PCMTrackTests.mm */; }; 4BD4A8D01E077FD20020D856 /* PCMTrackTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BD4A8CF1E077FD20020D856 /* PCMTrackTests.mm */; };
4BD5D2682199148100DDF17D /* ScanTargetVertexArrayAttributs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD5D2672199148100DDF17D /* ScanTargetVertexArrayAttributs.cpp */; }; 4BD5D2682199148100DDF17D /* ScanTargetVertexArrayAttributes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD5D2672199148100DDF17D /* ScanTargetVertexArrayAttributes.cpp */; };
4BD5D2692199148100DDF17D /* ScanTargetVertexArrayAttributs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD5D2672199148100DDF17D /* ScanTargetVertexArrayAttributs.cpp */; }; 4BD5D2692199148100DDF17D /* ScanTargetVertexArrayAttributes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD5D2672199148100DDF17D /* ScanTargetVertexArrayAttributes.cpp */; };
4BD5F1951D13528900631CD1 /* CSBestEffortUpdater.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BD5F1941D13528900631CD1 /* CSBestEffortUpdater.mm */; }; 4BD5F1951D13528900631CD1 /* CSBestEffortUpdater.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BD5F1941D13528900631CD1 /* CSBestEffortUpdater.mm */; };
4BD61664206B2AC800236112 /* QuickLoadOptions.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4BD61662206B2AC700236112 /* QuickLoadOptions.xib */; }; 4BD61664206B2AC800236112 /* QuickLoadOptions.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4BD61662206B2AC700236112 /* QuickLoadOptions.xib */; };
4BD67DCB209BE4D700AB2146 /* StaticAnalyser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD67DCA209BE4D600AB2146 /* StaticAnalyser.cpp */; }; 4BD67DCB209BE4D700AB2146 /* StaticAnalyser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD67DCA209BE4D600AB2146 /* StaticAnalyser.cpp */; };
@ -1387,7 +1387,7 @@
4BD468F51D8DF41D0084958B /* 1770.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = 1770.cpp; path = 1770/1770.cpp; sourceTree = "<group>"; }; 4BD468F51D8DF41D0084958B /* 1770.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = 1770.cpp; path = 1770/1770.cpp; sourceTree = "<group>"; };
4BD468F61D8DF41D0084958B /* 1770.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = 1770.hpp; path = 1770/1770.hpp; sourceTree = "<group>"; }; 4BD468F61D8DF41D0084958B /* 1770.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = 1770.hpp; path = 1770/1770.hpp; sourceTree = "<group>"; };
4BD4A8CF1E077FD20020D856 /* PCMTrackTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PCMTrackTests.mm; sourceTree = "<group>"; }; 4BD4A8CF1E077FD20020D856 /* PCMTrackTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PCMTrackTests.mm; sourceTree = "<group>"; };
4BD5D2672199148100DDF17D /* ScanTargetVertexArrayAttributs.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ScanTargetVertexArrayAttributs.cpp; sourceTree = "<group>"; }; 4BD5D2672199148100DDF17D /* ScanTargetVertexArrayAttributes.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ScanTargetVertexArrayAttributes.cpp; sourceTree = "<group>"; };
4BD5F1931D13528900631CD1 /* CSBestEffortUpdater.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSBestEffortUpdater.h; path = Updater/CSBestEffortUpdater.h; sourceTree = "<group>"; }; 4BD5F1931D13528900631CD1 /* CSBestEffortUpdater.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSBestEffortUpdater.h; path = Updater/CSBestEffortUpdater.h; sourceTree = "<group>"; };
4BD5F1941D13528900631CD1 /* CSBestEffortUpdater.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CSBestEffortUpdater.mm; path = Updater/CSBestEffortUpdater.mm; sourceTree = "<group>"; }; 4BD5F1941D13528900631CD1 /* CSBestEffortUpdater.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CSBestEffortUpdater.mm; path = Updater/CSBestEffortUpdater.mm; sourceTree = "<group>"; };
4BD601A920D89F2A00CBCE57 /* Log.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = Log.hpp; path = ../../Outputs/Log.hpp; sourceTree = "<group>"; }; 4BD601A920D89F2A00CBCE57 /* Log.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = Log.hpp; path = ../../Outputs/Log.hpp; sourceTree = "<group>"; };
@ -3027,7 +3027,7 @@
children = ( children = (
4BD191DC219113B80042E144 /* CRTOpenGL.cpp */, 4BD191DC219113B80042E144 /* CRTOpenGL.cpp */,
4BD191F22191180E0042E144 /* ScanTarget.cpp */, 4BD191F22191180E0042E144 /* ScanTarget.cpp */,
4BD5D2672199148100DDF17D /* ScanTargetVertexArrayAttributs.cpp */, 4BD5D2672199148100DDF17D /* ScanTargetVertexArrayAttributes.cpp */,
4BD191D8219113B80042E144 /* TextureBuilder.cpp */, 4BD191D8219113B80042E144 /* TextureBuilder.cpp */,
4BD191D9219113B80042E144 /* OpenGL.hpp */, 4BD191D9219113B80042E144 /* OpenGL.hpp */,
4BD191F32191180E0042E144 /* ScanTarget.hpp */, 4BD191F32191180E0042E144 /* ScanTarget.hpp */,
@ -3672,7 +3672,7 @@
4B894521201967B4007DE474 /* StaticAnalyser.cpp in Sources */, 4B894521201967B4007DE474 /* StaticAnalyser.cpp in Sources */,
4B7F188F2154825E00388727 /* MasterSystem.cpp in Sources */, 4B7F188F2154825E00388727 /* MasterSystem.cpp in Sources */,
4B055AA51FAE85EF0060FFFF /* Encoder.cpp in Sources */, 4B055AA51FAE85EF0060FFFF /* Encoder.cpp in Sources */,
4BD5D2692199148100DDF17D /* ScanTargetVertexArrayAttributs.cpp in Sources */, 4BD5D2692199148100DDF17D /* ScanTargetVertexArrayAttributes.cpp in Sources */,
4B894529201967B4007DE474 /* Disk.cpp in Sources */, 4B894529201967B4007DE474 /* Disk.cpp in Sources */,
4B055AEA1FAE9B990060FFFF /* 6502Storage.cpp in Sources */, 4B055AEA1FAE9B990060FFFF /* 6502Storage.cpp in Sources */,
4B055AA71FAE85EF0060FFFF /* SegmentParser.cpp in Sources */, 4B055AA71FAE85EF0060FFFF /* SegmentParser.cpp in Sources */,
@ -3862,7 +3862,7 @@
4B0333AF2094081A0050B93D /* AppleDSK.cpp in Sources */, 4B0333AF2094081A0050B93D /* AppleDSK.cpp in Sources */,
4B894518201967B4007DE474 /* ConfidenceCounter.cpp in Sources */, 4B894518201967B4007DE474 /* ConfidenceCounter.cpp in Sources */,
4B89452E201967B4007DE474 /* StaticAnalyser.cpp in Sources */, 4B89452E201967B4007DE474 /* StaticAnalyser.cpp in Sources */,
4BD5D2682199148100DDF17D /* ScanTargetVertexArrayAttributs.cpp in Sources */, 4BD5D2682199148100DDF17D /* ScanTargetVertexArrayAttributes.cpp in Sources */,
4B38F3481F2EC11D00D9235D /* AmstradCPC.cpp in Sources */, 4B38F3481F2EC11D00D9235D /* AmstradCPC.cpp in Sources */,
4B8FE2221DA19FB20090D3CE /* MachinePanel.swift in Sources */, 4B8FE2221DA19FB20090D3CE /* MachinePanel.swift in Sources */,
4B4518A41F75FD1C00926311 /* OricMFMDSK.cpp in Sources */, 4B4518A41F75FD1C00926311 /* OricMFMDSK.cpp in Sources */,

View File

@ -81,6 +81,18 @@ ScanTarget::ScanTarget() :
glGenTextures(1, &write_area_texture_name_); glGenTextures(1, &write_area_texture_name_);
glGenVertexArrays(1, &scan_vertex_array_); glGenVertexArrays(1, &scan_vertex_array_);
glBindVertexArray(scan_vertex_array_);
glBindBuffer(GL_ARRAY_BUFFER, scan_buffer_name_);
test_shader_.reset(new Shader(
globals(ShaderType::Scan),
"#version 150\n"
"out vec4 fragColour;"
"void main(void) {"
"fragColour = vec4(1.0);"
"}"
));
enable_vertex_attributes(ShaderType::Scan, *test_shader_);
} }
ScanTarget::~ScanTarget() { ScanTarget::~ScanTarget() {
@ -104,6 +116,10 @@ void ScanTarget::set_modals(Modals modals) {
write_pointers_.scan_buffer = 0; write_pointers_.scan_buffer = 0;
write_pointers_.write_area = 0; write_pointers_.write_area = 0;
} }
// TODO: this, but not to the test shader.
test_shader_->set_uniform("scale", GLfloat(modals.output_scale.x), GLfloat(modals.output_scale.y));
test_shader_->set_uniform("rowHeight", GLfloat(1.0f / modals.expected_vertical_lines));
} }
Outputs::Display::ScanTarget::Scan *ScanTarget::begin_scan() { Outputs::Display::ScanTarget::Scan *ScanTarget::begin_scan() {
@ -228,17 +244,19 @@ void ScanTarget::announce(Event event, uint16_t x, uint16_t y) {
} }
void ScanTarget::draw() { void ScanTarget::draw() {
glClear(GL_COLOR_BUFFER_BIT);
// Grab the current read and submit pointers. // Grab the current read and submit pointers.
const auto submit_pointers = submit_pointers_.load(); const auto submit_pointers = submit_pointers_.load();
const auto read_pointers = read_pointers_.load(); const auto read_pointers = read_pointers_.load();
// Submit scans. // Submit scans.
if(submit_pointers.scan_buffer != read_pointers.scan_buffer) { if(submit_pointers.scan_buffer != read_pointers.scan_buffer) {
const auto buffer_size = scan_buffer_.size() * sizeof(Scan); const auto buffer_size = scan_buffer_.size() * sizeof(Scan);
uint8_t *destination = static_cast<uint8_t *>( uint8_t *destination = static_cast<uint8_t *>(
glMapBufferRange(GL_ARRAY_BUFFER, 0, GLsizeiptr(buffer_size), GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT) glMapBufferRange(GL_ARRAY_BUFFER, 0, GLsizeiptr(buffer_size), GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT)
); );
assert(destination);
if(submit_pointers.scan_buffer > read_pointers.scan_buffer) { if(submit_pointers.scan_buffer > read_pointers.scan_buffer) {
// Submit the direct region from the submit pointer to the read pointer. // Submit the direct region from the submit pointer to the read pointer.
@ -323,7 +341,11 @@ void ScanTarget::draw() {
// the submit pointer location. // the submit pointer location.
read_pointers_.store(submit_pointers); read_pointers_.store(submit_pointers);
glClear(GL_COLOR_BUFFER_BIT); // TEST: draw all scans.
// ::OpenGL::Rectangle rect(-0.8f, -0.8f, 1.6f, 1.6f); glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindVertexArray(scan_vertex_array_);
test_shader_->bind();
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, GLsizei(scan_buffer_.size()));
// Rectangle rect(-0.8f, -0.8f, 1.6f, 1.6f);
// rect.draw(1, 1, 0); // rect.draw(1, 1, 0);
} }

View File

@ -110,7 +110,8 @@ class ScanTarget: public Outputs::Display::ScanTarget {
/*! /*!
@returns A string containing GLSL code describing the standard set of @returns A string containing GLSL code describing the standard set of
@c in and @c uniform variables to bind to the relevant struct @c in and @c uniform variables to bind to the relevant struct
from [...]OpenGL::ScanTarget. from [...]OpenGL::ScanTarget and a vertex function to provide
the standard varyings.
*/ */
std::string globals(ShaderType type); std::string globals(ShaderType type);
@ -119,6 +120,8 @@ class ScanTarget: public Outputs::Display::ScanTarget {
globals for shaders of @c type to @c target. globals for shaders of @c type to @c target.
*/ */
void enable_vertex_attributes(ShaderType type, Shader &target); void enable_vertex_attributes(ShaderType type, Shader &target);
std::unique_ptr<Shader> test_shader_;
}; };
} }

View File

@ -14,6 +14,8 @@ std::string ScanTarget::globals(ShaderType type) {
switch(type) { switch(type) {
case ShaderType::Scan: case ShaderType::Scan:
return return
"#version 150\n"
"uniform vec2 scale;" "uniform vec2 scale;"
"uniform float rowHeight;" "uniform float rowHeight;"
"uniform mat3 lumaChromaToRGB;" "uniform mat3 lumaChromaToRGB;"
@ -28,10 +30,23 @@ std::string ScanTarget::globals(ShaderType type) {
"in float endCompositeAngle;" "in float endCompositeAngle;"
"in float dataY;" "in float dataY;"
"in float lineY;"; "in float lineY;"
"void main(void) {"
"float lateral = float(gl_VertexID & 1);"
"float longitudinal = float((gl_VertexID & 2) >> 1);"
"vec2 vPosition = vec2("
"mix(startPoint.x, endPoint.x, lateral),"
"mix(startPoint.y, endPoint.y, longitudinal)"
") / scale;"
"gl_Position = vec4(vPosition, 0.0, 1.0);"
"}";
case ShaderType::Line: case ShaderType::Line:
return return
"#version 150\n"
"in vec2 startPoint;" "in vec2 startPoint;"
"in vec2 endPoint;"; "in vec2 endPoint;";
} }