Commit 481373d8 by Olli Etuaho

Fix GetShaderPrecisionFormat to return correct values on DX11

The integer precision is different on DirectX 9 and 11 backends. DirectX 11 guarantees native 32-bit integers. BUG=angle:919 Change-Id: I7619e66f8aaa1177c32b6da185fe805ce8a19b71 Reviewed-on: https://chromium-review.googlesource.com/250280Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent 3e142e47
...@@ -377,6 +377,41 @@ void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps) ...@@ -377,6 +377,41 @@ void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps)
colorBufferFloat = DetermineColorBufferFloatSupport(textureCaps); colorBufferFloat = DetermineColorBufferFloatSupport(textureCaps);
} }
TypePrecision::TypePrecision()
{
range[0] = 0;
range[1] = 0;
precision = 0;
}
void TypePrecision::setIEEEFloat()
{
range[0] = 127;
range[1] = 127;
precision = 23;
}
void TypePrecision::setTwosComplementInt(unsigned int bits)
{
range[0] = GLint(bits) - 1;
range[1] = GLint(bits) - 2;
precision = 0;
}
void TypePrecision::setSimulatedInt(unsigned int r)
{
range[0] = GLint(r);
range[1] = GLint(r);
precision = 0;
}
void TypePrecision::get(GLint *returnRange, GLint *returnPrecision) const
{
returnRange[0] = range[0];
returnRange[1] = range[1];
*returnPrecision = precision;
}
Caps::Caps() Caps::Caps()
: maxElementIndex(0), : maxElementIndex(0),
max3DTextureSize(0), max3DTextureSize(0),
......
...@@ -215,6 +215,20 @@ struct Extensions ...@@ -215,6 +215,20 @@ struct Extensions
bool colorBufferFloat; bool colorBufferFloat;
}; };
struct TypePrecision
{
TypePrecision();
void setIEEEFloat();
void setTwosComplementInt(unsigned int bits);
void setSimulatedInt(unsigned int range);
void get(GLint *returnRange, GLint *returnPrecision) const;
GLint range[2];
GLint precision;
};
struct Caps struct Caps
{ {
Caps(); Caps();
...@@ -242,6 +256,18 @@ struct Caps ...@@ -242,6 +256,18 @@ struct Caps
std::vector<GLenum> compressedTextureFormats; std::vector<GLenum> compressedTextureFormats;
std::vector<GLenum> programBinaryFormats; std::vector<GLenum> programBinaryFormats;
std::vector<GLenum> shaderBinaryFormats; std::vector<GLenum> shaderBinaryFormats;
TypePrecision vertexHighpFloat;
TypePrecision vertexMediumpFloat;
TypePrecision vertexLowpFloat;
TypePrecision vertexHighpInt;
TypePrecision vertexMediumpInt;
TypePrecision vertexLowpInt;
TypePrecision fragmentHighpFloat;
TypePrecision fragmentMediumpFloat;
TypePrecision fragmentLowpFloat;
TypePrecision fragmentHighpInt;
TypePrecision fragmentMediumpInt;
TypePrecision fragmentLowpInt;
GLuint64 maxServerWaitTimeout; GLuint64 maxServerWaitTimeout;
// Table 6.31, implementation dependent vertex shader limits // Table 6.31, implementation dependent vertex shader limits
......
...@@ -990,6 +990,21 @@ void GenerateCaps(ID3D11Device *device, gl::Caps *caps, gl::TextureCapsMap *text ...@@ -990,6 +990,21 @@ void GenerateCaps(ID3D11Device *device, gl::Caps *caps, gl::TextureCapsMap *text
// Program and shader binary formats (no supported shader binary formats) // Program and shader binary formats (no supported shader binary formats)
caps->programBinaryFormats.push_back(GL_PROGRAM_BINARY_ANGLE); caps->programBinaryFormats.push_back(GL_PROGRAM_BINARY_ANGLE);
caps->vertexHighpFloat.setIEEEFloat();
caps->vertexMediumpFloat.setIEEEFloat();
caps->vertexLowpFloat.setIEEEFloat();
caps->fragmentHighpFloat.setIEEEFloat();
caps->fragmentMediumpFloat.setIEEEFloat();
caps->fragmentLowpFloat.setIEEEFloat();
// 32-bit integers are natively supported
caps->vertexHighpInt.setTwosComplementInt(32);
caps->vertexMediumpInt.setTwosComplementInt(32);
caps->vertexLowpInt.setTwosComplementInt(32);
caps->fragmentHighpInt.setTwosComplementInt(32);
caps->fragmentMediumpInt.setTwosComplementInt(32);
caps->fragmentLowpInt.setTwosComplementInt(32);
// We do not wait for server fence objects internally, so report a max timeout of zero. // We do not wait for server fence objects internally, so report a max timeout of zero.
caps->maxServerWaitTimeout = 0; caps->maxServerWaitTimeout = 0;
......
...@@ -391,6 +391,22 @@ void GenerateCaps(IDirect3D9 *d3d9, IDirect3DDevice9 *device, D3DDEVTYPE deviceT ...@@ -391,6 +391,22 @@ void GenerateCaps(IDirect3D9 *d3d9, IDirect3DDevice9 *device, D3DDEVTYPE deviceT
// Program and shader binary formats (no supported shader binary formats) // Program and shader binary formats (no supported shader binary formats)
caps->programBinaryFormats.push_back(GL_PROGRAM_BINARY_ANGLE); caps->programBinaryFormats.push_back(GL_PROGRAM_BINARY_ANGLE);
caps->vertexHighpFloat.setIEEEFloat();
caps->vertexMediumpFloat.setIEEEFloat();
caps->vertexLowpFloat.setIEEEFloat();
caps->fragmentHighpFloat.setIEEEFloat();
caps->fragmentMediumpFloat.setIEEEFloat();
caps->fragmentLowpFloat.setIEEEFloat();
// Some (most) hardware only supports single-precision floating-point numbers,
// which can accurately represent integers up to +/-16777216
caps->vertexHighpInt.setSimulatedInt(24);
caps->vertexMediumpInt.setSimulatedInt(24);
caps->vertexLowpInt.setSimulatedInt(24);
caps->fragmentHighpInt.setSimulatedInt(24);
caps->fragmentMediumpInt.setSimulatedInt(24);
caps->fragmentLowpInt.setSimulatedInt(24);
// WaitSync is ES3-only, set to zero // WaitSync is ES3-only, set to zero
caps->maxServerWaitTimeout = 0; caps->maxServerWaitTimeout = 0;
......
...@@ -2366,39 +2366,66 @@ void GL_APIENTRY GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontyp ...@@ -2366,39 +2366,66 @@ void GL_APIENTRY GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontyp
switch (shadertype) switch (shadertype)
{ {
case GL_VERTEX_SHADER: case GL_VERTEX_SHADER:
case GL_FRAGMENT_SHADER: switch (precisiontype)
break; {
case GL_LOW_FLOAT:
context->getCaps().vertexLowpFloat.get(range, precision);
break;
case GL_MEDIUM_FLOAT:
context->getCaps().vertexMediumpFloat.get(range, precision);
break;
case GL_HIGH_FLOAT:
context->getCaps().vertexHighpFloat.get(range, precision);
break;
default: case GL_LOW_INT:
context->recordError(Error(GL_INVALID_ENUM)); context->getCaps().vertexLowpInt.get(range, precision);
return; break;
} case GL_MEDIUM_INT:
context->getCaps().vertexMediumpInt.get(range, precision);
break;
case GL_HIGH_INT:
context->getCaps().vertexHighpInt.get(range, precision);
break;
switch (precisiontype) default:
{ context->recordError(Error(GL_INVALID_ENUM));
case GL_LOW_FLOAT: return;
case GL_MEDIUM_FLOAT: }
case GL_HIGH_FLOAT:
// Assume IEEE 754 precision
range[0] = 127;
range[1] = 127;
*precision = 23;
break; break;
case GL_FRAGMENT_SHADER:
switch (precisiontype)
{
case GL_LOW_FLOAT:
context->getCaps().fragmentLowpFloat.get(range, precision);
break;
case GL_MEDIUM_FLOAT:
context->getCaps().fragmentMediumpFloat.get(range, precision);
break;
case GL_HIGH_FLOAT:
context->getCaps().fragmentHighpFloat.get(range, precision);
break;
case GL_LOW_INT: case GL_LOW_INT:
case GL_MEDIUM_INT: context->getCaps().fragmentLowpInt.get(range, precision);
case GL_HIGH_INT: break;
// Some (most) hardware only supports single-precision floating-point numbers, case GL_MEDIUM_INT:
// which can accurately represent integers up to +/-16777216 context->getCaps().fragmentMediumpInt.get(range, precision);
range[0] = 24; break;
range[1] = 24; case GL_HIGH_INT:
*precision = 0; context->getCaps().fragmentHighpInt.get(range, precision);
break; break;
default:
context->recordError(Error(GL_INVALID_ENUM));
return;
}
break;
default: default:
context->recordError(Error(GL_INVALID_ENUM)); context->recordError(Error(GL_INVALID_ENUM));
return; return;
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment