1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-04-21 02:17:08 +00:00

Create a supersampling buffer.

This commit is contained in:
Thomas Harte
2026-02-02 16:51:34 -05:00
parent 23dd26d042
commit a89e48718d
2 changed files with 37 additions and 4 deletions
+36 -4
View File
@@ -31,6 +31,11 @@ namespace {
/// The texture unit from which to source input data.
constexpr GLenum SourceDataTextureUnit = GL_TEXTURE0;
//
// Old Pipeline.
//
/// The texture unit which contains raw line-by-line composite, S-Video or RGB data.
constexpr GLenum UnprocessedLineBufferTextureUnit = GL_TEXTURE1;
@@ -44,6 +49,13 @@ constexpr GLenum QAMChromaTextureUnit = GL_TEXTURE2;
/// The texture unit that contains the current display.
constexpr GLenum AccumulationTextureUnit = GL_TEXTURE3;
//
// New pipeline.
//
/// The texture unit that contains the current display.
constexpr GLenum OutputTextureUnit = GL_TEXTURE4;
using Logger = Log::Logger<Log::Source::OpenGL>;
constexpr GLint internalFormatForDepth(const std::size_t depth) {
@@ -269,9 +281,9 @@ void ScanTarget::setup_pipeline() {
modals.cycles_per_line
);
// if(copy_shader_.empty()) {
// copy_shader_ = copy_shader(api_, GL_TEXTURE4, {}, {});
// }
if(copy_shader_.empty()) {
copy_shader_ = copy_shader(api_, OutputTextureUnit, {}, {});
}
if(
!existing_modals_ ||
@@ -325,7 +337,7 @@ bool ScanTarget::is_soft_display_type() {
return display_type == DisplayType::CompositeColour || display_type == DisplayType::CompositeMonochrome;
}
void ScanTarget::update(int, int output_height) {
void ScanTarget::update(const int output_width, const int output_height) {
// If the GPU is still busy, don't wait; we'll catch it next time.
if(fence_ != nullptr) {
if(glClientWaitSync(fence_, GL_SYNC_FLUSH_COMMANDS_BIT, 0) == GL_TIMEOUT_EXPIRED) {
@@ -344,6 +356,24 @@ void ScanTarget::update(int, int output_height) {
std::chrono::high_resolution_clock::now() - line_submission_begin_time_,
true);
// Make sure there's a buffer.
const auto output_buffer_width = output_width * 2;
const auto output_buffer_height = output_height * 2;
if(
output_buffer_.empty() ||
output_buffer_.width() != output_buffer_width ||
output_buffer_.height() != output_buffer_height
) {
output_buffer_ = TextureTarget(
api_,
output_buffer_width,
output_buffer_height,
OutputTextureUnit,
GL_NEAREST,
false // TODO: should probably be true, if I'm going to use stencil.
);
}
// Grab the new output list.
perform([&] {
const OutputArea area = get_output_area();
@@ -689,6 +719,8 @@ void ScanTarget::draw(int output_width, int output_height) {
}
if(!composition_buffer_.empty()) {
// copy_shader_.bind();
// glDrawElements(GL_TRIANGLE_STRIP, 0, GL_UNSIGNED_BYTE, nullptr);
// Copy the accumulation texture to the target.
test_gl([&]{ glBindFramebuffer(GL_FRAMEBUFFER, target_framebuffer_); });
test_gl([&]{ glViewport(0, 0, (GLsizei)output_width, (GLsizei)output_height); });