Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 65dd172a337c
Choose a base ref
...
head repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b9fcfeb64be7
Choose a head ref
  • 1 commit
  • 6 files changed
  • 1 contributor

Commits on Feb 21, 2020

  1. Copy the full SHA
    b9fcfeb View commit details
Showing with 170 additions and 3 deletions.
  1. +1 −0 glscopeclient/CMakeLists.txt
  2. +21 −1 glscopeclient/Program.h
  3. +1 −1 glscopeclient/Shader.cpp
  4. +9 −1 glscopeclient/Shader.h
  5. +50 −0 glscopeclient/ShaderStorageBuffer.cpp
  6. +88 −0 glscopeclient/ShaderStorageBuffer.h
1 change: 1 addition & 0 deletions glscopeclient/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ add_executable(glscopeclient
ProtocolAnalyzerWindow.cpp
ProtocolDecoderDialog.cpp
Shader.cpp
ShaderStorageBuffer.cpp
Texture.cpp
Timeline.cpp
VertexArray.cpp
22 changes: 21 additions & 1 deletion glscopeclient/Program.h
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2018 Andrew D. Zonenberg *
* Copyright (c) 2012-2020 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -95,16 +95,36 @@ class Program
void SetUniform(glm::mat4 mat, const char* name)
{ glUniformMatrix4fv(GetUniformLocation(name), 1, GL_FALSE, glm::value_ptr(mat)); }

void SetUniform(double f, const char* name)
{ glUniform1f(GetUniformLocation(name), f); }

void SetUniform(float f, const char* name)
{ glUniform1f(GetUniformLocation(name), f); }

void SetUniform(int i, const char* name)
{ glUniform1i(GetUniformLocation(name), i); }

void SetUniform(Texture& tex, const char* name, int texid = 0)
{
glActiveTexture(GL_TEXTURE0 + texid);
tex.Bind();
glUniform1i(GetUniformLocation(name), texid);
}

void SetImageUniform(Texture& tex, const char* name, int texid = 0)
{
glActiveTexture(GL_TEXTURE0 + texid);
tex.Bind();
glUniform1i(GetUniformLocation(name), texid);
glBindImageTexture(texid, tex, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
}

void DispatchCompute(GLuint x, GLuint y, GLuint z)
{ glDispatchCompute(x,y,z); }

void MemoryBarrier()
{ glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT | GL_SHADER_IMAGE_ACCESS_BARRIER_BIT); }

protected:
GLuint m_handle;

2 changes: 1 addition & 1 deletion glscopeclient/Shader.cpp
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2018 Andrew D. Zonenberg *
* Copyright (c) 2012-2020 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
10 changes: 9 additions & 1 deletion glscopeclient/Shader.h
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2018 Andrew D. Zonenberg *
* Copyright (c) 2012-2020 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -53,6 +53,14 @@ class Shader
GLuint m_handle;
};

class ComputeShader : public Shader
{
public:
ComputeShader()
: Shader(GL_COMPUTE_SHADER)
{}
};

class FragmentShader : public Shader
{
public:
50 changes: 50 additions & 0 deletions glscopeclient/ShaderStorageBuffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2020 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Implementation of ShaderStorageBuffer
*/
#include "glscopeclient.h"
#include "ShaderStorageBuffer.h"

using namespace std;

void ShaderStorageBuffer::BulkInit(vector<ShaderStorageBuffer*>& arr)
{
size_t sz = arr.size();
GLuint* p = new GLuint[sz];

glGenBuffers(sz, p);
for(size_t i=0; i<sz; i++)
arr[i]->m_handle = p[i];

delete[] p;
}
88 changes: 88 additions & 0 deletions glscopeclient/ShaderStorageBuffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2020 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of ShaderStorageBuffer
*/
#ifndef ShaderStorageBuffer_h
#define ShaderStorageBuffer_h

/**
@brief An OpenGL SSBO.
No virtual functions allowed, must be a POD type.
*/
class ShaderStorageBuffer
{
public:
ShaderStorageBuffer()
: m_handle(0)
{}

~ShaderStorageBuffer()
{ Destroy(); }

void Destroy()
{
if(m_handle != 0)
glDeleteBuffers(1, &m_handle);
m_handle = 0;
}

operator GLuint() const
{ return m_handle; }

void Bind()
{
LazyInit();
glBindBuffer(GL_SHADER_STORAGE_BUFFER, m_handle);
}

void BindBase(GLuint i)
{ glBindBufferBase(GL_SHADER_STORAGE_BUFFER, i, m_handle); }

static void BulkInit(std::vector<ShaderStorageBuffer*>& arr);

protected:

/**
@brief Lazily creates the VAO
*/
void LazyInit()
{
if(!m_handle)
glGenBuffers(1, &m_handle);
}

GLuint m_handle;
};

#endif