1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-25 16:31:42 +00:00

Fixed: the two shaders that use a common input array should use common bindings.

This commit is contained in:
Thomas Harte 2019-02-10 22:39:24 -05:00
parent c94acb1ca2
commit 008f50832c
3 changed files with 36 additions and 36 deletions

View File

@ -306,6 +306,10 @@ void ScanTarget::setup_pipeline() {
write_pointers_.write_area = 0;
}
// Prepare to bind line shaders.
glBindVertexArray(line_vertex_array_);
glBindBuffer(GL_ARRAY_BUFFER, line_buffer_name_);
// Destroy or create a QAM buffer and shader, if appropriate.
const bool needs_qam_buffer = (modals_.display_type == DisplayType::CompositeColour || modals_.display_type == DisplayType::SVideo);
if(needs_qam_buffer) {
@ -314,8 +318,6 @@ void ScanTarget::setup_pipeline() {
}
qam_separation_shader_ = qam_separation_shader();
glBindVertexArray(line_vertex_array_);
glBindBuffer(GL_ARRAY_BUFFER, line_buffer_name_);
enable_vertex_attributes(ShaderType::QAMSeparation, *qam_separation_shader_);
set_uniforms(ShaderType::QAMSeparation, *qam_separation_shader_);
qam_separation_shader_->set_uniform("textureName", GLint(UnprocessedLineBufferTextureUnit - GL_TEXTURE0));
@ -326,8 +328,6 @@ void ScanTarget::setup_pipeline() {
// Establish an output shader.
output_shader_ = conversion_shader();
glBindVertexArray(line_vertex_array_);
glBindBuffer(GL_ARRAY_BUFFER, line_buffer_name_);
enable_vertex_attributes(ShaderType::Conversion, *output_shader_);
set_uniforms(ShaderType::Conversion, *output_shader_);
output_shader_->set_uniform("origin", modals_.visible_area.origin.x, modals_.visible_area.origin.y);
@ -577,7 +577,8 @@ void ScanTarget::draw(bool synchronous, int output_width, int output_height) {
if(qam_separation_shader_) {
qam_separation_shader_->bind();
qam_chroma_texture_->bind_framebuffer();
// glClear(GL_COLOR_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT); // TODO: this is here as a hint that the old framebuffer doesn't need reloading;
// test whether that's a valid optimisation on desktop OpenGL.
glDisable(GL_BLEND);
glDisable(GL_STENCIL_TEST);
@ -608,8 +609,6 @@ void ScanTarget::draw(bool synchronous, int output_width, int output_height) {
glClear(GL_COLOR_BUFFER_BIT);
accumulation_texture_->bind_texture();
accumulation_texture_->draw(float(output_width) / float(output_height), 4.0f / 255.0f);
// qam_chroma_texture_->bind_texture();
// qam_chroma_texture_->draw(float(output_width) / float(output_height));
// All data now having been spooled to the GPU, update the read pointers to
// the submit pointer location.

View File

@ -178,7 +178,8 @@ class ScanTarget: public Outputs::Display::ScanTarget {
globals for shaders of @c type to @c target.
*/
static void enable_vertex_attributes(ShaderType type, Shader &target);
void set_uniforms(ShaderType type, Shader &target);
void set_uniforms(ShaderType type, Shader &target) const;
std::vector<std::string> bindings(ShaderType type) const;
GLsync fence_ = nullptr;
std::atomic_flag is_drawing_;

View File

@ -14,7 +14,7 @@ using namespace Outputs::Display::OpenGL;
// MARK: - State setup for compiled shaders.
void Outputs::Display::OpenGL::ScanTarget::set_uniforms(ShaderType type, Shader &target) {
void Outputs::Display::OpenGL::ScanTarget::set_uniforms(ShaderType type, Shader &target) const {
// Slightly over-amping rowHeight here is a cheap way to make sure that lines
// converge even allowing for the fact that they may not be spaced by exactly
// the expected distance. Cf. the stencil-powered logic for making sure all
@ -144,6 +144,30 @@ void ScanTarget::enable_vertex_attributes(ShaderType type, Shader &target) {
#undef rt_offset_of
}
std::vector<std::string> ScanTarget::bindings(ShaderType type) const {
switch(type) {
case ShaderType::Composition: return {
"startDataX",
"startClock",
"endDataX",
"endClock",
"dataY",
"lineY"
};
default: return {
"startPoint",
"endPoint",
"startClock",
"endClock",
"lineY",
"lineCompositeAmplitude",
"startCompositeAngle",
"endCompositeAngle"
};
}
}
// MARK: - Shader code.
std::string ScanTarget::sampling_function() const {
@ -421,16 +445,7 @@ std::unique_ptr<Shader> ScanTarget::conversion_shader() const {
return std::unique_ptr<Shader>(new Shader(
vertex_shader,
fragment_shader,
{
"startPoint",
"endPoint",
"startClock",
"endClock",
"lineY",
"lineCompositeAmplitude",
"startCompositeAngle",
"endCompositeAngle"
}
bindings(ShaderType::Conversion)
));
}
@ -504,14 +519,7 @@ std::unique_ptr<Shader> ScanTarget::composition_shader() const {
return std::unique_ptr<Shader>(new Shader(
vertex_shader,
fragment_shader + "}",
{
"startDataX",
"startClock",
"endDataX",
"endClock",
"dataY",
"lineY",
}
bindings(ShaderType::Composition)
));
}
@ -624,14 +632,6 @@ std::unique_ptr<Shader> ScanTarget::qam_separation_shader() const {
return std::unique_ptr<Shader>(new Shader(
vertex_shader,
fragment_shader,
{
"startClock",
"startCompositeAngle",
"endClock",
"endCompositeAngle",
"lineY",
"lineCompositeAmplitude"
}
bindings(ShaderType::QAMSeparation)
));
}