gpu: move common compute header to its own file
This commit is contained in:
@@ -24,18 +24,6 @@
|
||||
*/
|
||||
#version 430 core
|
||||
|
||||
#define PI 3.1415926535897932384626433832795f
|
||||
#define UNIT PI / 1024.0f
|
||||
|
||||
layout(std140) uniform uniforms {
|
||||
int cameraYaw;
|
||||
int cameraPitch;
|
||||
int centerX;
|
||||
int centerY;
|
||||
int zoom;
|
||||
ivec2 sinCosTable[2048];
|
||||
};
|
||||
|
||||
shared int totalNum[12]; // number of faces with a given priority
|
||||
shared int totalDistance[12]; // sum of distances to faces of a given priority
|
||||
|
||||
@@ -55,33 +43,7 @@ struct modelinfo {
|
||||
int z; // scene position z
|
||||
};
|
||||
|
||||
layout(std430, binding = 0) readonly buffer modelbuffer_in {
|
||||
modelinfo ol[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 1) readonly buffer vertexbuffer_in {
|
||||
ivec4 vb[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 2) readonly buffer tempvertexbuffer_in {
|
||||
ivec4 tempvb[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 3) writeonly buffer vertex_out {
|
||||
ivec4 vout[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 4) writeonly buffer uv_out {
|
||||
vec4 uvout[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 5) readonly buffer uvbuffer_in {
|
||||
vec4 uv[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 6) readonly buffer tempuvbuffer_in {
|
||||
vec4 tempuv[];
|
||||
};
|
||||
#include comp_common.glsl
|
||||
|
||||
layout(local_size_x = 1024) in;
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS BE 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.
|
||||
*/
|
||||
|
||||
#define PI 3.1415926535897932384626433832795f
|
||||
#define UNIT PI / 1024.0f
|
||||
|
||||
layout(std140) uniform uniforms {
|
||||
int cameraYaw;
|
||||
int cameraPitch;
|
||||
int centerX;
|
||||
int centerY;
|
||||
int zoom;
|
||||
ivec2 sinCosTable[2048];
|
||||
};
|
||||
|
||||
struct modelinfo {
|
||||
int offset; // offset into buffer
|
||||
int uvOffset; // offset into uv buffer
|
||||
int length; // length in faces
|
||||
int idx; // write idx in target buffer
|
||||
int flags; // radius, orientation
|
||||
int x; // scene position x
|
||||
int y; // scene position y
|
||||
int z; // scene position z
|
||||
};
|
||||
|
||||
layout(std430, binding = 0) readonly buffer modelbuffer_in {
|
||||
modelinfo ol[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 1) readonly buffer vertexbuffer_in {
|
||||
ivec4 vb[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 2) readonly buffer tempvertexbuffer_in {
|
||||
ivec4 tempvb[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 3) writeonly buffer vertex_out {
|
||||
ivec4 vout[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 4) writeonly buffer uv_out {
|
||||
vec4 uvout[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 5) readonly buffer uvbuffer_in {
|
||||
vec4 uv[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 6) readonly buffer tempuvbuffer_in {
|
||||
vec4 tempuv[];
|
||||
};
|
||||
@@ -24,18 +24,6 @@
|
||||
*/
|
||||
#version 430 core
|
||||
|
||||
#define PI 3.1415926535897932384626433832795f
|
||||
#define UNIT PI / 1024.0f
|
||||
|
||||
layout(std140) uniform uniforms {
|
||||
int cameraYaw;
|
||||
int cameraPitch;
|
||||
int centerX;
|
||||
int centerY;
|
||||
int zoom;
|
||||
ivec2 sinCosTable[2048];
|
||||
};
|
||||
|
||||
shared int totalNum[12]; // number of faces with a given priority
|
||||
shared int totalDistance[12]; // sum of distances to faces of a given priority
|
||||
|
||||
@@ -44,44 +32,7 @@ shared int totalMappedNum[18]; // number of faces with a given adjusted priority
|
||||
shared int min10; // minimum distance to a face of priority 10
|
||||
shared int dfs[512]; // packed face id and distance
|
||||
|
||||
struct modelinfo {
|
||||
int offset; // offset into buffer
|
||||
int uvOffset; // offset into uv buffer
|
||||
int length; // length in faces
|
||||
int idx; // write idx in target buffer
|
||||
int flags; // radius, orientation
|
||||
int x; // scene position x
|
||||
int y; // scene position y
|
||||
int z; // scene position z
|
||||
};
|
||||
|
||||
layout(std430, binding = 0) readonly buffer modelbuffer_in {
|
||||
modelinfo ol[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 1) readonly buffer vertexbuffer_in {
|
||||
ivec4 vb[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 2) readonly buffer tempvertexbuffer_in {
|
||||
ivec4 tempvb[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 3) writeonly buffer vertex_out {
|
||||
ivec4 vout[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 4) writeonly buffer uv_out {
|
||||
vec4 uvout[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 5) readonly buffer uvbuffer_in {
|
||||
vec4 uv[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 6) readonly buffer tempuvbuffer_in {
|
||||
vec4 tempuv[];
|
||||
};
|
||||
#include comp_common.glsl
|
||||
|
||||
layout(local_size_x = 512) in;
|
||||
|
||||
|
||||
@@ -85,6 +85,33 @@ public class ShaderTest
|
||||
gl = glContext.getGL().getGL4();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testUnordered() throws ShaderException
|
||||
{
|
||||
int glComputeProgram = gl.glCreateProgram();
|
||||
int glComputeShader = gl.glCreateShader(gl.GL_COMPUTE_SHADER);
|
||||
try
|
||||
{
|
||||
Function<String, String> func = (s) -> inputStreamToString(getClass().getResourceAsStream(s));
|
||||
Template template = new Template(func);
|
||||
String source = template.process(func.apply("comp_unordered.glsl"));
|
||||
|
||||
int line = 0;
|
||||
for (String str : source.split("\\n"))
|
||||
{
|
||||
System.out.println(++line + " " + str);
|
||||
}
|
||||
|
||||
GLUtil.loadComputeShader(gl, glComputeProgram, glComputeShader, source);
|
||||
}
|
||||
finally
|
||||
{
|
||||
gl.glDeleteShader(glComputeShader);
|
||||
gl.glDeleteProgram(glComputeProgram);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testSmall() throws ShaderException
|
||||
|
||||
Reference in New Issue
Block a user