Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 19 Jun 2013
Offline Last Active May 04 2014 02:05 AM

Topics I've Started

Query SSBO size fails when >64kb (LWJGL)

02 May 2014 - 02:34 PM

I'm trying to query the size of a SSBO I declared in a shader.

layout(shared) buffer SourceBuffer
	float	s[NUM_ELEMENTS];
glGetProgramResourcei(programHandle, variables, index, GL_ARRAY_STRIDE)

returns 16 = 4*sizeof(float)



when setting NUM_ELEMENTS to 4096-> we have

NUM_ELEMENTS * STRIDE = 4096 * 4 = 16384 elements = 64kb

glGetProgramResourcei(programHandle, GL_SHADER_STORAGE_BLOCK, interfaceBlockIndex, GL_BUFFER_DATA_SIZE);

With that setup glGetProgramResourcei returns the correct size. But when I get higher as the 64kb it returns -16 ?!?!?!


My card fully supports OpenGL 4.3.

Image Image-LoadStore vs Shader-Storage-Buffer-Object

01 May 2014 - 08:13 AM

I'am having some questions about Image Image-LoadStore and SSBOs (and also UBO).


I will move solved Questions down to Facts.



* why is a float[]-array not tighly packed when declared in a SSBO. ??? There is always a stride of sizeof(vec4).

* ... why does this make sense ???

* what are typical use-cased for the two ???


Facts (or educated-guesses):

* SSBO and Textures both reside in global memory?                                       normally yes.

* Acces to SSBOs is uncached?                                                                       only L2 cache.

* Acces to textures via LoadStore is cached (texture-cache)?                          yes, uses texture-Cache.

* The actual load and store via LoadStore is done by texturing-hardware?      yes, uses texture-memory-pipeline.

* which of the two is more performant?                                                             texture-cache has better 2d-spacial-locality, but latency longer

* where do UBOs reside in memory?                                                                uniform-buffers reside in the constant-cache! (only 1-float per clock)

* can I also write to an Uniform-Buffer?                                                             no.

Formular to get Frumstum-Index from Vector for 2D-Cube-Mapping

13 April 2014 - 04:14 AM

I'm working on a formular to calculate the index for the frustum of a 2D-Point-Light.

My Light-System is rendering the Scene into 4 1D-Textures: Right, Left, Top and Bottom.


Now, in the fragment shader I want to query the index for the frustum corresponding to the fragment position in light-space,

so I know which depth texture I have to sample.


I got one that works, but it's very complicated.




Or should I just do a series of "if" statements.

My concern with that is, that inside a warp, only the body of one if-statement can be entered, which leaves all fragments idling, if they have different frustum.

2D point light shadow - depth interpolation problem

11 April 2014 - 05:59 AM

I'm writing  a shader for a 2d point light shadow mapper.


I render the depth-values of the right Frustum of the light into a texture which is 1024x1 pixels in size.



I project the vertices myself, so I dont use the w coordinate.


This is my projection into the shadow-map. "vs.lightSpace" means that all vertices are in the coordinate-system of the light. (0,0) is it's origin.

	gl_Position = vec4(
		vs.lightSpace.y / vs.lightSpace.x,
float depthToHom(float depth) {
	float near = 0.5f;
	float far  = 10.0f;
	return depth * 2.0f / (far - near) + (-far - near) / (far - near);

As you can see the depth-values are not interpolated correctly. On long edges there is a round curve in the shadow. Is this because I don't divide correctly? The big white circle is supposed to be a point-light.




To sample the depth I use:

float depth = texture(shadowMap, vec2((lightSpace.y / lightSpace.x + 1.0f) * 0.5f, 0.5f)).x;

if(depthToNorm(lightSpace.x) > depth)
//... ... ...
float depthToNorm(float depth) {
    float near = 0.5f;
    float far  = 10.0f;
    return depth * (1.0f / (far - near)) + (-near) / (far - near);

Uniform Buffer & shared layout -> Index still -1

26 September 2013 - 07:27 AM

Hello. I'm trying to share a Uniform Buffer among different programs. The problem is, that I have to query the layout - which is shared - at one point. I tried all possibilities, but it always return -1.
The specification tells me, that with the shared layout, the driver is not allowed to optimize and has toactivate the variables.
What did I miss?
#version 420 core
layout(shared) uniform Camera {
mat4 camViewProj;
mat4 sunViewProj;
mat4 sunViewCoordProj;
out mat4 outVar;
void main()
//outVar = camViewProj;
I only get a valid index for "camViewProj" when I uncomment the section above.
To Query the indices, I used: