mirror of
https://github.com/TomHarte/CLK.git
synced 2026-04-20 10:17:05 +00:00
Enable generation of the needed composition shader.
Proving that I've forgotten something about vertex attribute bindings.
This commit is contained in:
@@ -387,30 +387,30 @@ OpenGL::Shader OpenGL::composition_shader(
|
||||
//
|
||||
// Enable vertex attributes.
|
||||
//
|
||||
BufferingScanTarget::Scan scan;
|
||||
const auto enable = [&](const std::string &name, auto &element, const bool normalise) {
|
||||
assert(sizeof(element) == 1 || sizeof(element) == 2);
|
||||
shader.enable_vertex_attribute_with_pointer(
|
||||
name,
|
||||
1,
|
||||
sizeof(element) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE,
|
||||
normalise ? GL_TRUE : GL_FALSE,
|
||||
sizeof(scan),
|
||||
reinterpret_cast<void *>((reinterpret_cast<uint8_t *>(&element) - reinterpret_cast<uint8_t *>(&scan))),
|
||||
1
|
||||
);
|
||||
};
|
||||
|
||||
for(int c = 0; c < 2; c++) {
|
||||
const std::string endpoint = std::string("scanEndpoint") + std::to_string(c);
|
||||
enable(endpoint + "DataOffset", scan.scan.end_points[c].data_offset, false);
|
||||
enable(endpoint + "CyclesSinceRetrace", scan.scan.end_points[c].cycles_since_end_of_horizontal_retrace, false);
|
||||
enable(endpoint + "CompositeAngle", scan.scan.end_points[c].composite_angle, false);
|
||||
}
|
||||
|
||||
enable("scanDataY", scan.data_y, false);
|
||||
enable("scanLine", scan.line, false);
|
||||
enable("scanCompositeAmplitude", scan.scan.composite_amplitude, true);
|
||||
// BufferingScanTarget::Scan scan;
|
||||
// const auto enable = [&](const std::string &name, auto &element, const bool normalise) {
|
||||
// assert(sizeof(element) == 1 || sizeof(element) == 2);
|
||||
// shader.enable_vertex_attribute_with_pointer(
|
||||
// name,
|
||||
// 1,
|
||||
// sizeof(element) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE,
|
||||
// normalise ? GL_TRUE : GL_FALSE,
|
||||
// sizeof(scan),
|
||||
// reinterpret_cast<void *>((reinterpret_cast<uint8_t *>(&element) - reinterpret_cast<uint8_t *>(&scan))),
|
||||
// 1
|
||||
// );
|
||||
// };
|
||||
//
|
||||
// for(int c = 0; c < 2; c++) {
|
||||
// const std::string endpoint = std::string("scanEndpoint") + std::to_string(c);
|
||||
// enable(endpoint + "DataOffset", scan.scan.end_points[c].data_offset, false);
|
||||
// enable(endpoint + "CyclesSinceRetrace", scan.scan.end_points[c].cycles_since_end_of_horizontal_retrace, false);
|
||||
// enable(endpoint + "CompositeAngle", scan.scan.end_points[c].composite_angle, false);
|
||||
// }
|
||||
//
|
||||
// enable("scanDataY", scan.data_y, false);
|
||||
// enable("scanLine", scan.line, false);
|
||||
// enable("scanCompositeAmplitude", scan.scan.composite_amplitude, true);
|
||||
|
||||
//
|
||||
// Set uniforms.
|
||||
|
||||
@@ -156,7 +156,7 @@ void Shader::init(
|
||||
}
|
||||
}
|
||||
|
||||
Shader::Shader(Shader &&rhs) {
|
||||
Shader &Shader::operator =(Shader &&rhs) {
|
||||
api_ = rhs.api_;
|
||||
shader_program_ = rhs.shader_program_;
|
||||
|
||||
@@ -164,6 +164,11 @@ Shader::Shader(Shader &&rhs) {
|
||||
bound_shader = this;
|
||||
}
|
||||
rhs.shader_program_ = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Shader::Shader(Shader &&rhs) {
|
||||
*this = std::move(rhs);
|
||||
}
|
||||
|
||||
Shader::~Shader() {
|
||||
|
||||
@@ -65,8 +65,10 @@ public:
|
||||
);
|
||||
~Shader();
|
||||
|
||||
// Allow moves.
|
||||
// Allow moves, including move assignment, and default construction to create something vacant.
|
||||
Shader(Shader&&);
|
||||
Shader &operator =(Shader &&);
|
||||
Shader() = default;
|
||||
|
||||
/*!
|
||||
Performs an @c glUseProgram to make this the active shader unless:
|
||||
@@ -146,7 +148,7 @@ private:
|
||||
|
||||
GLuint compile_shader(const std::string &source, GLenum type);
|
||||
API api_;
|
||||
GLuint shader_program_;
|
||||
GLuint shader_program_ = 0;
|
||||
|
||||
void flush_functions() const;
|
||||
mutable std::vector<std::function<void(void)>> enqueued_functions_;
|
||||
|
||||
@@ -244,6 +244,31 @@ void ScanTarget::setup_pipeline() {
|
||||
input_shader_->set_uniform("textureName", GLint(SourceDataTextureUnit - GL_TEXTURE0));
|
||||
}
|
||||
|
||||
//
|
||||
// New pipeline starts here!
|
||||
//
|
||||
const auto buffer_width = FilterGenerator::SuggestedBufferWidth;
|
||||
const float sample_multiplier =
|
||||
FilterGenerator::suggested_sample_multiplier(227.5f, 1320);
|
||||
|
||||
if(
|
||||
!existing_modals_ ||
|
||||
existing_modals_->input_data_type != modals.input_data_type ||
|
||||
existing_modals_->display_type != modals.display_type ||
|
||||
existing_modals_->composite_colour_space != modals.composite_colour_space
|
||||
) {
|
||||
composition_shader_ = OpenGL::composition_shader(
|
||||
api_,
|
||||
modals.input_data_type,
|
||||
modals.display_type,
|
||||
modals.composite_colour_space,
|
||||
sample_multiplier,
|
||||
2048, 2048,
|
||||
buffer_width, 2048,
|
||||
GL_TEXTURE0
|
||||
);
|
||||
}
|
||||
|
||||
existing_modals_ = modals;
|
||||
}
|
||||
|
||||
@@ -277,10 +302,13 @@ void ScanTarget::update(int, int output_height) {
|
||||
|
||||
// Establish the pipeline if necessary.
|
||||
const auto new_modals = BufferingScanTarget::new_modals();
|
||||
const bool did_setup_pipeline = bool(new_modals);
|
||||
if(did_setup_pipeline) {
|
||||
setup_pipeline();
|
||||
}
|
||||
const bool did_setup_pipeline = [&] {
|
||||
if(bool(new_modals)) {
|
||||
setup_pipeline();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} ();
|
||||
|
||||
// Determine the start time of this submission group and the number of lines it will contain.
|
||||
line_submission_begin_time_ = std::chrono::high_resolution_clock::now();
|
||||
|
||||
@@ -121,6 +121,8 @@ private:
|
||||
std::unique_ptr<Shader> output_shader_;
|
||||
std::unique_ptr<Shader> qam_separation_shader_;
|
||||
|
||||
Shader composition_shader_;
|
||||
|
||||
/*!
|
||||
Produces a shader that composes fragment of the input stream to a single buffer,
|
||||
normalising the data into one of four forms: RGB, 8-bit luminance,
|
||||
|
||||
Reference in New Issue
Block a user