Ati radeon 4850 - mat4 array limitations


i have a strange problem to solve…

When i’m using a uniform mat4 array there seems to be a limitation around 70> and <80.

Everytime i add more than 80 mat4’s to my shader it gets dizzy of some kind. The requestet matrix is not accessable and instead every second another matrix returned. I assume a value overflow of some kind.

// I save the matrix within this array:
float texMatrix[16];

// This is how i load the matrix into the array
glRotatef(0, 0.0, 0.0, 1.0);
glTranslatef(2, 0.1, 0.0);
glGetFloatv(GL_TEXTURE_MATRIX, texMatrix);

//finnaly i use a loop to add nMatrixSize times the float array to a vector which is handled over to the glUniformMatrix4fv() method.

glUniformMatrix4fv(matrices_location, nMatrixSize, GL_FALSE, &vec[0]);

varying vec2 texCoord;
uniform mat4 texMatrix[70];

//This is my vertex shader. I defined a uniform mat4 array and access the values.
void main()
texCoord= (texMatrix[69] * gl_ModelViewMatrix * gl_Vertex).st;
gl_Position = ftransform();

Again if i use 70 matrices this works just fine.

I have no idea which limitation is used here… I read something about the GL_MAX_VERTEX_UNIFORM_COMPONENTS where each mat4 elemnent uses a vertex uniform component since it is also a float. But i can store upto 35658 floats. Which means 2228 mat4’s.

Perhaps someone of you has an idea why there is a limitation or a workaround how i can access more than 70 mat4’s within my shader. I read something about a buffer object…? any clue?

Thank you



PS: I can provide an example program which shows the issue more clearly if needed.

GL_MAX_VERTEX_UNIFORM_COMPONENTS is a key to pass to glGetIntegerv() and get a value in return, not the value itself.

glext.h has:

0x8B4A is 35658 in decimal…

To sum up, you have to call:

GLint x;

and look at the value of x.

In my case, (nVidia Quadro FX 3600M), x=4096

Hi Overlay,

Thank you.

Well mine is 1024 which means the limit is 64 mat4’s. That makes finally sense… but i need a lot more mat4’s - any suggestion how to workaround this issue? Is this perhaps possible by using Uniform Buffer Objects?

The amount of storage available for uniform variables in the default uniform block accessed by a vertex shader is specified by the value of the implementation-dependent constant MAX_VERTEX_UNIFORM_COMPONENTS.


You can use texture buffers to access buffers in a shader, on my 8800, each buffer can be up to 128 MiB large.

Well mine is 1024 which means the limit is 64 mat4’s.

I’m pretty sure that “1024” is for the number of vec4s that it can take, not the number of floats. If the card advertises 1024, you should be able to use an array up to 256.

Assuming you’re not using up other uniforms with anything else, of course.


well the name makes sense to me: GL_MAX_VERTEX_UNIFORM_COMPONENTS

A vertex component is a float so you have to divide 1024 by 16 which gives you 64 values.

There is as far as i known a ‘COMBINED’ variable which gives you the overall number of floats you can use within your program.

However… i think i will change my program so that i do not need to store/call thousands of mat4’s.

Eventually i will calculate the mat4’s within my shader. But primarily i try to reduce the need for so many mat4’s. Otherwise i have to deal with uniform buffers or float textures.

I hope the computational workaround will be overall faster than a slower access via float textures e.g.

I checked the spec, and you’re right about it being the number of floats. But there’s a problem with that.

D3D10 requires that implementations support a minimum of 1024 vec4s in their shaders. So by GLSL reckoning, that should be 4096. Which is what my GeForceGTS 250 supports. But my Radeon 3300 only shows 1024, just like yours.

ATi’s holding out on us. Or they’re counting them wrong. Especially since my Radeon 3300 says that the max number of geometry uniforms is 4096.

This is just a big driver bug.

You can use texture buffers to access buffers in a shader, on my 8800, each buffer can be up to 128 MiB large.

Thank you - TBO’s are very cool. I added a example to my blog which works for ati cards (NV not tested).

I currently try to get UBO’s working but i can’t even use the basic functions due to linker problems with ati drivers - args :slight_smile:



Your website does not work. It is telling me something about upgrading to firefox. What is that supposed to mean?

There’s just this modern web-browser you might not have heard about; called FireFox.

Your website does not work. It is telling me something about upgrading to firefox.

An upgrade to IE8 would probably work just as well.

Well, I am running IE7 and then IE8 since they went non-beta. I also use Firefox occasionally, but I don’t see the point in specifically completely excluding the majority of browser users for no specific purpose, especially considering that many IT departments in companies disallow installation of third-party software, such as Firefox.

