Hi,
I have following GPU error:
Error: Error #3763: Sampler 0 binds a texture that that does not match the read mode specified in AGAL. Reading compressed or single/dual channel textures must be explicitly declared.
at flash.display3D::Context3D/drawTriangles()
at starling.display.materials::StandardMaterial/drawTriangles()[C:\AS3Libraries\starling-graphics-extension\extension2.0\src\starling\display\materials\StandardMaterial.as:189]
at starling.display.graphics::GraphicRenderer/render()[C:\AS3Libraries\starling-graphics-extension\extension2.0\src\starling\display\graphics\GraphicRenderer.as:545]
at starling.display:😃isplayObjectContainer/render()[C:\AS3Libraries\starling\starling\src\starling\display\DisplayObjectContainer.as:406]
This is AGAL code that is used:
var format:String = texture.format;
var formatFlag:String;
switch (format)
{
case Context3DTextureFormat.COMPRESSED:
formatFlag = "dxt1"; break;
case Context3DTextureFormat.COMPRESSED_ALPHA:
formatFlag = "dxt5"; break;
default:
formatFlag = "rgba";
}
var agal:String =
"tex ft1, v1, fs0 <2d, repeat, linear, "+formatFlag+"> \n" +
"mul ft2, v0, fc0 \n" +
"mul oc, ft1, ft2";
compileAGAL(Context3DProgramType.FRAGMENT, agal);
What is interesting about this error is that it only occurs when I try to use different texture types with the AGAL above at runtime. I am passing 2 types of textures to this AGAL. One is Texture Atlas entire texture (which is always ATF ETC2) and another is POT Render Texture.
If I am using only one type of texture either Atlas texture or POT Render Texture with this AGAL everything is working fine no matter how many times or even if I use different textures ( different Texture atlases ) but as long as I use same texture type as first time used.
So If I started using that AGAL with Texture atlas texture everything is fine but as soon as I try to use POT Texture after using Atlas texture error is thrown. Or if I am using only POT texture also everything is fine but as soon as I try to use Atlas texture after using POT texture error is thrown.
This is the rendering function. It is from starling graphics extension:
public function drawTriangles(context:Context3D,
matrix:Matrix3D,
vertexBuffer:VertexBuffer3D,
indexBuffer:IndexBuffer3D,
alpha:Number = 1,
numTriangles:int = -1):void
{
context.setVertexBufferAt(0, vertexBuffer, 0, Context3DVertexBufferFormat.FLOAT_3);
context.setVertexBufferAt(1, vertexBuffer, 3, Context3DVertexBufferFormat.FLOAT_4);
context.setVertexBufferAt(2, vertexBuffer, 7, Context3DVertexBufferFormat.FLOAT_2);
if(!program)
{
if(_materialTexture)
{
_fragmentShader.updateTextureAgal(_materialTexture);
}
program = Program3DCache.getProgram3D(context, _vertexShader, _fragmentShader);
}
context.setProgram(program);
/**
*
* FOR TEXTURE FILLS
*/
if(_materialTexture)
{
RenderUtil.setSamplerStateAt(0, false, TextureSmoothing.TRILINEAR, true);
context.setTextureAt(0, _materialTexture.base);
}
context.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX, 0, matrix, true);
_vertexShader.setConstants(context, 4);
// Multiply display obect's alpha by material alpha.
finalAlpha = _alpha * alpha;
_colorVector[0] = ((_color >> 16) / 255) * finalAlpha;
_colorVector[1] = (((_color & 0x00FF00) >> 8) / 255) * finalAlpha;
_colorVector[2] = ((_color & 0x0000FF) / 255) * finalAlpha;
_colorVector[3] = finalAlpha;
context.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, _colorVector);
_fragmentShader.setConstants(context, 1);
context.drawTriangles(indexBuffer, 0, numTriangles);
}
This error occurs when this line is executed from render function above:
context.drawTriangles(indexBuffer, 0, numTriangles);