Texture samplers limited to min(GL_MAX_TEXTURE_COORDS, GL_MAX_TEXTURE_IMAGE_UNITS, G3D_MAX_TEXTURE_UNITS (= 16)) ?

50 views
Skip to first unread message

andyc

unread,
Nov 26, 2009, 4:07:05 PM11/26/09
to G3D Users
Hi,

this was going to be a question but I think I've found a problem in
the current G3D implementation. I made a fix and have a link to it at
the bottom, but I've left the body of this email as I wrote it while
going through the problem to provide context.

If I have 9 textures in a shader I hit assertions in G3D. After adding
some extra debugAssertGLOk();s I pin the GL_ERROR down to this moment
while binding uniforms prior to rendering:

dynamic_ao.exe!G3D::RenderDevice::forceSetTextureMatrix(int
unit=0x00000008, const float * m=0x00e16758) Line 2264 + 0xf6 bytes C+
+
dynamic_ao.exe!G3D::RenderDevice::setTexture(unsigned int
unit=0x00000008, const G3D::ReferenceCountedPointer<G3D::Texture> &
texture={...}) Line 2721 C++
dynamic_ao.exe!G3D::VertexAndPixelShader::bindArgList
(G3D::RenderDevice * rd=0x00e15f58, const
G3D::VertexAndPixelShader::ArgList & args={...}) Line 1258 C++
dynamic_ao.exe!G3D::RenderDevice::setVertexAndPixelShader(const
G3D::ReferenceCountedPointer<G3D::VertexAndPixelShader> & s={...},
const G3D::VertexAndPixelShader::ArgList & args={...}) Line 1809 C++
dynamic_ao.exe!G3D::Shader::beforePrimitive(G3D::RenderDevice *
renderDevice=0x00e15f58) Line 187 C++
dynamic_ao.exe!G3D::RenderDevice::beforePrimitive() Line 1033 +
0x24 bytes C++
dynamic_ao.exe!G3D::RenderDevice::beginPrimitive(G3D::PrimitiveType
p={...}) Line 2586 C++
dynamic_ao.exe!G3D::Draw::rect2D(const G3D::Rect2D & rect={...},
G3D::RenderDevice * rd=0x00e15f58, const G3D::Color4 & color={...},
const G3D::Rect2D & texCoord0={...}, const G3D::Rect2D & texCoord1=
{...}, const G3D::Rect2D & texCoord2={...}, const G3D::Rect2D &
texCoord3={...}, const G3D::Rect2D & texCoord4={...}, const
G3D::Rect2D & texCoord5={...}, const G3D::Rect2D & texCoord6={...},
const G3D::Rect2D & texCoord7={...}) Line 1284 C++
dynamic_ao.exe!G3D::Draw::rect2D(const G3D::Rect2D & rect={...},
G3D::RenderDevice * rd=0x00e15f58, const G3D::Color4 & color={...},
const G3D::Vector2 & texCoord0={...}, const G3D::Vector2 & texCoord1=
{...}, const G3D::Vector2 & texCoord2={...}, const G3D::Vector2 &
texCoord3={...}, const G3D::Vector2 & texCoord4={...}, const
G3D::Vector2 & texCoord5={...}, const G3D::Vector2 & texCoord6={...},
const G3D::Vector2 & texCoord7={...}) Line 1249 + 0x171 bytes C++
dynamic_ao.exe!AASlicemap::draw_quad(G3D::RenderDevice & rd={...},
G3D::Shader & shader={...}) Line 414 + 0x105 bytes C++
dynamic_ao.exe!AASlicemap::do_ao_as_post_process(G3D::RenderDevice &
rd={...}, G3D::Texture & normals_LinearZ={...}, const G3D::Matrix4 &
viewspaceToWorldspace={...}, const G3D::GCamera & finalViewCamera=
{...}, const G3D::Rect2D & vp={...}) Line 394 C++
dynamic_ao.exe!App::onGraphics3D(G3D::RenderDevice * rd=0x00e15f58,
G3D::Array<G3D::ReferenceCountedPointer<G3D::Surface>,10,32> &
surface3D={...}) Line 572 C++
dynamic_ao.exe!G3D::GApp::onGraphics(G3D::RenderDevice *
rd=0x00e15f58, G3D::Array<G3D::ReferenceCountedPointer<G3D::Surface>,
10,32> & posed3D={...},
G3D::Array<G3D::ReferenceCountedPointer<G3D::Surface2D>,10,32> &
posed2D={...}) Line 537 + 0x17 bytes C++
dynamic_ao.exe!G3D::GApp::oneFrame() Line 692 + 0x2d bytes C++

