Commit a3b2e71f by Enrico Galli Committed by Commit Bot

ES31: Support for GL_BUFFER_DATA_SIZE on GL_ATOMIC_COUNTER_BUFFER in D3D

This commit adds support for querying the GL_BUFFER_DATA_SIZE of GL_ATOMIC_COUNTER_BUFFER in the D3D renderer. Bug: angleproject:1729 Test: angle_end2end_tests Change-Id: Id6aae0d92c5e0960b2b245ba7d83970b04ba4eed Reviewed-on: https://chromium-review.googlesource.com/c/1399143 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent b814bbb7
......@@ -75,6 +75,7 @@ Intel Corporation
Yunchao He
Xinghua Cao
Brandon Jones
Enrico Galli
Klarälvdalens Datakonsult AB
Milian Wolff
......
......@@ -2888,6 +2888,31 @@ void ProgramD3D::linkResources(const gl::ProgramLinkedResources &resources)
resources.shaderStorageBlockLinker.linkBlocks(getShaderStorageBlockSize,
getShaderStorageBlockMemberInfo);
initializeShaderStorageBlocks();
std::map<int, unsigned int> sizeMap;
getAtomicCounterBufferSizeMap(sizeMap);
resources.atomicCounterBufferLinker.link(sizeMap);
}
void ProgramD3D::getAtomicCounterBufferSizeMap(std::map<int, unsigned int> &sizeMapOut) const
{
for (unsigned int index : mState.getAtomicCounterUniformRange())
{
const gl::LinkedUniform &glUniform = mState.getUniforms()[index];
auto &bufferDataSize = sizeMapOut[glUniform.binding];
// Calculate the size of the buffer by finding the end of the last uniform with the same
// binding. The end of the uniform is calculated by finding the initial offset of the
// uniform and adding size of the uniform. For arrays, the size is the number of elements
// times the element size (should always by 4 for atomic_units).
unsigned dataOffset =
glUniform.offset + (glUniform.getBasicTypeElementCount() * glUniform.getElementSize());
if (dataOffset > bufferDataSize)
{
bufferDataSize = dataOffset;
}
}
}
} // namespace rx
......@@ -410,6 +410,8 @@ class ProgramD3D : public ProgramImpl
std::vector<Image> &outImages,
gl::RangeUI *outUsedRange);
void getAtomicCounterBufferSizeMap(std::map<int, unsigned int> &sizeMapOut) const;
template <typename DestT>
void getUniformInternal(GLint location, DestT *dataOut) const;
......
......@@ -924,6 +924,68 @@ TEST_P(ProgramInterfaceTestES31, GetShaderStorageBlockProperties)
EXPECT_EQ("blockName1[0]", std::string(name));
}
// Tests querying the program resources of atomic counter buffers.
TEST_P(ProgramInterfaceTestES31, GetAtomicCounterProperties)
{
constexpr char kCSSource[] = R"(#version 310 es
layout(local_size_x=1, local_size_y=1, local_size_z=1) in;
layout(binding = 0) uniform atomic_uint acbase;
layout(binding = 0, offset = 8) uniform atomic_uint ac[1];
layout(binding = 0) uniform atomic_uint ac2;
void main()
{
atomicCounter(acbase);
atomicCounter(ac[0]);
atomicCounter(ac2);
})";
ANGLE_GL_COMPUTE_PROGRAM(program, kCSSource);
GLuint index = glGetProgramResourceIndex(program, GL_UNIFORM, "ac");
EXPECT_GL_NO_ERROR();
EXPECT_NE(GL_INVALID_INDEX, index);
GLenum props[] = {GL_ATOMIC_COUNTER_BUFFER_INDEX};
GLsizei propCount = static_cast<GLsizei>(ArraySize(props));
GLint atomicIndex;
GLsizei length;
glGetProgramResourceiv(program, GL_UNIFORM, index, propCount, props, 1, &length, &atomicIndex);
EXPECT_GL_NO_ERROR();
EXPECT_EQ(1, length);
EXPECT_LE(0, atomicIndex);
GLenum atomicProps[] = {GL_ACTIVE_VARIABLES,
GL_BUFFER_BINDING,
GL_NUM_ACTIVE_VARIABLES,
GL_BUFFER_DATA_SIZE,
GL_REFERENCED_BY_VERTEX_SHADER,
GL_REFERENCED_BY_FRAGMENT_SHADER,
GL_REFERENCED_BY_COMPUTE_SHADER};
GLsizei atomicPropsCount = static_cast<GLsizei>(ArraySize(atomicProps));
constexpr int kBufSize = 256;
GLint params[kBufSize];
GLsizei length2;
glGetProgramResourceiv(program, GL_ATOMIC_COUNTER_BUFFER, atomicIndex, atomicPropsCount,
atomicProps, kBufSize, &length2, params);
EXPECT_GL_NO_ERROR();
EXPECT_EQ(9, length2);
EXPECT_LE(0, params[0]); // active_variables acbase
EXPECT_LE(0, params[1]); // active_variables ac[1]
EXPECT_LE(0, params[2]); // active_variables ac2
EXPECT_EQ(0, params[3]); // buffer_binding
EXPECT_EQ(3, params[4]); // num_active_variables
EXPECT_EQ(16, params[5]); // buffer_data_size
EXPECT_EQ(0, params[6]); // referenced_by_vertex_shader
EXPECT_EQ(0, params[7]); // referenced_by_fragment_shader
EXPECT_EQ(1, params[8]); // referenced_by_compute_shader
}
// Tests transform feedback varying qeury works correctly.
TEST_P(ProgramInterfaceTestES31, QueryTransformFeedbackVarying)
{
......
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