Commit a787b618 by Jonah Ryan-Davis Committed by Commit Bot

D3D11: Buffers larger than MAX_UNIFORM_BLOCK_SIZE

We had clamped all UBOs to MAX_UNIFORM_BLOCK_SIZE, when D3D11 allows the underlying buffer to be larger as long as each UBO binding is still within the max. Bug: 906683 Bug: angleproject:3388 Change-Id: Id5536302dd73a41c0882fddd77e94f4503f00730 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1837356Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
parent 2682b5a0
...@@ -684,8 +684,9 @@ angle::Result Buffer11::getConstantBufferRange(const gl::Context *context, ...@@ -684,8 +684,9 @@ angle::Result Buffer11::getConstantBufferRange(const gl::Context *context,
UINT *numConstantsOut) UINT *numConstantsOut)
{ {
NativeStorage *bufferStorage = nullptr; NativeStorage *bufferStorage = nullptr;
if ((offset == 0 &&
if (offset == 0 || mRenderer->getRenderer11DeviceCaps().supportsConstantBufferOffsets) size < static_cast<GLsizeiptr>(mRenderer->getNativeCaps().maxUniformBlockSize)) ||
mRenderer->getRenderer11DeviceCaps().supportsConstantBufferOffsets)
{ {
ANGLE_TRY(getBufferStorage(context, BUFFER_USAGE_UNIFORM, &bufferStorage)); ANGLE_TRY(getBufferStorage(context, BUFFER_USAGE_UNIFORM, &bufferStorage));
CalculateConstantBufferParams(offset, size, firstConstantOut, numConstantsOut); CalculateConstantBufferParams(offset, size, firstConstantOut, numConstantsOut);
...@@ -1217,9 +1218,12 @@ void Buffer11::NativeStorage::FillBufferDesc(D3D11_BUFFER_DESC *bufferDesc, ...@@ -1217,9 +1218,12 @@ void Buffer11::NativeStorage::FillBufferDesc(D3D11_BUFFER_DESC *bufferDesc,
// Note: it seems that D3D11 allows larger buffers on some platforms, but not all. // Note: it seems that D3D11 allows larger buffers on some platforms, but not all.
// (Windows 10 seems to allow larger constant buffers, but not Windows 7) // (Windows 10 seems to allow larger constant buffers, but not Windows 7)
bufferDesc->ByteWidth = if (!renderer->getRenderer11DeviceCaps().supportsConstantBufferOffsets)
std::min<UINT>(bufferDesc->ByteWidth, {
static_cast<UINT>(renderer->getNativeCaps().maxUniformBlockSize)); bufferDesc->ByteWidth = std::min<UINT>(
bufferDesc->ByteWidth,
static_cast<UINT>(renderer->getNativeCaps().maxUniformBlockSize));
}
break; break;
case BUFFER_USAGE_RAW_UAV: case BUFFER_USAGE_RAW_UAV:
......
...@@ -1515,11 +1515,10 @@ TEST_P(UniformBufferTest, DependentBufferChange) ...@@ -1515,11 +1515,10 @@ TEST_P(UniformBufferTest, DependentBufferChange)
// Recreate WebGL conformance test conformance2/uniforms/large-uniform-buffers.html to test // Recreate WebGL conformance test conformance2/uniforms/large-uniform-buffers.html to test
// regression in http://anglebug.com/3388 // regression in http://anglebug.com/3388
TEST_P(UniformBufferTest, SizeOver65535) TEST_P(UniformBufferTest, SizeOverMaxBlockSize)
{ {
// UBOs sized above 65535 do not appear to work on D3D11 // Test crashes on Windows AMD OpenGL
// http://anglebug.com/3388 ANGLE_SKIP_TEST_IF(IsAMD() && IsWindows() && IsOpenGL());
ANGLE_SKIP_TEST_IF(IsD3D11());
ANGLE_GL_PROGRAM(program, essl3_shaders::vs::Simple(), kFragmentShader); ANGLE_GL_PROGRAM(program, essl3_shaders::vs::Simple(), kFragmentShader);
...@@ -1546,10 +1545,14 @@ TEST_P(UniformBufferTest, SizeOver65535) ...@@ -1546,10 +1545,14 @@ TEST_P(UniformBufferTest, SizeOver65535)
glGetActiveUniformBlockiv(program, uboIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &uboDataSize); glGetActiveUniformBlockiv(program, uboIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &uboDataSize);
EXPECT_NE(uboDataSize, 0); // uniform block data size invalid EXPECT_NE(uboDataSize, 0); // uniform block data size invalid
GLint64 maxUniformBlockSize;
glGetInteger64v(GL_MAX_UNIFORM_BLOCK_SIZE, &maxUniformBlockSize);
GLBuffer uboBuf; GLBuffer uboBuf;
std::array<GLfloat, 0x20000> uboData; std::vector<GLfloat> uboData;
uboData.resize(maxUniformBlockSize * 2); // underlying data is twice the max block size
GLint offs0 = 0x00000; GLint offs0 = 0;
// Red // Red
uboData[offs0 + 0] = 1; uboData[offs0 + 0] = 1;
...@@ -1557,7 +1560,7 @@ TEST_P(UniformBufferTest, SizeOver65535) ...@@ -1557,7 +1560,7 @@ TEST_P(UniformBufferTest, SizeOver65535)
uboData[offs0 + 2] = 0; uboData[offs0 + 2] = 0;
uboData[offs0 + 3] = 1; uboData[offs0 + 3] = 1;
GLint offs1 = 0x10000; GLint offs1 = maxUniformBlockSize;
GLint alignment = 0; GLint alignment = 0;
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &alignment); glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &alignment);
EXPECT_EQ(offs1 % alignment, 0); EXPECT_EQ(offs1 % alignment, 0);
......
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