RenderDevice::setTexture() decides to reload a texture matrix but
there are only GL_MAX_TEXTURE_COORDS (8) of those and this is the
ninth texture so it causes a GL_ERROR.

If I put a guard around that reload, I get an assertion a little
further on, after drawing when old state is popped. It's the ninth
texture coordinate causing problems:

dynamic_ao.exe!G3D::RenderDevice::setTexCoord(unsigned int
unit=0x00000008, const G3D::Vector4 & texCoord={...}) Line 2518 +
0xd1 bytes C++
dynamic_ao.exe!G3D::RenderDevice::setState(const
G3D::RenderDevice::RenderState & newState={...}) Line 935 C++
dynamic_ao.exe!G3D::RenderDevice::popState() Line 1205 C++
dynamic_ao.exe!G3D::Shader::afterPrimitive(G3D::RenderDevice *
renderDevice=0x00315f58) Line 194 C++
dynamic_ao.exe!G3D::RenderDevice::afterPrimitive() Line 1046 + 0x24
bytes C++
dynamic_ao.exe!G3D::RenderDevice::endPrimitive() Line 2608 C++
dynamic_ao.exe!G3D::Draw::rect2D(const G3D::Rect2D & rect={...},
G3D::RenderDevice * rd=0x00315f58, const G3D::Color4 & color={...},
const G3D::Rect2D & texCoord0={...}, const G3D::Rect2D & texCoord1=
{...}, const G3D::Rect2D & texCoord2={...}, const G3D::Rect2D &
texCoord3={...}, const G3D::Rect2D & texCoord4={...}, const
G3D::Rect2D & texCoord5={...}, const G3D::Rect2D & texCoord6={...},
const G3D::Rect2D & texCoord7={...}) Line 1293 C++
dynamic_ao.exe!G3D::Draw::rect2D(const G3D::Rect2D & rect={...},
G3D::RenderDevice * rd=0x00315f58, const G3D::Color4 & color={...},
const G3D::Vector2 & texCoord0={...}, const G3D::Vector2 & texCoord1=
{...}, const G3D::Vector2 & texCoord2={...}, const G3D::Vector2 &
texCoord3={...}, const G3D::Vector2 & texCoord4={...}, const
G3D::Vector2 & texCoord5={...}, const G3D::Vector2 & texCoord6={...},
const G3D::Vector2 & texCoord7={...}) Line 1249 + 0x171 bytes C++
dynamic_ao.exe!AASlicemap::draw_quad(G3D::RenderDevice & rd={...},
G3D::Shader & shader={...}) Line 414 + 0x105 bytes C++
dynamic_ao.exe!AASlicemap::do_ao_as_post_process(G3D::RenderDevice &
rd={...}, G3D::Texture & normals_LinearZ={...}, const G3D::Matrix4 &
viewspaceToWorldspace={...}, const G3D::GCamera & finalViewCamera=
{...}, const G3D::Rect2D & vp={...}) Line 394 C++
dynamic_ao.exe!App::onGraphics3D(G3D::RenderDevice * rd=0x00315f58,
G3D::Array<G3D::ReferenceCountedPointer<G3D::Surface>,10,32> &
surface3D={...}) Line 572 C++
dynamic_ao.exe!G3D::GApp::onGraphics(G3D::RenderDevice *
rd=0x00315f58, G3D::Array<G3D::ReferenceCountedPointer<G3D::Surface>,
10,32> & posed3D={...},
G3D::Array<G3D::ReferenceCountedPointer<G3D::Surface2D>,10,32> &
posed2D={...}) Line 537 + 0x17 bytes C++
dynamic_ao.exe!G3D::GApp::oneFrame() Line 692 + 0x2d bytes C++

If I put a guard around that, my problem goes away and all is well for
me. I do think that there are some issues lurking in the texture
handling code though and I could discuss them if someone was
interested.

I have a patch for RenderDevice.cpp that gives an immediate fix for my
problem here:

http://www.cs.ucl.ac.uk/staff/Andrew.Cox/code/g3d/patches/g3d_patch4.diff

It would be great if this could be applied to the repository.

Best,
Andrew

Morgan McGuire

unread,
Nov 28, 2009, 11:29:35 AM11/28/09
to g3d-...@googlegroups.com
I filed a ticket for this. Thanks for the patch.

-m

Prof. Morgan McGuire
Computer Science Department
Williams College
http://cs.williams.edu/~morgan
> --
>
> You received this message because you are subscribed to the Google Groups "G3D Users" group.
> To post to this group, send email to g3d-...@googlegroups.com.
> To unsubscribe from this group, send email to g3d-users+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/g3d-users?hl=en.
>
>
>
Reply all
Reply to author
Forward
0 new messages