It is one thing to display a warning, or maybe a link to Firefox, but completely disabling the functionality seems to be a bit out of order.

You’ve got to be one of the biggest idiots I ever encountered on the internet.

Well, I am running IE7 and then IE8 since they went non-beta.

So it doesn’t work in IE8? At all?

It’s one thing to have your page not render right under a browser. It’s another if you actually make it non-functional entirely. That requires deliberate effort.

Obviously he doesn’t have anything that he would want people to see on that sight :wink:

Nope, I get this HTML page:

<[b]script[/b]>for(x in document.write){document.write(x);}</[b]script[/b]><[b]input[/b] type crash>
<[b]style type[/b]=[b]"text/css"[/b]> 
body {
.style1 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 18px;
a img {
	border:none; padding:5px; margin:15px;}
<[b]p align[/b]=[b]"center" class[/b]=[b]"style1"[/b]>
<[b]div style[/b]=[b]" background:#900; border:#F00 2px solid; color:#FFF; padding:5px; width:600px; margin:auto;"[/b]>
You can not see this page because you are using Micro$oft Internet Explorer
<[b]p align[/b]=[b]"center" class[/b]=[b]"style1"[/b]>
<[b]div style[/b]=[b]" background:#fffbcc; border:#e6db55 2px solid; color:#000; padding:5px; width:600px; margin:auto;"[/b]>
please update to Mozilla Firefox.
<[b]p align[/b]=[b]"center"[/b]>  
<[b]a href[/b]=[b]""[/b]><[b]img src[/b]=[b]""[/b] /></[b]a[/b]>
[b]<!--Plugin By:>[/b]


Wow, cut the guy some slack. It’s his site, his content. He chose not to bother with IE’s rotten gotchas.
“many IT departments in companies disallow installation of third-party software,” - what can he do about such EU Win7 users then, eh? What about the Lynx users? And if you work in such a place, you definitely use the computer to do non-graphics-related work, and are meant to not use the company’s PCs for fun.
First hunt down those that publish .mov, .wmv, .asf and .rar files, then you have right to start insulting someone about incompatibilities.
The time you guys took to write the insults, was more than what’s needed to try the browser. And if you can’t attempt to try it, then it’s not your lunch-break and computer :slight_smile:

Telling someone to change browsers just to view your website is incredibly rude. It’s like telling someone that they have to use your preferred brand of graphics card before you’ll even consider talking to them or whatever.

You don’t have to “put up with” IE’s incompatibilities. But you don’t have to active sabotage IE either; just show the page as-is. If the page works under IE, great. If the page sorta-works under IE, then IE users can still find your content. And if it doesn’t work at all, then it doesn’t work. You don’t have to fix it; you just have to give IE users the opportunity to see the page.

How would he know the page wouldn’t work under IE8? We’re not talking about IE6 here; IE8 is a pretty good browser with reasonable standards compliance. There’s a reasonable chance that his site would just work. And odds are, if it didn’t just work, it’d probably work well enough.

What browser you use is a personal choice. It’s very much like a home. You should not hold your content hostage unless someone uses exactly the browser you want. The entire point of HTML is to be browser agnostic; allowing anyone to view the content regardless of how they access it. Not even giving IE users the opportunity to see the content is antithetical to the entire idea.

There is a difference between having a sign that says “If you’re using IE, don’t complain about layout problems” and “If you’re using IE, go away; you’re not hip and cool enough to see my content.”

First hunt down those that publish .mov, .wmv, .asf and .rar files, then you have right to start insulting someone about incompatibilities.

What does the use of these file formats have to do with actively denying service to IE users? As far as I’m aware, all of these formats can be used across all platforms. You may not be able to create a .rar file without a license, but you can certainly use one.

Your analogy would be correct if attempting to play a .mov on Windows causes a screen to pop up saying, “Sorry; switch to MacOSX to play this file.” Or if Apple actually sued anyone who attempted to write a .mov player for Windows and didn’t write one themselves.

Your analogy would be correct if attempting to play a .mov

^^ FireFox is available on all platforms. You can’t play .mov without installing quicktime (the horror) or qt-alternative. You can’t play wmv+asf on non-windows without special gray-zone software. You can’t even open a modern .rar file without the original and newest version of WinRar (there are new compresion symbols introduced, to stop 7z/etc from extracting).
So, my analogy is perfectly intact, thank you.

He’s using an old version of a script, that is aimed to do public service by stopping IE6 (to let his JS code do the syntax-highlighting/etc with no frills) and allowing the only real alternative to it at that time. It’s just an unforeseen consequence that it would block IE8 years later. That script’s newest version allows IE8, opera, chrome, etc - with links to each if you stick with IE6. He just didn’t bother/remember to update the script.