Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to create shader - waveform-compute.glsl failed #129

Closed
ggsubs opened this issue Jul 7, 2020 · 1 comment
Closed

Failed to create shader - waveform-compute.glsl failed #129

ggsubs opened this issue Jul 7, 2020 · 1 comment

Comments

@ggsubs
Copy link

ggsubs commented Jul 7, 2020

When running on a VM hosted on macOS Catalina. Guest OS is Ubuntu 18 LTS, the same result using either Parallels or VMWare Fusion. OpenGL versions under Parallels is OpenGL 2.1, on VMWare, it's OpenGL 3.3

ERROR: Failed to create shader (of type 37305)
ERROR: Compile of shader shaders/waveform-compute.glsl failed:
�����
Shader source: #version 430

//The output texture (for now, only alpha channel is used)
layout(binding=0, rgba32f) uniform image2D outputTex;

//Voltage data
struct data_point
{
	float x;		//x pixel position (fractional)
	float voltage;	//y value of this sample, in pixels
};

layout(std430, binding=1) buffer waveform
{
	data_point data[];
};

//Global configuration for the run
layout(std430, binding=2) buffer config
{
	uint windowHeight;
	uint windowWidth;
	uint memDepth;
	uint alpha_scaled;
};

//Indexes so we know which samples go to which X pixel range
layout(std430, binding=3) buffer index
{
	uint xind[];
};

//Maximum height of a single waveform, in pixels.
//This is enough for a nearly fullscreen 4K window so should be plenty.
#define MAX_HEIGHT		2048

//Number of columns of pixels per thread block
#define COLS_PER_BLOCK	2

layout(local_size_x=COLS_PER_BLOCK, local_size_y=1, local_size_z=1) in;

//Interpolate a Y coordinate
float InterpolateY(vec2 left, vec2 right, float slope, float x)
{
	return left.y + ( (x - left.x) * slope );
}

/*
NEW IDEA
Multiple threads per X coordinate (say, 32 - 1 warp)
Parallel fetch base[i+z] and atomically increment local memory

Each local has a 2D shared array
Assuming 96 KB shared memory, we can fit a total of 24K float32 temp pixels
Assuming 2K max line height, that's up to 12 pixels of width per local
*/

//Shared buffer for the local working buffer
shared float g_workingBuffer[COLS_PER_BLOCK][MAX_HEIGHT];

void main()
{
	//Abort if window height is too big, or if we're off the end of the window
	if(windowHeight > MAX_HEIGHT)
		return;
	if(gl_GlobalInvocationID.x > windowWidth)
		return;

	//Save some constants
	float alpha = float(alpha_scaled) / 256;

	//Clear column to blank in the first thread of the block
	if(gl_LocalInvocationID.y == 0)
	{
		for(uint y=0; y<windowHeight; y++)
			g_workingBuffer[gl_LocalInvocationID.x][y] = 0;
	}
	barrier();
	memoryBarrierShared();

	//Loop over the waveform, starting at the leftmost point that overlaps this column
	uint istart = xind[gl_GlobalInvocationID.x];
	vec2 left = vec2(data[istart].x, data[istart].voltage);
	vec2 right;
	for(uint i=istart; i<(memDepth-1); i++)
	{
		//Fetch coordinates of the current and upcoming sample
		right = vec2(data[i+1].x, data[i+1].voltage);

		//If the current point is right of us, stop
		if(left.x > gl_GlobalInvocationID.x + 1)
			break;

		//If the upcoming point is still left of us, we're not there yet
		if(right.x < gl_GlobalInvocationID.x)
		{
			left = right;
			continue;
		}

		//To start, assume we're drawing the entire segment
		float starty = left.y;
		float endy = right.y;

		//Interpolate if either end is outside our column
		float slope = (right.y - left.y) / (right.x - left.x);
		if(left.x < gl_GlobalInvocationID.x)
			starty = InterpolateY(left, right, slope, gl_GlobalInvocationID.x);
		if(right.x > gl_GlobalInvocationID.x + 1)
			endy = InterpolateY(left, right, slope, gl_GlobalInvocationID.x + 1);

		//Sort Y coordinates from min to max
		int ymin = int(min(starty, endy));
		int ymax = int(max(starty, endy));

		//Push current point down the pipeline
		left = right;

		//Fill in the space between min and max for this segment
		for(int y=ymin; y <= ymax; y++)
		{
			g_workingBuffer[gl_LocalInvocationID.x][y] += alpha;
		}

		//TODO: antialiasing
		//TODO: decimation at very wide zooms
	}

	//Copy working buffer to RGB output
	for(uint y=0; y<windowHeight; y++)
		imageStore(outputTex, ivec2(gl_GlobalInvocationID.x, y), vec4(0, 0, 0, g_workingBuffer[gl_LocalInvocationID.x][y]));
}

INTERNAL ERROR: failed to load waveform compute shader, aborting
    This indicates a bug in the program, please file a report via Github
Aborted (core dumped)
@azonenberg
Copy link
Collaborator

glscopeclient requires OpenGL 4.3 to get compute shaders. Is there any way to get newer in a virtual machine? GL 4.3 has been around since 2012 so I would expect it's pretty well supported.

My understanding is that OSX's OpenGL version is stuck at 4.1 forever since Apple deprecated OpenGL for some silly reason, so you probably won't be able to run it natively. Do you have a Linux or Windows computer you can try it on? Apple clearly has zero interest in cross platform accelerated graphics and I'm not about to rewrite the whole tool with a different graphics API, so for the time being I'm pretty sure OSX support is just not possible.

Closing this issue since there's nothing wrong with glscopeclient, the problem is on Apple's end. Feel free to hop in the IRC channel (#scopehal on Freenode) to discuss possible workarounds etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants