Commit b3693762 by Mohan Maiya Committed by Commit Bot

Vulkan: Enhance VulkanBarriersPerfBenchmark

1. Request a GLES3.0 context 2. Create 2 uniform buffers to be used in the new test case 3. Increase the size of the viewport 4. Add a new test case where we issue draw and buffer copy commands. The expectation is that the draw to FBO and the copy between the 2 buffers happen in parallel. Bug: angleproject:4633 Test: angle_perftest --gtest_filter=VulkanBarriersPerfBenchmark.Run/vulkan_buffer_copy Change-Id: I3c5d287c05451f77053962371a96e2de6a8ea00d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2215139 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent 2f2595a8
......@@ -21,18 +21,19 @@ constexpr unsigned int kIterationsPerStep = 10;
struct VulkanBarriersPerfParams final : public RenderTestParams
{
VulkanBarriersPerfParams(bool largeTransfers, bool slowFS)
VulkanBarriersPerfParams(bool bufferCopy, bool largeTransfers, bool slowFS)
{
iterationsPerStep = kIterationsPerStep;
// Common default parameters
eglParameters = egl_platform::VULKAN();
majorVersion = 2;
majorVersion = 3;
minorVersion = 0;
windowWidth = 256;
windowHeight = 256;
trackGpuTime = true;
doBufferCopy = bufferCopy;
doLargeTransfers = largeTransfers;
doSlowFragmentShaders = slowFS;
}
......@@ -41,7 +42,9 @@ struct VulkanBarriersPerfParams final : public RenderTestParams
// Static parameters
static constexpr int kImageSizes[3] = {256, 512, 4096};
static constexpr int kBufferSize = 4096 * 4096;
bool doBufferCopy;
bool doLargeTransfers;
bool doSlowFragmentShaders;
};
......@@ -66,6 +69,7 @@ class VulkanBarriersPerfBenchmark : public ANGLERenderTest,
private:
void createTexture(uint32_t textureIndex, uint32_t sizeIndex, bool compressed);
void createUniformBuffer();
void createFramebuffer(uint32_t fboIndex, uint32_t textureIndex, uint32_t sizeIndex);
void createResources();
......@@ -82,6 +86,9 @@ class VulkanBarriersPerfBenchmark : public ANGLERenderTest,
// Texture handles
GLTexture mTextures[4];
// Uniform buffer handles
GLBuffer mUniformBuffers[2];
// Framebuffer handles
GLFramebuffer mFbos[2];
......@@ -92,6 +99,9 @@ class VulkanBarriersPerfBenchmark : public ANGLERenderTest,
static constexpr size_t kSmallFboIndex = 0;
static constexpr size_t kLargeFboIndex = 1;
static constexpr size_t kUniformBuffer1Index = 0;
static constexpr size_t kUniformBuffer2Index = 1;
static constexpr size_t kSmallTextureIndex = 0;
static constexpr size_t kLargeTextureIndex = 1;
static constexpr size_t kTransferTexture1Index = 2;
......@@ -108,6 +118,10 @@ std::string VulkanBarriersPerfParams::story() const
sout << RenderTestParams::story();
if (doBufferCopy)
{
sout << "_buffer_copy";
}
if (doLargeTransfers)
{
sout << "_transfer";
......@@ -178,6 +192,17 @@ void VulkanBarriersPerfBenchmark::createTexture(uint32_t textureIndex,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
void VulkanBarriersPerfBenchmark::createUniformBuffer()
{
const auto &params = GetParam();
glBindBuffer(GL_UNIFORM_BUFFER, mUniformBuffers[kUniformBuffer1Index]);
glBufferData(GL_UNIFORM_BUFFER, params.kBufferSize, nullptr, GL_DYNAMIC_COPY);
glBindBuffer(GL_UNIFORM_BUFFER, mUniformBuffers[kUniformBuffer2Index]);
glBufferData(GL_UNIFORM_BUFFER, params.kBufferSize, nullptr, GL_DYNAMIC_COPY);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
void VulkanBarriersPerfBenchmark::createFramebuffer(uint32_t fboIndex,
uint32_t textureIndex,
uint32_t sizeIndex)
......@@ -229,6 +254,7 @@ void VulkanBarriersPerfBenchmark::createResources()
// transfers.
createFramebuffer(kSmallFboIndex, kSmallTextureIndex, kSmallSizeIndex);
createFramebuffer(kLargeFboIndex, kLargeTextureIndex, kLargeSizeIndex);
createUniformBuffer();
if (params.doLargeTransfers)
{
......@@ -276,7 +302,10 @@ void VulkanBarriersPerfBenchmark::drawBenchmark()
* - Alternately clear and draw from fbo 1 into fbo 2 and back. This would use the color
* attachment and shader read-only layouts in the fragment shader and color attachment stages.
*
* Once compressed texture copies are supported, alternately transfer large chunks of data from
* - Alternately copy data between the 2 uniform buffers. This would use the transfer layouts
* in the transfer stage.
*
* Once compressed texture copies are supported, alternately copy large chunks of data from
* texture 1 into texture 2 and back. This would use the transfer layouts in the transfer
* stage.
*
......@@ -290,30 +319,31 @@ void VulkanBarriersPerfBenchmark::drawBenchmark()
* The above operations for example should ideally run on the GPU threads in parallel:
*
* + |---draw---||---draw---||---draw---||---draw---||---draw---|
* + |-----------transfer------------||-----------transfer------------|
* + |----buffer copy----||----buffer copy----||----buffer copy----|
* + |-----------texture copy------------||-----------texture copy------------|
* + |-----dispatch------||------dispatch------||------dispatch------|
*
* If barriers are too restrictive, situations like this could happen (draw is blocking
* transfer):
* copy):
*
* + |---draw---||---draw---||---draw---||---draw---||---draw---|
* + |-----------transfer------------||-----------transfer------------|
* + |------------copy------------||-----------copy------------|
*
* Or like this (transfer is blocking draw):
* Or like this (copy is blocking draw):
*
* + |---draw---| |---draw---| |---draw---|
* + |-----------transfer------------||-----------transfer------------|
* + |--------------copy-------------||-------------copy--------------|
*
* Or like this (draw and transfer blocking each other):
* Or like this (draw and copy blocking each other):
*
* + |---draw---| |---draw---|
* + |-----------transfer------------| |-----------transfer------------|
* + |------------copy---------------| |------------copy------------|
*
* The idea of doing slow FS calls is to make the second case above slower (by making the draw
* slower than the transfer):
*
* + |------------------draw------------------| |-...draw...-|
* + |-----------transfer------------| |-----------transfer------------|
* + |--------------copy----------------| |-------------copy-------------|
*/
startGpuTimer();
......@@ -321,19 +351,31 @@ void VulkanBarriersPerfBenchmark::drawBenchmark()
{
bool altEven = iteration % 2 == 0;
const int fboDestIndex = altEven ? kLargeFboIndex : kSmallFboIndex;
const int fboTexSrcIndex = altEven ? kSmallTextureIndex : kLargeTextureIndex;
const int fboDestSizeIndex = altEven ? kLargeSizeIndex : kSmallSizeIndex;
const int fboDestIndex = altEven ? kLargeFboIndex : kSmallFboIndex;
const int fboTexSrcIndex = altEven ? kSmallTextureIndex : kLargeTextureIndex;
const int fboDestSizeIndex = altEven ? kLargeSizeIndex : kSmallSizeIndex;
const int uniformBufferReadIndex = altEven ? kUniformBuffer1Index : kUniformBuffer2Index;
const int uniformBufferWriteIndex = altEven ? kUniformBuffer2Index : kUniformBuffer1Index;
if (params.doBufferCopy)
{
// Transfer data between the 2 Uniform buffers
glBindBuffer(GL_COPY_READ_BUFFER, mUniformBuffers[uniformBufferReadIndex]);
glBindBuffer(GL_COPY_WRITE_BUFFER, mUniformBuffers[uniformBufferWriteIndex]);
glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0,
params.kBufferSize);
}
// Bind the framebuffer
glBindFramebuffer(GL_FRAMEBUFFER, mFbos[fboDestIndex]);
// Set the viewport
glViewport(0, 0, fboDestSizeIndex, fboDestSizeIndex);
glViewport(0, 0, params.kImageSizes[fboDestSizeIndex],
params.kImageSizes[fboDestSizeIndex]);
// Clear the color buffer
glClear(GL_COLOR_BUFFER_BIT);
// Bind the framebuffer
glBindFramebuffer(GL_FRAMEBUFFER, mFbos[fboDestIndex]);
// Bind the texture
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, mTextures[fboTexSrcIndex]);
......@@ -355,6 +397,7 @@ TEST_P(VulkanBarriersPerfBenchmark, Run)
}
ANGLE_INSTANTIATE_TEST(VulkanBarriersPerfBenchmark,
VulkanBarriersPerfParams(false, false),
VulkanBarriersPerfParams(true, false),
VulkanBarriersPerfParams(true, true));
VulkanBarriersPerfParams(false, false, false),
VulkanBarriersPerfParams(true, false, false),
VulkanBarriersPerfParams(false, true, false),
VulkanBarriersPerfParams(false, true, true));
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