Commit e321940c by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Move image clear functionality to UtilsVk

DispatchUtilsVk is renamed to UtilsVk and the functionality in framebuffer's clearWithDraw() is moved to that class. Eventually, more fragment-shader-based internal algorithms will be added to this class as well. Bug: angleproject:2958 Change-Id: I4753c9cb3288b59cd1ed60fe7a57b9f189704322 Reviewed-on: https://chromium-review.googlesource.com/c/1369284 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent af4cef51
...@@ -206,7 +206,7 @@ class RecordableGraphResource : public CommandGraphResource ...@@ -206,7 +206,7 @@ class RecordableGraphResource : public CommandGraphResource
angle::Result recordCommands(Context *context, CommandBuffer **commandBufferOut); angle::Result recordCommands(Context *context, CommandBuffer **commandBufferOut);
// Begins a command buffer on the current graph node for in-RenderPass rendering. // Begins a command buffer on the current graph node for in-RenderPass rendering.
// Currently only called from FramebufferVk::getCommandBufferForDraw. // Currently only called from FramebufferVk::startNewRenderPass.
angle::Result beginRenderPass(Context *context, angle::Result beginRenderPass(Context *context,
const Framebuffer &framebuffer, const Framebuffer &framebuffer,
const gl::Rectangle &renderArea, const gl::Rectangle &renderArea,
......
...@@ -287,8 +287,8 @@ angle::Result FramebufferVk::clear(const gl::Context *context, GLbitfield mask) ...@@ -287,8 +287,8 @@ angle::Result FramebufferVk::clear(const gl::Context *context, GLbitfield mask)
VkClearColorValue modifiedClearColorValue = clearColorValue; VkClearColorValue modifiedClearColorValue = clearColorValue;
RenderTargetVk *colorRenderTarget = colorRenderTargets[colorIndex]; RenderTargetVk *colorRenderTarget = colorRenderTargets[colorIndex];
// Its possible we're clearing a render target that has no alpha channel but we represent it // It's possible we're clearing a render target that has no alpha channel but we represent
// with a texture that has one. We must not affect its alpha channel no matter what the // it with a texture that has one. We must not affect its alpha channel no matter what the
// clear value is in that case. // clear value is in that case.
if (mEmulatedAlphaAttachmentMask[colorIndex]) if (mEmulatedAlphaAttachmentMask[colorIndex])
{ {
...@@ -1002,78 +1002,26 @@ angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk, ...@@ -1002,78 +1002,26 @@ angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk,
{ {
RendererVk *renderer = contextVk->getRenderer(); RendererVk *renderer = contextVk->getRenderer();
vk::ShaderProgramHelper *fullScreenClear = nullptr; // If the format of the framebuffer does not have an alpha channel, we need to make sure we do
ANGLE_TRY(renderer->getFullScreenClearShaderProgram(contextVk, &fullScreenClear));
// Trigger a new command node to ensure overlapping writes happen sequentially.
mFramebuffer.finishCurrentCommands(renderer);
// The shader uses a simple pipeline layout with a push constant range.
vk::PipelineLayoutDesc pipelineLayoutDesc;
pipelineLayoutDesc.updatePushConstantRange(gl::ShaderType::Fragment, 0,
sizeof(VkClearColorValue));
// The shader does not use any descriptor sets.
vk::DescriptorSetLayoutPointerArray descriptorSetLayouts;
vk::BindingPointer<vk::PipelineLayout> pipelineLayout;
ANGLE_TRY(renderer->getPipelineLayout(contextVk, pipelineLayoutDesc, descriptorSetLayouts,
&pipelineLayout));
vk::RecordingMode recordingMode = vk::RecordingMode::Start;
vk::CommandBuffer *drawCommands = nullptr;
ANGLE_TRY(getCommandBufferForDraw(contextVk, &drawCommands, &recordingMode));
const gl::Rectangle &renderArea = mFramebuffer.getRenderPassRenderArea();
bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO();
// This pipeline desc could be cached.
vk::GraphicsPipelineDesc pipelineDesc;
pipelineDesc.initDefaults();
pipelineDesc.updateColorWriteMask(colorMaskFlags, getEmulatedAlphaAttachmentMask());
pipelineDesc.updateRenderPassDesc(getRenderPassDesc());
vk::PipelineAndSerial *pipeline = nullptr;
ANGLE_TRY(fullScreenClear->getGraphicsPipeline(contextVk, pipelineLayout.get(), pipelineDesc,
gl::AttributesMask(), &pipeline));
pipeline->updateSerial(renderer->getCurrentQueueSerial());
vk::CommandBuffer *writeCommands = nullptr;
ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &writeCommands));
// If the format of the framebuffer does not have an alpha channel, we need to make sure we does
// not affect the alpha channel of the type we're using to emulate the format. // not affect the alpha channel of the type we're using to emulate the format.
// TODO(jmadill): Implement EXT_draw_buffers http://anglebug.com/2394 // TODO(jmadill): Implement EXT_draw_buffers http://anglebug.com/2394
RenderTargetVk *renderTarget = mRenderTargetCache.getColors()[0]; RenderTargetVk *renderTarget = mRenderTargetCache.getColors()[0];
ASSERT(renderTarget); ASSERT(renderTarget);
const vk::Format &imageFormat = renderTarget->getImageFormat(); UtilsVk::ClearImageParameters params = {};
VkClearColorValue clearColorValue = contextVk->getClearColorValue().color; params.colorMaskFlags = colorMaskFlags;
params.alphaMask = &getEmulatedAlphaAttachmentMask();
params.renderPassDesc = &getRenderPassDesc();
const vk::Format &imageFormat = renderTarget->getImageFormat();
params.clearValue = contextVk->getClearColorValue().color;
bool overrideAlphaWithOne = bool overrideAlphaWithOne =
imageFormat.textureFormat().alphaBits > 0 && imageFormat.angleFormat().alphaBits == 0; imageFormat.textureFormat().alphaBits > 0 && imageFormat.angleFormat().alphaBits == 0;
clearColorValue.float32[3] = overrideAlphaWithOne ? 1.0f : clearColorValue.float32[3]; params.clearValue.float32[3] = overrideAlphaWithOne ? 1.0f : params.clearValue.float32[3];
drawCommands->pushConstants(pipelineLayout.get(), VK_SHADER_STAGE_FRAGMENT_BIT, 0,
sizeof(VkClearColorValue), clearColorValue.float32);
// TODO(jmadill): Masked combined color and depth/stencil clear. http://anglebug.com/2455 params.renderAreaHeight = mState.getDimensions().height;
// Any active queries submitted by the user should also be paused here.
drawCommands->bindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline->get());
GLint renderAreaHeight = mState.getDimensions().height; return renderer->getUtils().clearImage(contextVk, this, params);
VkViewport viewport;
gl_vk::GetViewport(renderArea, 0.0f, 1.0f, invertViewport, renderAreaHeight, &viewport);
drawCommands->setViewport(0, 1, &viewport);
VkRect2D scissor;
const gl::State &glState = contextVk->getGLState();
gl_vk::GetScissor(glState, invertViewport, renderArea, &scissor);
drawCommands->setScissor(0, 1, &scissor);
drawCommands->draw(6, 1, 0, 0);
return angle::Result::Continue;
} }
angle::Result FramebufferVk::getSamplePosition(const gl::Context *context, angle::Result FramebufferVk::getSamplePosition(const gl::Context *context,
...@@ -1149,7 +1097,7 @@ void FramebufferVk::updateActiveColorMasks(size_t colorIndex, bool r, bool g, bo ...@@ -1149,7 +1097,7 @@ void FramebufferVk::updateActiveColorMasks(size_t colorIndex, bool r, bool g, bo
mActiveColorComponentMasksForClear[3].set(colorIndex, a); mActiveColorComponentMasksForClear[3].set(colorIndex, a);
} }
gl::DrawBufferMask FramebufferVk::getEmulatedAlphaAttachmentMask() const gl::DrawBufferMask &FramebufferVk::getEmulatedAlphaAttachmentMask() const
{ {
return mEmulatedAlphaAttachmentMask; return mEmulatedAlphaAttachmentMask;
} }
......
...@@ -103,7 +103,7 @@ class FramebufferVk : public FramebufferImpl ...@@ -103,7 +103,7 @@ class FramebufferVk : public FramebufferImpl
const gl::Extents &getReadImageExtents() const; const gl::Extents &getReadImageExtents() const;
gl::DrawBufferMask getEmulatedAlphaAttachmentMask(); const gl::DrawBufferMask &getEmulatedAlphaAttachmentMask() const;
RenderTargetVk *getColorReadRenderTarget() const; RenderTargetVk *getColorReadRenderTarget() const;
// This will clear the current write operation if it is complete. // This will clear the current write operation if it is complete.
......
...@@ -344,13 +344,11 @@ void RendererVk::onDestroy(vk::Context *context) ...@@ -344,13 +344,11 @@ void RendererVk::onDestroy(vk::Context *context)
(void)finish(context); (void)finish(context);
} }
mDispatchUtils.destroy(mDevice); mUtils.destroy(mDevice);
mPipelineLayoutCache.destroy(mDevice); mPipelineLayoutCache.destroy(mDevice);
mDescriptorSetLayoutCache.destroy(mDevice); mDescriptorSetLayoutCache.destroy(mDevice);
mFullScreenClearShaderProgram.destroy(mDevice);
mRenderPassCache.destroy(mDevice); mRenderPassCache.destroy(mDevice);
mPipelineCache.destroy(mDevice); mPipelineCache.destroy(mDevice);
mSubmitSemaphorePool.destroy(mDevice); mSubmitSemaphorePool.destroy(mDevice);
...@@ -1319,25 +1317,6 @@ const vk::Semaphore *RendererVk::getSubmitLastSignaledSemaphore(vk::Context *con ...@@ -1319,25 +1317,6 @@ const vk::Semaphore *RendererVk::getSubmitLastSignaledSemaphore(vk::Context *con
return semaphore; return semaphore;
} }
angle::Result RendererVk::getFullScreenClearShaderProgram(vk::Context *context,
vk::ShaderProgramHelper **programOut)
{
if (!mFullScreenClearShaderProgram.valid())
{
vk::RefCounted<vk::ShaderAndSerial> *fullScreenQuad = nullptr;
ANGLE_TRY(mShaderLibrary.getFullScreenQuad_vert(context, 0, &fullScreenQuad));
vk::RefCounted<vk::ShaderAndSerial> *pushConstantColor = nullptr;
ANGLE_TRY(mShaderLibrary.getPushConstantColor_frag(context, 0, &pushConstantColor));
mFullScreenClearShaderProgram.setShader(gl::ShaderType::Vertex, fullScreenQuad);
mFullScreenClearShaderProgram.setShader(gl::ShaderType::Fragment, pushConstantColor);
}
*programOut = &mFullScreenClearShaderProgram;
return angle::Result::Continue;
}
angle::Result RendererVk::getTimestamp(vk::Context *context, uint64_t *timestampOut) angle::Result RendererVk::getTimestamp(vk::Context *context, uint64_t *timestampOut)
{ {
// The intent of this function is to query the timestamp without stalling the GPU. Currently, // The intent of this function is to query the timestamp without stalling the GPU. Currently,
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
#include "libANGLE/BlobCache.h" #include "libANGLE/BlobCache.h"
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
#include "libANGLE/renderer/vulkan/CommandGraph.h" #include "libANGLE/renderer/vulkan/CommandGraph.h"
#include "libANGLE/renderer/vulkan/DispatchUtilsVk.h"
#include "libANGLE/renderer/vulkan/QueryVk.h" #include "libANGLE/renderer/vulkan/QueryVk.h"
#include "libANGLE/renderer/vulkan/UtilsVk.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h" #include "libANGLE/renderer/vulkan/vk_format_utils.h"
#include "libANGLE/renderer/vulkan/vk_helpers.h" #include "libANGLE/renderer/vulkan/vk_helpers.h"
#include "libANGLE/renderer/vulkan/vk_internal_shaders_autogen.h" #include "libANGLE/renderer/vulkan/vk_internal_shaders_autogen.h"
...@@ -162,9 +162,7 @@ class RendererVk : angle::NonCopyable ...@@ -162,9 +162,7 @@ class RendererVk : angle::NonCopyable
Serial issueShaderSerial(); Serial issueShaderSerial();
vk::ShaderLibrary &getShaderLibrary() { return mShaderLibrary; } vk::ShaderLibrary &getShaderLibrary() { return mShaderLibrary; }
angle::Result getFullScreenClearShaderProgram(vk::Context *context, UtilsVk &getUtils() { return mUtils; }
vk::ShaderProgramHelper **programOut);
DispatchUtilsVk &getDispatchUtils() { return mDispatchUtils; }
const angle::FeaturesVk &getFeatures() const const angle::FeaturesVk &getFeatures() const
{ {
ASSERT(mFeaturesInitialized); ASSERT(mFeaturesInitialized);
...@@ -320,8 +318,7 @@ class RendererVk : angle::NonCopyable ...@@ -320,8 +318,7 @@ class RendererVk : angle::NonCopyable
// Internal shader library. // Internal shader library.
vk::ShaderLibrary mShaderLibrary; vk::ShaderLibrary mShaderLibrary;
vk::ShaderProgramHelper mFullScreenClearShaderProgram; UtilsVk mUtils;
DispatchUtilsVk mDispatchUtils;
// The GpuEventQuery struct holds together a timestamp query and enough data to create a // The GpuEventQuery struct holds together a timestamp query and enough data to create a
// trace event based on that. Use traceGpuEvent to insert such queries. They will be readback // trace event based on that. Use traceGpuEvent to insert such queries. They will be readback
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// DispatchUtilsVk.h: // UtilsVk.h:
// Defines the DispatchUtilsVk class, a helper for various internal dispatch utilities such as // Defines the UtilsVk class, a helper for various internal draw/dispatch utilities such as
// buffer clear and copy, texture mip map generation, etc. // buffer clear and copy, image clear and copy, texture mip map generation, etc.
// //
// - Buffer clear: Implemented, but no current users // - Buffer clear: Implemented, but no current users
// - Buffer copy: // - Buffer copy:
...@@ -13,11 +13,13 @@ ...@@ -13,11 +13,13 @@
// - Convert vertex attribute: // - Convert vertex attribute:
// * Used by VertexArrayVk::convertVertexBuffer() to convert vertex attributes from unsupported // * Used by VertexArrayVk::convertVertexBuffer() to convert vertex attributes from unsupported
// formats to their fallbacks. // formats to their fallbacks.
// - Image clear: Used by FramebufferVk::clearWithDraw().
// - Image copy: Not yet implemented
// - Mipmap generation: Not yet implemented // - Mipmap generation: Not yet implemented
// //
#ifndef LIBANGLE_RENDERER_VULKAN_DISPATCHUTILSVK_H_ #ifndef LIBANGLE_RENDERER_VULKAN_UTILSVK_H_
#define LIBANGLE_RENDERER_VULKAN_DISPATCHUTILSVK_H_ #define LIBANGLE_RENDERER_VULKAN_UTILSVK_H_
#include "libANGLE/renderer/vulkan/vk_cache_utils.h" #include "libANGLE/renderer/vulkan/vk_cache_utils.h"
#include "libANGLE/renderer/vulkan/vk_helpers.h" #include "libANGLE/renderer/vulkan/vk_helpers.h"
...@@ -25,11 +27,11 @@ ...@@ -25,11 +27,11 @@
namespace rx namespace rx
{ {
class DispatchUtilsVk : angle::NonCopyable class UtilsVk : angle::NonCopyable
{ {
public: public:
DispatchUtilsVk(); UtilsVk();
~DispatchUtilsVk(); ~UtilsVk();
void destroy(VkDevice device); void destroy(VkDevice device);
...@@ -57,6 +59,15 @@ class DispatchUtilsVk : angle::NonCopyable ...@@ -57,6 +59,15 @@ class DispatchUtilsVk : angle::NonCopyable
size_t destOffset; size_t destOffset;
}; };
struct ClearImageParameters
{
VkClearColorValue clearValue;
VkColorComponentFlags colorMaskFlags;
GLint renderAreaHeight;
const gl::DrawBufferMask *alphaMask;
const vk::RenderPassDesc *renderPassDesc;
};
angle::Result clearBuffer(vk::Context *context, angle::Result clearBuffer(vk::Context *context,
vk::BufferHelper *dest, vk::BufferHelper *dest,
const ClearParameters &params); const ClearParameters &params);
...@@ -69,6 +80,13 @@ class DispatchUtilsVk : angle::NonCopyable ...@@ -69,6 +80,13 @@ class DispatchUtilsVk : angle::NonCopyable
vk::BufferHelper *src, vk::BufferHelper *src,
const ConvertVertexParameters &params); const ConvertVertexParameters &params);
// Note: this function takes a FramebufferVk instead of ImageHelper, as that's the only user,
// which avoids recreating a framebuffer. An overload taking ImageHelper can be added when
// necessary.
angle::Result clearImage(ContextVk *contextVk,
FramebufferVk *framebuffer,
const ClearImageParameters &params);
private: private:
struct BufferUtilsShaderParams struct BufferUtilsShaderParams
{ {
...@@ -97,39 +115,42 @@ class DispatchUtilsVk : angle::NonCopyable ...@@ -97,39 +115,42 @@ class DispatchUtilsVk : angle::NonCopyable
uint32_t Ed = 0; uint32_t Ed = 0;
}; };
struct ImageClearShaderParams
{
// Structure matching PushConstants in ImageClear.frag
VkClearColorValue clearValue = {};
};
// Functions implemented by the class: // Functions implemented by the class:
enum class Function enum class Function
{ {
BufferClear = 0, // Functions implemented in graphics
BufferCopy = 1, ImageClear = 0,
ConvertVertexBuffer = 2,
// Functions implemented in compute
ComputeStartIndex = 1, // Special value to separate draw and dispatch functions.
BufferClear = 1,
BufferCopy = 2,
ConvertVertexBuffer = 3,
InvalidEnum = 3, InvalidEnum = 4,
EnumCount = 3, EnumCount = 4,
}; };
// Common function that creates the pipeline for the specified function, binds it and prepares // Common function that creates the pipeline for the specified function, binds it and prepares
// the dispatch call. The possible values of `flags` comes from // the draw/dispatch call. If function >= ComputeStartIndex, fsCsShader is expected to be a
// vk::InternalShader::* defined in vk_internal_shaders_autogen.h // compute shader, vsShader and pipelineDesc should be nullptr, and this will set up a dispatch
angle::Result setupProgramCommon(vk::Context *context, // call. Otherwise fsCsShader is expected to be a fragment shader and this will set up a draw
Function function, // call.
vk::RefCounted<vk::ShaderAndSerial> *shader,
vk::ShaderProgramHelper *program,
const VkDescriptorSet descriptorSet,
const void *pushConstants,
size_t pushConstantsSize,
vk::CommandBuffer *commandBuffer);
using GetShader = angle::Result (vk::ShaderLibrary::*)(vk::Context *,
uint32_t,
vk::RefCounted<vk::ShaderAndSerial> **);
template <GetShader getShader, Function function, typename ShaderParams>
angle::Result setupProgram(vk::Context *context, angle::Result setupProgram(vk::Context *context,
Function function,
vk::RefCounted<vk::ShaderAndSerial> *fsCsShader,
vk::RefCounted<vk::ShaderAndSerial> *vsShader,
vk::ShaderProgramHelper *program, vk::ShaderProgramHelper *program,
uint32_t flags, const vk::GraphicsPipelineDesc *pipelineDesc,
const VkDescriptorSet &descriptorSet, const VkDescriptorSet descriptorSet,
const ShaderParams &params, const void *pushConstants,
size_t pushConstantsSize,
vk::CommandBuffer *commandBuffer); vk::CommandBuffer *commandBuffer);
// Initializes descriptor set layout, pipeline layout and descriptor pool corresponding to given // Initializes descriptor set layout, pipeline layout and descriptor pool corresponding to given
...@@ -145,9 +166,10 @@ class DispatchUtilsVk : angle::NonCopyable ...@@ -145,9 +166,10 @@ class DispatchUtilsVk : angle::NonCopyable
// Initializers corresponding to functions, calling into ensureResourcesInitialized with the // Initializers corresponding to functions, calling into ensureResourcesInitialized with the
// appropriate parameters. // appropriate parameters.
angle::Result ensureBufferClearInitialized(vk::Context *context); angle::Result ensureBufferClearResourcesInitialized(vk::Context *context);
angle::Result ensureBufferCopyInitialized(vk::Context *context); angle::Result ensureBufferCopyResourcesInitialized(vk::Context *context);
angle::Result ensureConvertVertexInitialized(vk::Context *context); angle::Result ensureConvertVertexResourcesInitialized(vk::Context *context);
angle::Result ensureImageClearResourcesInitialized(vk::Context *context);
angle::PackedEnumMap<Function, vk::DescriptorSetLayoutPointerArray> mDescriptorSetLayouts; angle::PackedEnumMap<Function, vk::DescriptorSetLayoutPointerArray> mDescriptorSetLayouts;
angle::PackedEnumMap<Function, vk::BindingPointer<vk::PipelineLayout>> mPipelineLayouts; angle::PackedEnumMap<Function, vk::BindingPointer<vk::PipelineLayout>> mPipelineLayouts;
...@@ -160,8 +182,9 @@ class DispatchUtilsVk : angle::NonCopyable ...@@ -160,8 +182,9 @@ class DispatchUtilsVk : angle::NonCopyable
vk::ShaderProgramHelper vk::ShaderProgramHelper
mConvertVertexPrograms[vk::InternalShader::ConvertVertex_comp::kFlagsMask | mConvertVertexPrograms[vk::InternalShader::ConvertVertex_comp::kFlagsMask |
vk::InternalShader::ConvertVertex_comp::kConversionMask]; vk::InternalShader::ConvertVertex_comp::kConversionMask];
vk::ShaderProgramHelper mImageClearProgram;
}; };
} // namespace rx } // namespace rx
#endif // LIBANGLE_RENDERER_VULKAN_DISPATCHUTILSVK_H_ #endif // LIBANGLE_RENDERER_VULKAN_UTILSVK_H_
...@@ -222,7 +222,7 @@ angle::Result VertexArrayVk::convertVertexBufferGpu(ContextVk *contextVk, ...@@ -222,7 +222,7 @@ angle::Result VertexArrayVk::convertVertexBufferGpu(ContextVk *contextVk,
mCurrentArrayBuffers[attribIndex] = mCurrentArrayBuffers[attribIndex] =
mCurrentArrayBufferConversion[attribIndex].getCurrentBuffer(); mCurrentArrayBufferConversion[attribIndex].getCurrentBuffer();
DispatchUtilsVk::ConvertVertexParameters params; UtilsVk::ConvertVertexParameters params;
params.vertexCount = numVertices; params.vertexCount = numVertices;
params.srcFormat = &srcFormat; params.srcFormat = &srcFormat;
params.destFormat = &destFormat; params.destFormat = &destFormat;
...@@ -230,8 +230,8 @@ angle::Result VertexArrayVk::convertVertexBufferGpu(ContextVk *contextVk, ...@@ -230,8 +230,8 @@ angle::Result VertexArrayVk::convertVertexBufferGpu(ContextVk *contextVk,
params.srcOffset = binding.getOffset(); params.srcOffset = binding.getOffset();
params.destOffset = static_cast<size_t>(mCurrentArrayBufferOffsets[attribIndex]); params.destOffset = static_cast<size_t>(mCurrentArrayBufferOffsets[attribIndex]);
ANGLE_TRY(renderer->getDispatchUtils().convertVertexBuffer( ANGLE_TRY(renderer->getUtils().convertVertexBuffer(contextVk, mCurrentArrayBuffers[attribIndex],
contextVk, mCurrentArrayBuffers[attribIndex], &srcBuffer->getBuffer(), params)); &srcBuffer->getBuffer(), params));
mCurrentArrayBufferHandles[attribIndex] = mCurrentArrayBufferHandles[attribIndex] =
mCurrentArrayBuffers[attribIndex]->getBuffer().getHandle(); mCurrentArrayBuffers[attribIndex]->getBuffer().getHandle();
...@@ -670,7 +670,7 @@ angle::Result VertexArrayVk::updateIndexTranslation(ContextVk *contextVk, ...@@ -670,7 +670,7 @@ angle::Result VertexArrayVk::updateIndexTranslation(ContextVk *contextVk,
// Copy relevant section of the source into destination at allocated offset. Note that the // Copy relevant section of the source into destination at allocated offset. Note that the
// offset returned by allocate() above is in bytes, while our allocated array is of // offset returned by allocate() above is in bytes, while our allocated array is of
// GLushorts. // GLushorts.
DispatchUtilsVk::CopyParameters params = {}; UtilsVk::CopyParameters params = {};
params.destOffset = params.destOffset =
static_cast<size_t>(mCurrentElementArrayBufferOffset) / sizeof(GLushort); static_cast<size_t>(mCurrentElementArrayBufferOffset) / sizeof(GLushort);
params.srcOffset = offsetIntoSrcData; params.srcOffset = offsetIntoSrcData;
...@@ -679,7 +679,7 @@ angle::Result VertexArrayVk::updateIndexTranslation(ContextVk *contextVk, ...@@ -679,7 +679,7 @@ angle::Result VertexArrayVk::updateIndexTranslation(ContextVk *contextVk,
// Note: this is a copy, which implicitly converts between formats. Once support for // Note: this is a copy, which implicitly converts between formats. Once support for
// primitive restart is added, a specialized shader is likely needed to special case 0xFF -> // primitive restart is added, a specialized shader is likely needed to special case 0xFF ->
// 0xFFFF. // 0xFFFF.
ANGLE_TRY(renderer->getDispatchUtils().copyBuffer(contextVk, dest, src, params)); ANGLE_TRY(renderer->getUtils().copyBuffer(contextVk, dest, src, params));
} }
else else
{ {
......
// 7.11.3009
#pragma once
const uint32_t kImageClear_frag_00000000[] = {
0x07230203,0x00010000,0x00080007,0x00000012,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0006000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x00030010,0x00000004,
0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,0x00000000,
0x00050005,0x00000009,0x6f6c6f63,0x74754f72,0x00000000,0x00060005,0x0000000a,0x68737550,
0x736e6f43,0x746e6174,0x00000073,0x00060006,0x0000000a,0x00000000,0x61656c63,0x6c6f4372,
0x0000726f,0x00040005,0x0000000c,0x61726170,0x0000736d,0x00040047,0x00000009,0x0000001e,
0x00000000,0x00050048,0x0000000a,0x00000000,0x00000023,0x00000000,0x00030047,0x0000000a,
0x00000002,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,
0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040020,0x00000008,0x00000003,
0x00000007,0x0004003b,0x00000008,0x00000009,0x00000003,0x0003001e,0x0000000a,0x00000007,
0x00040020,0x0000000b,0x00000009,0x0000000a,0x0004003b,0x0000000b,0x0000000c,0x00000009,
0x00040015,0x0000000d,0x00000020,0x00000001,0x0004002b,0x0000000d,0x0000000e,0x00000000,
0x00040020,0x0000000f,0x00000009,0x00000007,0x00050036,0x00000002,0x00000004,0x00000000,
0x00000003,0x000200f8,0x00000005,0x00050041,0x0000000f,0x00000010,0x0000000c,0x0000000e,
0x0004003d,0x00000007,0x00000011,0x00000010,0x0003003e,0x00000009,0x00000011,0x000100fd,
0x00010038
};
#if 0 // Generated from:
#version 450 core
layout(push_constant)uniform PushConstants {
vec4 clearColor;
} params;
layout(location = 0)out vec4 colorOut;
void main()
{
colorOut = params . clearColor;
}
#endif // Preprocessed code
// 7.11.3009
#pragma once
const uint32_t kPushConstantColor_frag_00000000[] = {
0x07230203,0x00010000,0x00080007,0x00000012,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0006000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x00030010,0x00000004,
0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,0x00000000,
0x00050005,0x00000009,0x6f6c6f63,0x74754f72,0x00000000,0x00040005,0x0000000a,0x636f6c62,
0x0000006b,0x00050006,0x0000000a,0x00000000,0x6f6c6f63,0x006e4972,0x00030005,0x0000000c,
0x00000000,0x00040047,0x00000009,0x0000001e,0x00000000,0x00050048,0x0000000a,0x00000000,
0x00000023,0x00000000,0x00030047,0x0000000a,0x00000002,0x00020013,0x00000002,0x00030021,
0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,
0x00000004,0x00040020,0x00000008,0x00000003,0x00000007,0x0004003b,0x00000008,0x00000009,
0x00000003,0x0003001e,0x0000000a,0x00000007,0x00040020,0x0000000b,0x00000009,0x0000000a,
0x0004003b,0x0000000b,0x0000000c,0x00000009,0x00040015,0x0000000d,0x00000020,0x00000001,
0x0004002b,0x0000000d,0x0000000e,0x00000000,0x00040020,0x0000000f,0x00000009,0x00000007,
0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x00050041,
0x0000000f,0x00000010,0x0000000c,0x0000000e,0x0004003d,0x00000007,0x00000011,0x00000010,
0x0003003e,0x00000009,0x00000011,0x000100fd,0x00010038
};
#if 0 // Generated from:
#version 450 core
layout(push_constant)uniform block {
vec4 colorIn;
};
layout(location = 0)out vec4 colorOut;
void main()
{
colorOut = colorIn;
}
#endif // Preprocessed code
...@@ -3,17 +3,17 @@ ...@@ -3,17 +3,17 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// PushConstantColor.frag: Simple solid color fragment shader. // ImageClear.frag: Clear image to a solid color.
#version 450 core #version 450 core
layout(push_constant) uniform block { layout(push_constant) uniform PushConstants {
vec4 colorIn; vec4 clearColor;
}; } params;
layout(location = 0) out vec4 colorOut; layout(location = 0) out vec4 colorOut;
void main() void main()
{ {
colorOut = colorIn; colorOut = params.clearColor;
} }
...@@ -45,7 +45,7 @@ namespace ...@@ -45,7 +45,7 @@ namespace
#include "libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.0000000E.inc" #include "libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.0000000E.inc"
#include "libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.0000000F.inc" #include "libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.0000000F.inc"
#include "libANGLE/renderer/vulkan/shaders/gen/FullScreenQuad.vert.00000000.inc" #include "libANGLE/renderer/vulkan/shaders/gen/FullScreenQuad.vert.00000000.inc"
#include "libANGLE/renderer/vulkan/shaders/gen/PushConstantColor.frag.00000000.inc" #include "libANGLE/renderer/vulkan/shaders/gen/ImageClear.frag.00000000.inc"
// This is SPIR-V binary blob and the size. // This is SPIR-V binary blob and the size.
struct ShaderBlob struct ShaderBlob
...@@ -89,8 +89,8 @@ constexpr ShaderBlob kConvertVertex_comp_shaders[] = { ...@@ -89,8 +89,8 @@ constexpr ShaderBlob kConvertVertex_comp_shaders[] = {
constexpr ShaderBlob kFullScreenQuad_vert_shaders[] = { constexpr ShaderBlob kFullScreenQuad_vert_shaders[] = {
{kFullScreenQuad_vert_00000000, sizeof(kFullScreenQuad_vert_00000000)}, {kFullScreenQuad_vert_00000000, sizeof(kFullScreenQuad_vert_00000000)},
}; };
constexpr ShaderBlob kPushConstantColor_frag_shaders[] = { constexpr ShaderBlob kImageClear_frag_shaders[] = {
{kPushConstantColor_frag_00000000, sizeof(kPushConstantColor_frag_00000000)}, {kImageClear_frag_00000000, sizeof(kImageClear_frag_00000000)},
}; };
angle::Result GetShader(Context *context, angle::Result GetShader(Context *context,
...@@ -135,7 +135,7 @@ void ShaderLibrary::destroy(VkDevice device) ...@@ -135,7 +135,7 @@ void ShaderLibrary::destroy(VkDevice device)
{ {
shader.get().destroy(device); shader.get().destroy(device);
} }
for (RefCounted<ShaderAndSerial> &shader : mPushConstantColor_frag_shaders) for (RefCounted<ShaderAndSerial> &shader : mImageClear_frag_shaders)
{ {
shader.get().destroy(device); shader.get().destroy(device);
} }
...@@ -165,12 +165,12 @@ angle::Result ShaderLibrary::getFullScreenQuad_vert(Context *context, ...@@ -165,12 +165,12 @@ angle::Result ShaderLibrary::getFullScreenQuad_vert(Context *context,
ArraySize(kFullScreenQuad_vert_shaders), shaderFlags, shaderOut); ArraySize(kFullScreenQuad_vert_shaders), shaderFlags, shaderOut);
} }
angle::Result ShaderLibrary::getPushConstantColor_frag(Context *context, angle::Result ShaderLibrary::getImageClear_frag(Context *context,
uint32_t shaderFlags, uint32_t shaderFlags,
RefCounted<ShaderAndSerial> **shaderOut) RefCounted<ShaderAndSerial> **shaderOut)
{ {
return GetShader(context, mPushConstantColor_frag_shaders, kPushConstantColor_frag_shaders, return GetShader(context, mImageClear_frag_shaders, kImageClear_frag_shaders,
ArraySize(kPushConstantColor_frag_shaders), shaderFlags, shaderOut); ArraySize(kImageClear_frag_shaders), shaderFlags, shaderOut);
} }
} // namespace vk } // namespace vk
......
...@@ -38,5 +38,5 @@ angle_vulkan_internal_shaders = [ ...@@ -38,5 +38,5 @@ angle_vulkan_internal_shaders = [
"shaders/gen/ConvertVertex.comp.0000000E.inc", "shaders/gen/ConvertVertex.comp.0000000E.inc",
"shaders/gen/ConvertVertex.comp.0000000F.inc", "shaders/gen/ConvertVertex.comp.0000000F.inc",
"shaders/gen/FullScreenQuad.vert.00000000.inc", "shaders/gen/FullScreenQuad.vert.00000000.inc",
"shaders/gen/PushConstantColor.frag.00000000.inc", "shaders/gen/ImageClear.frag.00000000.inc",
] ]
...@@ -65,8 +65,8 @@ enum Conversion ...@@ -65,8 +65,8 @@ enum Conversion
namespace FullScreenQuad_vert namespace FullScreenQuad_vert
{} // namespace FullScreenQuad_vert {} // namespace FullScreenQuad_vert
namespace PushConstantColor_frag namespace ImageClear_frag
{} // namespace PushConstantColor_frag {} // namespace ImageClear_frag
} // namespace InternalShader } // namespace InternalShader
...@@ -87,9 +87,9 @@ class ShaderLibrary final : angle::NonCopyable ...@@ -87,9 +87,9 @@ class ShaderLibrary final : angle::NonCopyable
angle::Result getFullScreenQuad_vert(Context *context, angle::Result getFullScreenQuad_vert(Context *context,
uint32_t shaderFlags, uint32_t shaderFlags,
RefCounted<ShaderAndSerial> **shaderOut); RefCounted<ShaderAndSerial> **shaderOut);
angle::Result getPushConstantColor_frag(Context *context, angle::Result getImageClear_frag(Context *context,
uint32_t shaderFlags, uint32_t shaderFlags,
RefCounted<ShaderAndSerial> **shaderOut); RefCounted<ShaderAndSerial> **shaderOut);
private: private:
RefCounted<ShaderAndSerial> RefCounted<ShaderAndSerial>
...@@ -100,7 +100,7 @@ class ShaderLibrary final : angle::NonCopyable ...@@ -100,7 +100,7 @@ class ShaderLibrary final : angle::NonCopyable
mConvertVertex_comp_shaders[InternalShader::ConvertVertex_comp::kFlagsMask | mConvertVertex_comp_shaders[InternalShader::ConvertVertex_comp::kFlagsMask |
InternalShader::ConvertVertex_comp::kConversionMask]; InternalShader::ConvertVertex_comp::kConversionMask];
RefCounted<ShaderAndSerial> mFullScreenQuad_vert_shaders[1]; RefCounted<ShaderAndSerial> mFullScreenQuad_vert_shaders[1];
RefCounted<ShaderAndSerial> mPushConstantColor_frag_shaders[1]; RefCounted<ShaderAndSerial> mImageClear_frag_shaders[1];
}; };
} // namespace vk } // namespace vk
} // namespace rx } // namespace rx
......
...@@ -724,8 +724,6 @@ libangle_vulkan_sources = [ ...@@ -724,8 +724,6 @@ libangle_vulkan_sources = [
"src/libANGLE/renderer/vulkan/ContextVk.h", "src/libANGLE/renderer/vulkan/ContextVk.h",
"src/libANGLE/renderer/vulkan/DeviceVk.cpp", "src/libANGLE/renderer/vulkan/DeviceVk.cpp",
"src/libANGLE/renderer/vulkan/DeviceVk.h", "src/libANGLE/renderer/vulkan/DeviceVk.h",
"src/libANGLE/renderer/vulkan/DispatchUtilsVk.cpp",
"src/libANGLE/renderer/vulkan/DispatchUtilsVk.h",
"src/libANGLE/renderer/vulkan/DisplayVk.cpp", "src/libANGLE/renderer/vulkan/DisplayVk.cpp",
"src/libANGLE/renderer/vulkan/DisplayVk.h", "src/libANGLE/renderer/vulkan/DisplayVk.h",
"src/libANGLE/renderer/vulkan/FenceNVVk.cpp", "src/libANGLE/renderer/vulkan/FenceNVVk.cpp",
...@@ -760,6 +758,8 @@ libangle_vulkan_sources = [ ...@@ -760,6 +758,8 @@ libangle_vulkan_sources = [
"src/libANGLE/renderer/vulkan/TextureVk.h", "src/libANGLE/renderer/vulkan/TextureVk.h",
"src/libANGLE/renderer/vulkan/TransformFeedbackVk.cpp", "src/libANGLE/renderer/vulkan/TransformFeedbackVk.cpp",
"src/libANGLE/renderer/vulkan/TransformFeedbackVk.h", "src/libANGLE/renderer/vulkan/TransformFeedbackVk.h",
"src/libANGLE/renderer/vulkan/UtilsVk.cpp",
"src/libANGLE/renderer/vulkan/UtilsVk.h",
"src/libANGLE/renderer/vulkan/VertexArrayVk.cpp", "src/libANGLE/renderer/vulkan/VertexArrayVk.cpp",
"src/libANGLE/renderer/vulkan/VertexArrayVk.h", "src/libANGLE/renderer/vulkan/VertexArrayVk.h",
"src/libANGLE/renderer/vulkan/vk_cache_utils.cpp", "src/libANGLE/renderer/vulkan/vk_cache_utils.cpp",
......
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