mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-27 06:35:04 +00:00
Ensures redraws when resizing; declines to busy wait otherwise.
This commit is contained in:
parent
e9d1afd515
commit
3045e85004
@ -68,7 +68,7 @@
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
buildConfiguration = "Release"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
enableASanStackUseAfterReturn = "YES"
|
||||
|
@ -244,7 +244,7 @@ struct ActivityObserver: public Activity::Observer {
|
||||
}
|
||||
|
||||
- (void)drawViewForPixelSize:(CGSize)pixelSize onlyIfDirty:(BOOL)onlyIfDirty {
|
||||
_scanTarget->draw();
|
||||
_scanTarget->draw(onlyIfDirty ? false : true);
|
||||
// _machine->crt_machine()->get_crt()->draw_frame((unsigned int)pixelSize.width, (unsigned int)pixelSize.height, onlyIfDirty ? true : false);
|
||||
}
|
||||
|
||||
|
@ -286,8 +286,14 @@ template <typename T> void ScanTarget::submit_buffer(const T &array, GLuint targ
|
||||
}
|
||||
}
|
||||
|
||||
void ScanTarget::draw() {
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
void ScanTarget::draw(bool synchronous) {
|
||||
if(fence_ != nullptr) {
|
||||
// if the GPU is still busy, don't wait; we'll catch it next time
|
||||
if(glClientWaitSync(fence_, GL_SYNC_FLUSH_COMMANDS_BIT, synchronous ? GL_TIMEOUT_IGNORED : 0) == GL_TIMEOUT_EXPIRED) {
|
||||
return;
|
||||
}
|
||||
fence_ = nullptr;
|
||||
}
|
||||
|
||||
// Grab the current read and submit pointers.
|
||||
const auto submit_pointers = submit_pointers_.load();
|
||||
@ -358,8 +364,11 @@ void ScanTarget::draw() {
|
||||
|
||||
// TEST: draw all lines.
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBindVertexArray(line_vertex_array_);
|
||||
test_shader_->bind();
|
||||
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, GLsizei(scan_buffer_.size()));
|
||||
|
||||
fence_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class ScanTarget: public Outputs::Display::ScanTarget {
|
||||
public:
|
||||
ScanTarget();
|
||||
~ScanTarget();
|
||||
void draw();
|
||||
void draw(bool synchronous);
|
||||
|
||||
private:
|
||||
// Outputs::Display::ScanTarget overrides.
|
||||
@ -130,6 +130,7 @@ class ScanTarget: public Outputs::Display::ScanTarget {
|
||||
void enable_vertex_attributes(ShaderType type, Shader &target);
|
||||
|
||||
std::unique_ptr<Shader> test_shader_;
|
||||
GLsync fence_ = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -45,8 +45,11 @@ std::string ScanTarget::glsl_globals(ShaderType type) {
|
||||
}
|
||||
|
||||
std::string ScanTarget::glsl_default_vertex_shader(ShaderType type) {
|
||||
// switch(type) {
|
||||
// case ShaderType::Scan:
|
||||
switch(type) {
|
||||
case ShaderType::Scan:
|
||||
return "";
|
||||
|
||||
case ShaderType::Line:
|
||||
return
|
||||
"void main(void) {"
|
||||
"float lateral = float(gl_VertexID & 1);"
|
||||
@ -57,10 +60,7 @@ std::string ScanTarget::glsl_default_vertex_shader(ShaderType type) {
|
||||
"vec2 eyePosition = vec2(-0.9, 0.9) + vec2(1.8, -1.8) * (centrePoint + height);"
|
||||
"gl_Position = vec4(eyePosition, 0.0, 1.0);"
|
||||
"}";
|
||||
|
||||
// case ShaderType::Line:
|
||||
// return "";
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
void ScanTarget::enable_vertex_attributes(ShaderType type, Shader &target) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user