1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-25 03:32:01 +00:00

Improves filtering slightly, and ensures coefficients are always set when needed.

This commit is contained in:
Thomas Harte 2019-02-26 22:35:55 -05:00
parent 694783efe9
commit 79707a3c66
2 changed files with 9 additions and 4 deletions

View File

@ -397,6 +397,7 @@ void ScanTarget::draw(bool synchronous, int output_width, int output_height) {
while(is_drawing_.test_and_set());
// Establish the pipeline if necessary.
const bool did_setup_pipeline = modals_are_dirty_;
if(modals_are_dirty_) {
setup_pipeline();
modals_are_dirty_ = false;
@ -534,8 +535,8 @@ void ScanTarget::draw(bool synchronous, int output_width, int output_height) {
// in fidelity. TODO: make this decision a function of computer speed.
const int framebuffer_height = std::min(output_height, 1080);
const int proportional_width = (framebuffer_height * 4) / 3;
if(!accumulation_texture_ || ( /* !synchronous && */ (accumulation_texture_->get_width() != proportional_width || accumulation_texture_->get_height() != framebuffer_height))) {
set_sampling_window(proportional_width, framebuffer_height, *output_shader_);
const bool did_create_accumulation_texture = !accumulation_texture_ || ( /* !synchronous && */ (accumulation_texture_->get_width() != proportional_width || accumulation_texture_->get_height() != framebuffer_height));
if(did_create_accumulation_texture) {
std::unique_ptr<OpenGL::TextureTarget> new_framebuffer(
new TextureTarget(
GLsizei(proportional_width),
@ -563,6 +564,10 @@ void ScanTarget::draw(bool synchronous, int output_width, int output_height) {
stencil_is_valid_ = false;
}
if(did_setup_pipeline || did_create_accumulation_texture) {
set_sampling_window(proportional_width, framebuffer_height, *output_shader_);
}
// Figure out how many new lines are ready.
uint16_t new_lines = (submit_pointers.line + LineBufferHeight - read_pointers.line) % LineBufferHeight;
if(new_lines) {

View File

@ -58,12 +58,12 @@ void ScanTarget::set_uniforms(ShaderType type, Shader &target) const {
void ScanTarget::set_sampling_window(int output_width, int output_height, Shader &target) {
if(modals_.display_type != DisplayType::CompositeColour) {
const float one_pixel_width = float(output_width) * modals_.visible_area.size.width / float(modals_.cycles_per_line);
const float one_pixel_width = float(modals_.cycles_per_line) * modals_.visible_area.size.width / float(output_width);
const float clocks_per_angle = float(modals_.cycles_per_line) * float(modals_.colour_cycle_denominator) / float(modals_.colour_cycle_numerator);
GLfloat texture_offsets[4];
GLfloat angles[4];
for(int c = 0; c < 4; ++c) {
texture_offsets[c] = ((one_pixel_width * float(c)) / 3.0f) - (one_pixel_width * 0.5f);
texture_offsets[c] = 1.5f * (((one_pixel_width * float(c)) / 3.0f) - (one_pixel_width * 0.5f));
angles[c] = GLfloat((texture_offsets[c] / clocks_per_angle) * 2.0f * M_PI);
}
target.set_uniform("textureCoordinateOffsets", 1, 4, texture_offsets);