aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/vk')
-rw-r--r--src/gpu/vk/GrVkBackendContext.cpp9
-rw-r--r--src/gpu/vk/GrVkCaps.cpp25
-rw-r--r--src/gpu/vk/GrVkCommandBuffer.cpp23
-rw-r--r--src/gpu/vk/GrVkCommandBuffer.h6
-rw-r--r--src/gpu/vk/GrVkGpuCommandBuffer.cpp16
-rw-r--r--src/gpu/vk/GrVkInterface.cpp23
-rw-r--r--src/gpu/vk/GrVkPipeline.cpp113
-rw-r--r--src/gpu/vk/GrVkPipeline.h6
-rw-r--r--src/gpu/vk/GrVkPipelineState.cpp11
-rw-r--r--src/gpu/vk/GrVkPipelineState.h2
-rw-r--r--src/gpu/vk/GrVkPipelineStateCache.cpp2
-rw-r--r--src/gpu/vk/GrVkRenderTarget.cpp17
-rw-r--r--src/gpu/vk/GrVkRenderTarget.h3
13 files changed, 206 insertions, 50 deletions
diff --git a/src/gpu/vk/GrVkBackendContext.cpp b/src/gpu/vk/GrVkBackendContext.cpp
index e473178223..a602a50f73 100644
--- a/src/gpu/vk/GrVkBackendContext.cpp
+++ b/src/gpu/vk/GrVkBackendContext.cpp
@@ -76,6 +76,10 @@ const GrVkBackendContext* GrVkBackendContext::Create(uint32_t* presentQueueIndex
SkTArray<const char*> instanceLayerNames;
SkTArray<const char*> instanceExtensionNames;
uint32_t extensionFlags = 0;
+ if (extensions.hasInstanceExtension(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) {
+ instanceExtensionNames.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
+ extensionFlags |= kKHR_get_physical_device_properties2_GrVkExtensionFlag;
+ }
#ifdef SK_ENABLE_VK_LAYERS
for (size_t i = 0; i < SK_ARRAY_COUNT(kDebugLayerNames); ++i) {
if (extensions.hasInstanceLayer(kDebugLayerNames[i])) {
@@ -87,7 +91,6 @@ const GrVkBackendContext* GrVkBackendContext::Create(uint32_t* presentQueueIndex
extensionFlags |= kEXT_debug_report_GrVkExtensionFlag;
}
#endif
-
if (extensions.hasInstanceExtension(VK_KHR_SURFACE_EXTENSION_NAME)) {
instanceExtensionNames.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
extensionFlags |= kKHR_surface_GrVkExtensionFlag;
@@ -223,6 +226,10 @@ const GrVkBackendContext* GrVkBackendContext::Create(uint32_t* presentQueueIndex
}
}
#endif
+ if (extensions.hasDeviceExtension(VK_EXT_DISCARD_RECTANGLES_EXTENSION_NAME)) {
+ deviceExtensionNames.push_back(VK_EXT_DISCARD_RECTANGLES_EXTENSION_NAME);
+ extensionFlags |= kEXT_discard_rectangles_GrVkExtensionFlag;
+ }
if (extensions.hasDeviceExtension(VK_KHR_SWAPCHAIN_EXTENSION_NAME)) {
deviceExtensionNames.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
extensionFlags |= kKHR_swapchain_GrVkExtensionFlag;
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index 2b24205af8..9f635e2f20 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -75,9 +75,30 @@ bool GrVkCaps::initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc*
void GrVkCaps::init(const GrContextOptions& contextOptions, const GrVkInterface* vkInterface,
VkPhysicalDevice physDev, uint32_t featureFlags, uint32_t extensionFlags) {
+ VkPhysicalDeviceProperties2KHR khrProperties;
+ if (SkToBool(extensionFlags & kKHR_get_physical_device_properties2_GrVkExtensionFlag)) {
+ khrProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR;
+ khrProperties.pNext = nullptr;
+
+ VkPhysicalDeviceDiscardRectanglePropertiesEXT discardRectsProperties;
+ if (SkToBool(extensionFlags & kEXT_discard_rectangles_GrVkExtensionFlag)) {
+ discardRectsProperties.sType =
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DISCARD_RECTANGLE_PROPERTIES_EXT;
+ discardRectsProperties.pNext = khrProperties.pNext;
+ khrProperties.pNext = &discardRectsProperties;
+ }
+
+ GR_VK_CALL(vkInterface, GetPhysicalDeviceProperties2KHR(physDev, &khrProperties));
+
+ if (SkToBool(extensionFlags & kEXT_discard_rectangles_GrVkExtensionFlag)) {
+ fWindowRectsSupport = WindowRectsSupport::kDrawOnly;
+ fMaxWindowRectangles = discardRectsProperties.maxDiscardRectangles;
+ }
+ } else {
+ GR_VK_CALL(vkInterface, GetPhysicalDeviceProperties(physDev, &khrProperties.properties));
+ }
- VkPhysicalDeviceProperties properties;
- GR_VK_CALL(vkInterface, GetPhysicalDeviceProperties(physDev, &properties));
+ const VkPhysicalDeviceProperties& properties = khrProperties.properties;
VkPhysicalDeviceMemoryProperties memoryProperties;
GR_VK_CALL(vkInterface, GetPhysicalDeviceMemoryProperties(physDev, &memoryProperties));
diff --git a/src/gpu/vk/GrVkCommandBuffer.cpp b/src/gpu/vk/GrVkCommandBuffer.cpp
index 8a17a4f033..ba19168b37 100644
--- a/src/gpu/vk/GrVkCommandBuffer.cpp
+++ b/src/gpu/vk/GrVkCommandBuffer.cpp
@@ -34,6 +34,11 @@ void GrVkCommandBuffer::invalidateState() {
memset(&fCachedScissor, 0, sizeof(VkRect2D));
fCachedScissor.offset.x = -1; // Scissor offset must be greater that 0 to be valid
+ memset(&fCachedDiscardRectangles, 0, sizeof(fCachedDiscardRectangles));
+ for (int i = 0; i < GrWindowRectangles::kMaxWindows; ++i) {
+ fCachedDiscardRectangles[i].offset.x = -1; // Negative offsets are invalid.
+ }
+
for (int i = 0; i < 4; ++i) {
fCachedBlendConstant[i] = -1.0;
}
@@ -323,6 +328,24 @@ void GrVkCommandBuffer::setScissor(const GrVkGpu* gpu,
}
}
+void GrVkCommandBuffer::setDiscardRectangles(const GrVkGpu* gpu,
+ uint32_t firstDiscardRectangle,
+ uint32_t discardRectangleCount,
+ const VkRect2D* discardRectangles) {
+ SkASSERT(fIsActive);
+ SkASSERT(firstDiscardRectangle + discardRectangleCount <= gpu->vkCaps().maxWindowRectangles());
+ SkASSERT(gpu->vkCaps().maxWindowRectangles() <= GrWindowRectangles::kMaxWindows);
+ if (memcmp(discardRectangles, &fCachedDiscardRectangles[firstDiscardRectangle],
+ discardRectangleCount * sizeof(VkRect2D))) {
+ GR_VK_CALL(gpu->vkInterface(), CmdSetDiscardRectangleEXT(fCmdBuffer,
+ firstDiscardRectangle,
+ discardRectangleCount,
+ discardRectangles));
+ memcpy(&fCachedDiscardRectangles[firstDiscardRectangle], discardRectangles,
+ discardRectangleCount * sizeof(VkRect2D));
+ }
+}
+
void GrVkCommandBuffer::setBlendConstants(const GrVkGpu* gpu,
const float blendConstants[4]) {
SkASSERT(fIsActive);
diff --git a/src/gpu/vk/GrVkCommandBuffer.h b/src/gpu/vk/GrVkCommandBuffer.h
index 7d16242e6b..cf6dc2a750 100644
--- a/src/gpu/vk/GrVkCommandBuffer.h
+++ b/src/gpu/vk/GrVkCommandBuffer.h
@@ -80,6 +80,11 @@ public:
uint32_t scissorCount,
const VkRect2D* scissors);
+ void setDiscardRectangles(const GrVkGpu* gpu,
+ uint32_t firstDiscardRectangle,
+ uint32_t discardRectangleCount,
+ const VkRect2D* discardRectangles);
+
void setBlendConstants(const GrVkGpu* gpu, const float blendConstants[4]);
// Commands that only work inside of a render pass
@@ -167,6 +172,7 @@ private:
// Cached values used for dynamic state updates
VkViewport fCachedViewport;
VkRect2D fCachedScissor;
+ VkRect2D fCachedDiscardRectangles[GrWindowRectangles::kMaxWindows];
float fCachedBlendConstant[4];
};
diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.cpp b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
index 52dfede267..a14ce8c3e2 100644
--- a/src/gpu/vk/GrVkGpuCommandBuffer.cpp
+++ b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
@@ -251,10 +251,11 @@ void GrVkGpuRTCommandBuffer::insertEventMarker(const char* msg) {
}
void GrVkGpuRTCommandBuffer::onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) {
- SkASSERT(!clip.hasWindowRectangles());
-
CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
+ // We ignore window rectangles as they are not supported by Vulkan during clear.
+ SkASSERT(!clip.hasWindowRectangles());
+
GrStencilAttachment* sb = fRenderTarget->renderTargetPriv().getStencilAttachment();
// this should only be called internally when we know we have a
// stencil buffer.
@@ -313,7 +314,7 @@ void GrVkGpuRTCommandBuffer::onClearStencilClip(const GrFixedClip& clip, bool in
void GrVkGpuRTCommandBuffer::onClear(const GrFixedClip& clip, GrColor color) {
GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
- // parent class should never let us get here with no RT
+ // We ignore window rectangles as they are not supported by Vulkan during clear.
SkASSERT(!clip.hasWindowRectangles());
CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
@@ -527,6 +528,7 @@ GrVkPipelineState* GrVkGpuRTCommandBuffer::prepareDrawState(const GrPipeline& pi
GrRenderTarget* rt = pipeline.renderTarget();
+ GrVkPipeline::SetDynamicViewportState(fGpu, cbInfo.currentCmdBuf(), rt);
if (!pipeline.getScissorState().enabled()) {
GrVkPipeline::SetDynamicScissorRectState(fGpu, cbInfo.currentCmdBuf(),
rt, pipeline.proxy()->origin(),
@@ -536,7 +538,13 @@ GrVkPipelineState* GrVkGpuRTCommandBuffer::prepareDrawState(const GrPipeline& pi
rt, pipeline.proxy()->origin(),
pipeline.getScissorState().rect());
}
- GrVkPipeline::SetDynamicViewportState(fGpu, cbInfo.currentCmdBuf(), rt);
+ if (pipeline.getWindowRectsState().enabled()) {
+ // No need to check hasDynamicState -- window rectangles aren't currently included in
+ // GrPipeline::DynamicState.
+ GrVkPipeline::SetDynamicDiscardRectanglesState(fGpu, cbInfo.currentCmdBuf(),
+ rt, pipeline.proxy()->origin(),
+ pipeline.getWindowRectsState().windows());
+ }
GrVkPipeline::SetDynamicBlendConstantState(fGpu, cbInfo.currentCmdBuf(), rt->config(),
pipeline.getXferProcessor());
diff --git a/src/gpu/vk/GrVkInterface.cpp b/src/gpu/vk/GrVkInterface.cpp
index dedc264136..04589cd51b 100644
--- a/src/gpu/vk/GrVkInterface.cpp
+++ b/src/gpu/vk/GrVkInterface.cpp
@@ -59,6 +59,11 @@ GrVkInterface::GrVkInterface(GetProc getProc,
ACQUIRE_PROC(EnumerateDeviceExtensionProperties, instance, VK_NULL_HANDLE);
ACQUIRE_PROC(EnumerateDeviceLayerProperties, instance, VK_NULL_HANDLE);
+ if (extensionFlags & kKHR_get_physical_device_properties2_GrVkExtensionFlag) {
+ // Also Instance Proc.
+ ACQUIRE_PROC(GetPhysicalDeviceProperties2KHR, instance, VK_NULL_HANDLE);
+ }
+
if (extensionFlags & kEXT_debug_report_GrVkExtensionFlag) {
// Also instance Procs.
ACQUIRE_PROC(CreateDebugReportCallbackEXT, instance, VK_NULL_HANDLE);
@@ -186,6 +191,11 @@ GrVkInterface::GrVkInterface(GetProc getProc,
ACQUIRE_PROC(CmdNextSubpass, VK_NULL_HANDLE, device);
ACQUIRE_PROC(CmdEndRenderPass, VK_NULL_HANDLE, device);
ACQUIRE_PROC(CmdExecuteCommands, VK_NULL_HANDLE, device);
+
+ if (extensionFlags & kEXT_discard_rectangles_GrVkExtensionFlag) {
+ // Also Device Proc.
+ ACQUIRE_PROC(CmdSetDiscardRectangleEXT, VK_NULL_HANDLE, device);
+ }
}
#ifdef SK_DEBUG
@@ -338,6 +348,12 @@ bool GrVkInterface::validate(uint32_t extensionFlags) const {
RETURN_FALSE_INTERFACE
}
+ if (extensionFlags & kKHR_get_physical_device_properties2_GrVkExtensionFlag) {
+ if (nullptr == fFunctions.fGetPhysicalDeviceProperties2KHR) {
+ RETURN_FALSE_INTERFACE
+ }
+ }
+
if (extensionFlags & kEXT_debug_report_GrVkExtensionFlag) {
if (nullptr == fFunctions.fCreateDebugReportCallbackEXT ||
nullptr == fFunctions.fDebugReportMessageEXT ||
@@ -345,6 +361,13 @@ bool GrVkInterface::validate(uint32_t extensionFlags) const {
RETURN_FALSE_INTERFACE
}
}
+
+ if (extensionFlags & kEXT_discard_rectangles_GrVkExtensionFlag) {
+ if (nullptr == fFunctions.fCmdSetDiscardRectangleEXT) {
+ RETURN_FALSE_INTERFACE
+ }
+ }
+
return true;
}
diff --git a/src/gpu/vk/GrVkPipeline.cpp b/src/gpu/vk/GrVkPipeline.cpp
index a247078f72..5891f4cb59 100644
--- a/src/gpu/vk/GrVkPipeline.cpp
+++ b/src/gpu/vk/GrVkPipeline.cpp
@@ -239,6 +239,21 @@ static void setup_viewport_scissor_state(VkPipelineViewportStateCreateInfo* view
SkASSERT(viewportInfo->viewportCount == viewportInfo->scissorCount);
}
+static void setup_discard_rectangles_state(const GrWindowRectsState& windowState,
+ const GrCaps* caps,
+ VkPipelineDiscardRectangleStateCreateInfoEXT* info) {
+ SkASSERT(windowState.numWindows() <= caps->maxWindowRectangles());
+ memset(info, 0, sizeof(VkPipelineDiscardRectangleStateCreateInfoEXT));
+ info->sType = VK_STRUCTURE_TYPE_PIPELINE_DISCARD_RECTANGLE_STATE_CREATE_INFO_EXT;
+ info->pNext = nullptr;
+ info->flags = 0;
+ info->discardRectangleMode =
+ GrWindowRectsState::Mode::kExclusive == windowState.mode() ?
+ VK_DISCARD_RECTANGLE_MODE_EXCLUSIVE_EXT : VK_DISCARD_RECTANGLE_MODE_INCLUSIVE_EXT;
+ info->discardRectangleCount = windowState.numWindows();
+ info->pDiscardRectangles = nullptr; // This is set dynamically
+}
+
static void setup_multisample_state(const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc,
const GrCaps* caps,
@@ -409,17 +424,21 @@ static void setup_raster_state(const GrPipeline& pipeline,
rasterInfo->lineWidth = 1.0f;
}
-static void setup_dynamic_state(VkPipelineDynamicStateCreateInfo* dynamicInfo,
- VkDynamicState* dynamicStates) {
+static void setup_dynamic_state(const GrPipeline& pipeline,
+ VkPipelineDynamicStateCreateInfo* dynamicInfo,
+ SkSTArray<4, VkDynamicState>* dynamicStates) {
memset(dynamicInfo, 0, sizeof(VkPipelineDynamicStateCreateInfo));
dynamicInfo->sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
dynamicInfo->pNext = VK_NULL_HANDLE;
dynamicInfo->flags = 0;
- dynamicStates[0] = VK_DYNAMIC_STATE_VIEWPORT;
- dynamicStates[1] = VK_DYNAMIC_STATE_SCISSOR;
- dynamicStates[2] = VK_DYNAMIC_STATE_BLEND_CONSTANTS;
- dynamicInfo->dynamicStateCount = 3;
- dynamicInfo->pDynamicStates = dynamicStates;
+ dynamicStates->push_back(VK_DYNAMIC_STATE_VIEWPORT);
+ dynamicStates->push_back(VK_DYNAMIC_STATE_SCISSOR);
+ if (pipeline.getWindowRectsState().enabled()) {
+ dynamicStates->push_back(VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT);
+ }
+ dynamicStates->push_back(VK_DYNAMIC_STATE_BLEND_CONSTANTS);
+ dynamicInfo->dynamicStateCount = dynamicStates->count();
+ dynamicInfo->pDynamicStates = dynamicStates->begin();
}
GrVkPipeline* GrVkPipeline::Create(GrVkGpu* gpu, const GrPipeline& pipeline,
@@ -458,9 +477,9 @@ GrVkPipeline* GrVkPipeline::Create(GrVkGpu* gpu, const GrPipeline& pipeline,
VkPipelineRasterizationStateCreateInfo rasterInfo;
setup_raster_state(pipeline, gpu->caps(), &rasterInfo);
- VkDynamicState dynamicStates[3];
+ SkSTArray<4, VkDynamicState> dynamicStates;
VkPipelineDynamicStateCreateInfo dynamicInfo;
- setup_dynamic_state(&dynamicInfo, dynamicStates);
+ setup_dynamic_state(pipeline, &dynamicInfo, &dynamicStates);
VkGraphicsPipelineCreateInfo pipelineCreateInfo;
memset(&pipelineCreateInfo, 0, sizeof(VkGraphicsPipelineCreateInfo));
@@ -484,6 +503,15 @@ GrVkPipeline* GrVkPipeline::Create(GrVkGpu* gpu, const GrPipeline& pipeline,
pipelineCreateInfo.basePipelineHandle = VK_NULL_HANDLE;
pipelineCreateInfo.basePipelineIndex = -1;
+ VkPipelineDiscardRectangleStateCreateInfoEXT discardRectanglesInfo;
+ if (pipeline.getWindowRectsState().enabled()) {
+ SkASSERT(GrCaps::WindowRectsSupport::kNone != gpu->caps()->windowRectsSupport());
+ setup_discard_rectangles_state(pipeline.getWindowRectsState(), gpu->caps(),
+ &discardRectanglesInfo);
+ discardRectanglesInfo.pNext = pipelineCreateInfo.pNext;
+ pipelineCreateInfo.pNext = &discardRectanglesInfo;
+ }
+
VkPipeline vkPipeline;
VkResult err = GR_VK_CALL(gpu->vkInterface(), CreateGraphicsPipelines(gpu->device(),
cache, 1,
@@ -500,31 +528,6 @@ void GrVkPipeline::freeGPUData(const GrVkGpu* gpu) const {
GR_VK_CALL(gpu->vkInterface(), DestroyPipeline(gpu->device(), fPipeline, nullptr));
}
-void GrVkPipeline::SetDynamicScissorRectState(GrVkGpu* gpu,
- GrVkCommandBuffer* cmdBuffer,
- const GrRenderTarget* renderTarget,
- GrSurfaceOrigin rtOrigin,
- SkIRect scissorRect) {
- if (!scissorRect.intersect(SkIRect::MakeWH(renderTarget->width(), renderTarget->height()))) {
- scissorRect.setEmpty();
- }
-
- VkRect2D scissor;
- scissor.offset.x = scissorRect.fLeft;
- scissor.extent.width = scissorRect.width();
- if (kTopLeft_GrSurfaceOrigin == rtOrigin) {
- scissor.offset.y = scissorRect.fTop;
- } else {
- SkASSERT(kBottomLeft_GrSurfaceOrigin == rtOrigin);
- scissor.offset.y = renderTarget->height() - scissorRect.fBottom;
- }
- scissor.extent.height = scissorRect.height();
-
- SkASSERT(scissor.offset.x >= 0);
- SkASSERT(scissor.offset.y >= 0);
- cmdBuffer->setScissor(gpu, 0, 1, &scissor);
-}
-
void GrVkPipeline::SetDynamicViewportState(GrVkGpu* gpu,
GrVkCommandBuffer* cmdBuffer,
const GrRenderTarget* renderTarget) {
@@ -539,6 +542,48 @@ void GrVkPipeline::SetDynamicViewportState(GrVkGpu* gpu,
cmdBuffer->setViewport(gpu, 0, 1, &viewport);
}
+inline static void skrect_to_vkrect(SkIRect skrect,
+ const GrRenderTarget* renderTarget,
+ GrSurfaceOrigin rtOrigin,
+ VkRect2D* vkrect) {
+ if (!skrect.intersect(SkIRect::MakeWH(renderTarget->width(), renderTarget->height()))) {
+ skrect.setEmpty();
+ }
+
+ vkrect->offset.x = skrect.fLeft;
+ vkrect->extent.width = skrect.width();
+ if (kTopLeft_GrSurfaceOrigin == rtOrigin) {
+ vkrect->offset.y = skrect.fTop;
+ } else {
+ SkASSERT(kBottomLeft_GrSurfaceOrigin == rtOrigin);
+ vkrect->offset.y = renderTarget->height() - skrect.fBottom;
+ }
+ vkrect->extent.height = skrect.height();
+}
+
+void GrVkPipeline::SetDynamicScissorRectState(GrVkGpu* gpu,
+ GrVkCommandBuffer* cmdBuffer,
+ const GrRenderTarget* renderTarget,
+ GrSurfaceOrigin rtOrigin,
+ SkIRect scissorRect) {
+ VkRect2D scissor;
+ skrect_to_vkrect(scissorRect, renderTarget, rtOrigin, &scissor);
+ cmdBuffer->setScissor(gpu, 0, 1, &scissor);
+}
+
+void GrVkPipeline::SetDynamicDiscardRectanglesState(GrVkGpu* gpu,
+ GrVkCommandBuffer* cmdBuffer,
+ const GrRenderTarget* renderTarget,
+ GrSurfaceOrigin rtOrigin,
+ const GrWindowRectangles& windowRectangles) {
+ const SkIRect* skrects = windowRectangles.data();
+ VkRect2D vkrects[GrWindowRectangles::kMaxWindows];
+ for (int i = 0; i < windowRectangles.count(); ++i) {
+ skrect_to_vkrect(skrects[i], renderTarget, rtOrigin, &vkrects[i]);
+ }
+ cmdBuffer->setDiscardRectangles(gpu, 0, windowRectangles.count(), vkrects);
+}
+
void GrVkPipeline::SetDynamicBlendConstantState(GrVkGpu* gpu,
GrVkCommandBuffer* cmdBuffer,
GrPixelConfig pixelConfig,
diff --git a/src/gpu/vk/GrVkPipeline.h b/src/gpu/vk/GrVkPipeline.h
index 88c3d5f915..ad77037c52 100644
--- a/src/gpu/vk/GrVkPipeline.h
+++ b/src/gpu/vk/GrVkPipeline.h
@@ -22,6 +22,7 @@ class GrStencilSettings;
class GrVkCommandBuffer;
class GrVkGpu;
class GrVkRenderPass;
+class GrWindowRectangles;
struct SkIRect;
class GrVkPipeline : public GrVkResource {
@@ -39,9 +40,12 @@ public:
VkPipeline pipeline() const { return fPipeline; }
+ static void SetDynamicViewportState(GrVkGpu*, GrVkCommandBuffer*, const GrRenderTarget*);
static void SetDynamicScissorRectState(GrVkGpu*, GrVkCommandBuffer*, const GrRenderTarget*,
GrSurfaceOrigin, SkIRect);
- static void SetDynamicViewportState(GrVkGpu*, GrVkCommandBuffer*, const GrRenderTarget*);
+ static void SetDynamicDiscardRectanglesState(GrVkGpu*, GrVkCommandBuffer*,
+ const GrRenderTarget*, GrSurfaceOrigin,
+ const GrWindowRectangles&);
static void SetDynamicBlendConstantState(GrVkGpu*, GrVkCommandBuffer*, GrPixelConfig,
const GrXferProcessor&);
diff --git a/src/gpu/vk/GrVkPipelineState.cpp b/src/gpu/vk/GrVkPipelineState.cpp
index 17197750ab..5256c6dbcd 100644
--- a/src/gpu/vk/GrVkPipelineState.cpp
+++ b/src/gpu/vk/GrVkPipelineState.cpp
@@ -571,9 +571,9 @@ bool GrVkPipelineState::Desc::Build(Desc* desc,
const GrPipeline& pipeline,
const GrStencilSettings& stencil,
GrPrimitiveType primitiveType,
- const GrShaderCaps& caps) {
+ const GrCaps& caps) {
if (!INHERITED::Build(desc, primProc, primitiveType == GrPrimitiveType::kPoints, pipeline,
- caps)) {
+ *caps.shaderCaps())) {
return false;
}
@@ -587,5 +587,12 @@ bool GrVkPipelineState::Desc::Build(Desc* desc,
b.add32((uint32_t)primitiveType);
+ if (GrCaps::WindowRectsSupport::kNone != caps.windowRectsSupport()) {
+ const GrWindowRectsState& windowState = pipeline.getWindowRectsState();
+ uint32_t mode = (0u - (uint32_t)windowState.mode());
+ SkASSERT(0u == mode || ~0u == mode);
+ b.add32((uint32_t)windowState.numWindows() ^ mode);
+ }
+
return true;
}
diff --git a/src/gpu/vk/GrVkPipelineState.h b/src/gpu/vk/GrVkPipelineState.h
index 2794b99d22..0eb822a65b 100644
--- a/src/gpu/vk/GrVkPipelineState.h
+++ b/src/gpu/vk/GrVkPipelineState.h
@@ -77,7 +77,7 @@ public:
const GrPipeline&,
const GrStencilSettings&,
GrPrimitiveType primitiveType,
- const GrShaderCaps&);
+ const GrCaps&);
private:
typedef GrProgramDesc INHERITED;
};
diff --git a/src/gpu/vk/GrVkPipelineStateCache.cpp b/src/gpu/vk/GrVkPipelineStateCache.cpp
index caffe05bd5..37dc4a6cf9 100644
--- a/src/gpu/vk/GrVkPipelineStateCache.cpp
+++ b/src/gpu/vk/GrVkPipelineStateCache.cpp
@@ -93,7 +93,7 @@ GrVkPipelineState* GrVkResourceProvider::PipelineStateCache::refPipelineState(
// Get GrVkProgramDesc
GrVkPipelineState::Desc desc;
if (!GrVkPipelineState::Desc::Build(&desc, primProc, pipeline, stencil,
- primitiveType, *fGpu->caps()->shaderCaps())) {
+ primitiveType, *fGpu->caps())) {
GrCapsDebugf(fGpu->caps(), "Failed to build vk program descriptor!\n");
return nullptr;
}
diff --git a/src/gpu/vk/GrVkRenderTarget.cpp b/src/gpu/vk/GrVkRenderTarget.cpp
index 27cb119efc..d250ec6d61 100644
--- a/src/gpu/vk/GrVkRenderTarget.cpp
+++ b/src/gpu/vk/GrVkRenderTarget.cpp
@@ -8,6 +8,7 @@
#include "GrVkRenderTarget.h"
#include "GrRenderTargetPriv.h"
+#include "GrVkCaps.h"
#include "GrVkCommandBuffer.h"
#include "GrVkFramebuffer.h"
#include "GrVkGpu.h"
@@ -32,7 +33,7 @@ GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
: GrSurface(gpu, desc)
, GrVkImage(info, ownership)
// for the moment we only support 1:1 color to stencil
- , GrRenderTarget(gpu, desc)
+ , GrRenderTarget(gpu, desc, ComputeFlags(gpu->vkCaps()))
, fColorAttachmentView(colorAttachmentView)
, fMSAAImage(new GrVkImage(msaaInfo, GrBackendObjectOwnership::kOwned))
, fResolveAttachmentView(resolveAttachmentView)
@@ -55,7 +56,7 @@ GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
: GrSurface(gpu, desc)
, GrVkImage(info, ownership)
// for the moment we only support 1:1 color to stencil
- , GrRenderTarget(gpu, desc)
+ , GrRenderTarget(gpu, desc, ComputeFlags(gpu->vkCaps()))
, fColorAttachmentView(colorAttachmentView)
, fMSAAImage(new GrVkImage(msaaInfo, GrBackendObjectOwnership::kOwned))
, fResolveAttachmentView(resolveAttachmentView)
@@ -75,7 +76,7 @@ GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
GrBackendObjectOwnership ownership)
: GrSurface(gpu, desc)
, GrVkImage(info, ownership)
- , GrRenderTarget(gpu, desc)
+ , GrRenderTarget(gpu, desc, ComputeFlags(gpu->vkCaps()))
, fColorAttachmentView(colorAttachmentView)
, fMSAAImage(nullptr)
, fResolveAttachmentView(nullptr)
@@ -95,7 +96,7 @@ GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
GrBackendObjectOwnership ownership)
: GrSurface(gpu, desc)
, GrVkImage(info, ownership)
- , GrRenderTarget(gpu, desc)
+ , GrRenderTarget(gpu, desc, ComputeFlags(gpu->vkCaps()))
, fColorAttachmentView(colorAttachmentView)
, fMSAAImage(nullptr)
, fResolveAttachmentView(nullptr)
@@ -105,6 +106,14 @@ GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
this->createFramebuffer(gpu);
}
+inline GrRenderTargetFlags GrVkRenderTarget::ComputeFlags(const GrVkCaps& vkCaps) {
+ GrRenderTargetFlags flags = GrRenderTargetFlags::kNone;
+ if (GrCaps::WindowRectsSupport::kNone != vkCaps.windowRectsSupport()) {
+ flags |= GrRenderTargetFlags::kWindowRectsSupport;
+ }
+ return flags;
+}
+
GrVkRenderTarget*
GrVkRenderTarget::Create(GrVkGpu* gpu,
SkBudgeted budgeted,
diff --git a/src/gpu/vk/GrVkRenderTarget.h b/src/gpu/vk/GrVkRenderTarget.h
index 18a0bd3eea..2ea065bc34 100644
--- a/src/gpu/vk/GrVkRenderTarget.h
+++ b/src/gpu/vk/GrVkRenderTarget.h
@@ -15,6 +15,7 @@
#include "GrVkRenderPass.h"
#include "GrVkResourceProvider.h"
+class GrVkCaps;
class GrVkCommandBuffer;
class GrVkFramebuffer;
class GrVkGpu;
@@ -91,6 +92,8 @@ protected:
const GrVkImageView* colorAttachmentView,
GrBackendObjectOwnership);
+ static GrRenderTargetFlags ComputeFlags(const GrVkCaps&);
+
GrVkGpu* getVkGpu() const;
void onAbandon() override;