diff options
author | Jim Van Verth <jvanverth@google.com> | 2017-11-02 16:56:09 +0000 |
---|---|---|
committer | Jim Van Verth <jvanverth@google.com> | 2017-11-02 16:56:19 +0000 |
commit | 6a40abc8c7e158e6be34c836f6ea1bbf7b498146 (patch) | |
tree | 6a74566b8ca660b65b2457ba42620a9e93331012 | |
parent | 2b17f64694c4b919f8ea5dff5a81813f435fb410 (diff) |
Revert "Implement window rectangles in vulkan"
This reverts commit 94c0468b2b4255e3beed81efdcfbf6d9d39e11e4.
Reason for revert: <INSERT REASONING HERE>
Original change's description:
> Implement window rectangles in vulkan
>
> Bug: skia:
> Change-Id: I32c079b90a5503c797dfc073a093f940cd8c550a
> Reviewed-on: https://skia-review.googlesource.com/65423
> Commit-Queue: Chris Dalton <csmartdalton@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,csmartdalton@google.com
Change-Id: I5a90cb57fb5d4bcf8c7e76a5f71a7f16edbaf6be
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/67060
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
32 files changed, 86 insertions, 418 deletions
diff --git a/gm/windowrectangles.cpp b/gm/windowrectangles.cpp index 034b30f880..b4f6562985 100644 --- a/gm/windowrectangles.cpp +++ b/gm/windowrectangles.cpp @@ -256,7 +256,7 @@ void WindowRectanglesMaskGM::stencilCheckerboard(GrRenderTargetContext* rtc, boo 0>() ); - rtc->priv().clearStencilClip(GrFixedClip::Disabled(), false, true); + rtc->priv().clearStencilClip(GrFixedClip::Disabled(), false); for (int y = 0; y < kDeviceRect.height(); y += kMaskCheckerSize) { for (int x = (y & 1) == flip ? 0 : kMaskCheckerSize; diff --git a/include/gpu/GrCaps.h b/include/gpu/GrCaps.h index 5579557e64..0b4c2e7ee5 100644 --- a/include/gpu/GrCaps.h +++ b/include/gpu/GrCaps.h @@ -126,14 +126,6 @@ public: bool reuseScratchTextures() const { return fReuseScratchTextures; } bool reuseScratchBuffers() const { return fReuseScratchBuffers; } - enum class WindowRectsSupport { - kNone, - kDrawOnly, - kDrawAndClear - }; - - WindowRectsSupport windowRectsSupport() const { return fWindowRectsSupport; } - /// maximum number of attribute values per vertex int maxVertexAttributes() const { return fMaxVertexAttributes; } @@ -242,8 +234,6 @@ protected: uint32_t fMapBufferFlags; int fBufferMapThreshold; - WindowRectsSupport fWindowRectsSupport; - int fMaxRenderTargetSize; int fMaxVertexAttributes; int fMaxTextureSize; diff --git a/include/gpu/vk/GrVkBackendContext.h b/include/gpu/vk/GrVkBackendContext.h index 4b93313a74..68791ba945 100644 --- a/include/gpu/vk/GrVkBackendContext.h +++ b/include/gpu/vk/GrVkBackendContext.h @@ -14,15 +14,13 @@ #include "vk/GrVkInterface.h" enum GrVkExtensionFlags { - kKHR_get_physical_device_properties2_GrVkExtensionFlag = 0x0001, - kEXT_debug_report_GrVkExtensionFlag = 0x0002, - kNV_glsl_shader_GrVkExtensionFlag = 0x0004, - kKHR_surface_GrVkExtensionFlag = 0x0008, - kEXT_discard_rectangles_GrVkExtensionFlag = 0x0010, - kKHR_swapchain_GrVkExtensionFlag = 0x0020, - kKHR_win32_surface_GrVkExtensionFlag = 0x0040, - kKHR_android_surface_GrVkExtensionFlag = 0x0080, - kKHR_xcb_surface_GrVkExtensionFlag = 0x0100, + kEXT_debug_report_GrVkExtensionFlag = 0x0001, + kNV_glsl_shader_GrVkExtensionFlag = 0x0002, + kKHR_surface_GrVkExtensionFlag = 0x0004, + kKHR_swapchain_GrVkExtensionFlag = 0x0008, + kKHR_win32_surface_GrVkExtensionFlag = 0x0010, + kKHR_android_surface_GrVkExtensionFlag = 0x0020, + kKHR_xcb_surface_GrVkExtensionFlag = 0x0040, }; enum GrVkFeatureFlags { diff --git a/include/gpu/vk/GrVkDefines.h b/include/gpu/vk/GrVkDefines.h index 5873f9924f..0bc6fb0343 100644 --- a/include/gpu/vk/GrVkDefines.h +++ b/include/gpu/vk/GrVkDefines.h @@ -38,130 +38,6 @@ #error "Vulkan header version is too low" #endif -#ifndef VK_KHR_get_physical_device_properties2 - -// Installed Vulkan SDK is too old to define VK_KHR_get_physical_device_properties2: define it here. -#define VK_KHR_get_physical_device_properties2 1 -#define VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_SPEC_VERSION 1 -#define VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME "VK_KHR_get_physical_device_properties2" - -typedef struct VkPhysicalDeviceFeatures2KHR { - VkStructureType sType; - void* pNext; - VkPhysicalDeviceFeatures features; -} VkPhysicalDeviceFeatures2KHR; - -typedef struct VkPhysicalDeviceProperties2KHR { - VkStructureType sType; - void* pNext; - VkPhysicalDeviceProperties properties; -} VkPhysicalDeviceProperties2KHR; - -typedef struct VkFormatProperties2KHR { - VkStructureType sType; - void* pNext; - VkFormatProperties formatProperties; -} VkFormatProperties2KHR; - -typedef struct VkImageFormatProperties2KHR { - VkStructureType sType; - void* pNext; - VkImageFormatProperties imageFormatProperties; -} VkImageFormatProperties2KHR; - -typedef struct VkPhysicalDeviceImageFormatInfo2KHR { - VkStructureType sType; - const void* pNext; - VkFormat format; - VkImageType type; - VkImageTiling tiling; - VkImageUsageFlags usage; - VkImageCreateFlags flags; -} VkPhysicalDeviceImageFormatInfo2KHR; - -typedef struct VkQueueFamilyProperties2KHR { - VkStructureType sType; - void* pNext; - VkQueueFamilyProperties queueFamilyProperties; -} VkQueueFamilyProperties2KHR; - -typedef struct VkPhysicalDeviceMemoryProperties2KHR { - VkStructureType sType; - void* pNext; - VkPhysicalDeviceMemoryProperties memoryProperties; -} VkPhysicalDeviceMemoryProperties2KHR; - -typedef struct VkSparseImageFormatProperties2KHR { - VkStructureType sType; - void* pNext; - VkSparseImageFormatProperties properties; -} VkSparseImageFormatProperties2KHR; - -typedef struct VkPhysicalDeviceSparseImageFormatInfo2KHR { - VkStructureType sType; - const void* pNext; - VkFormat format; - VkImageType type; - VkSampleCountFlagBits samples; - VkImageUsageFlags usage; - VkImageTiling tiling; -} VkPhysicalDeviceSparseImageFormatInfo2KHR; - - -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFeatures2KHR)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2KHR* pFeatures); -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceProperties2KHR)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2KHR* pProperties); -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFormatProperties2KHR)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2KHR* pFormatProperties); -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2KHR* pImageFormatInfo, VkImageFormatProperties2KHR* pImageFormatProperties); -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR)(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties2KHR* pQueueFamilyProperties); -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceMemoryProperties2KHR)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2KHR* pMemoryProperties); -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2KHR* pFormatInfo, uint32_t* pPropertyCount, VkSparseImageFormatProperties2KHR* pProperties); - -static constexpr VkStructureType VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR = (VkStructureType) 1000059001; - -#endif // !VK_KHR_get_physical_device_properties2 - -#ifndef VK_EXT_discard_rectangles - -// Installed Vulkan SDK is too old to define discard rectangles: define them here. -#define VK_EXT_discard_rectangles 1 -#define VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION 1 -#define VK_EXT_DISCARD_RECTANGLES_EXTENSION_NAME "VK_EXT_discard_rectangles" - -typedef enum VkDiscardRectangleModeEXT { - VK_DISCARD_RECTANGLE_MODE_INCLUSIVE_EXT = 0, - VK_DISCARD_RECTANGLE_MODE_EXCLUSIVE_EXT = 1, - VK_DISCARD_RECTANGLE_MODE_BEGIN_RANGE_EXT = VK_DISCARD_RECTANGLE_MODE_INCLUSIVE_EXT, - VK_DISCARD_RECTANGLE_MODE_END_RANGE_EXT = VK_DISCARD_RECTANGLE_MODE_EXCLUSIVE_EXT, - VK_DISCARD_RECTANGLE_MODE_RANGE_SIZE_EXT = (VK_DISCARD_RECTANGLE_MODE_EXCLUSIVE_EXT - VK_DISCARD_RECTANGLE_MODE_INCLUSIVE_EXT + 1), - VK_DISCARD_RECTANGLE_MODE_MAX_ENUM_EXT = 0x7FFFFFFF -} VkDiscardRectangleModeEXT; - -typedef VkFlags VkPipelineDiscardRectangleStateCreateFlagsEXT; - -typedef struct VkPhysicalDeviceDiscardRectanglePropertiesEXT { - VkStructureType sType; - const void* pNext; - uint32_t maxDiscardRectangles; -} VkPhysicalDeviceDiscardRectanglePropertiesEXT; - -typedef struct VkPipelineDiscardRectangleStateCreateInfoEXT { - VkStructureType sType; - const void* pNext; - VkPipelineDiscardRectangleStateCreateFlagsEXT flags; - VkDiscardRectangleModeEXT discardRectangleMode; - uint32_t discardRectangleCount; - const VkRect2D* pDiscardRectangles; -} VkPipelineDiscardRectangleStateCreateInfoEXT; - - -typedef void (VKAPI_PTR *PFN_vkCmdSetDiscardRectangleEXT)(VkCommandBuffer commandBuffer, uint32_t firstDiscardRectangle, uint32_t discardRectangleCount, const VkRect2D* pDiscardRectangles); - -static constexpr VkStructureType VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DISCARD_RECTANGLE_PROPERTIES_EXT = (VkStructureType) 1000099000; -static constexpr VkStructureType VK_STRUCTURE_TYPE_PIPELINE_DISCARD_RECTANGLE_STATE_CREATE_INFO_EXT = (VkStructureType) 1000099001; -static constexpr VkDynamicState VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT = (VkDynamicState) 1000099000; - -#endif // !VK_EXT_discard_rectangles - -#endif // SK_VULKAN +#endif -#endif // GrVkDefines_DEFINED +#endif diff --git a/include/gpu/vk/GrVkInterface.h b/include/gpu/vk/GrVkInterface.h index a56df31cb2..05ce561829 100644 --- a/include/gpu/vk/GrVkInterface.h +++ b/include/gpu/vk/GrVkInterface.h @@ -203,13 +203,9 @@ public: VkPtr<PFN_vkCmdEndRenderPass> fCmdEndRenderPass; VkPtr<PFN_vkCmdExecuteCommands> fCmdExecuteCommands; - VkPtr<PFN_vkGetPhysicalDeviceProperties2KHR> fGetPhysicalDeviceProperties2KHR; - VkPtr<PFN_vkCreateDebugReportCallbackEXT> fCreateDebugReportCallbackEXT; VkPtr<PFN_vkDebugReportMessageEXT> fDebugReportMessageEXT; VkPtr<PFN_vkDestroyDebugReportCallbackEXT> fDestroyDebugReportCallbackEXT; - - VkPtr<PFN_vkCmdSetDiscardRectangleEXT> fCmdSetDiscardRectangleEXT; } fFunctions; }; diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp index 9705320fb0..2e25845876 100644 --- a/src/gpu/GrCaps.cpp +++ b/src/gpu/GrCaps.cpp @@ -61,8 +61,6 @@ GrCaps::GrCaps(const GrContextOptions& options) { fMapBufferFlags = kNone_MapFlags; - fWindowRectsSupport = WindowRectsSupport::kNone; - fMaxVertexAttributes = 0; fMaxRenderTargetSize = 1; fMaxTextureSize = 1; @@ -196,14 +194,6 @@ void GrCaps::dumpJSON(SkJSONWriter* writer) const { SkASSERT(!this->isConfigRenderable(kUnknown_GrPixelConfig, true)); SkASSERT(!this->isConfigTexturable(kUnknown_GrPixelConfig)); - const char* windowRectsSupportName = "<invalid>"; - switch (fWindowRectsSupport) { - case WindowRectsSupport::kNone: windowRectsSupportName = "None"; break; - case WindowRectsSupport::kDrawOnly: windowRectsSupportName = "DrawOnly"; break; - case WindowRectsSupport::kDrawAndClear: windowRectsSupportName = "DrawAndClear"; break; - } - writer->appendString("Window Rectangles Support", windowRectsSupportName); - writer->beginArray("configs"); for (size_t i = 1; i < kGrPixelConfigCnt; ++i) { diff --git a/src/gpu/GrGpuCommandBuffer.h b/src/gpu/GrGpuCommandBuffer.h index 92d520439a..6963d23ebe 100644 --- a/src/gpu/GrGpuCommandBuffer.h +++ b/src/gpu/GrGpuCommandBuffer.h @@ -108,7 +108,7 @@ public: virtual void inlineUpload(GrOpFlushState*, GrDeferredTextureUploadFn&) = 0; /** - * Clear the owned render target. + * Clear the owned render target. Ignores the draw state and clip. */ void clear(const GrFixedClip&, GrColor); diff --git a/src/gpu/GrReducedClip.cpp b/src/gpu/GrReducedClip.cpp index d69a05450a..bc3286bdf0 100644 --- a/src/gpu/GrReducedClip.cpp +++ b/src/gpu/GrReducedClip.cpp @@ -744,7 +744,7 @@ bool GrReducedClip::drawStencilClipMask(GrContext* context, } bool initialState = InitialState::kAllIn == this->initialState(); - renderTargetContext->priv().clearStencilClip(stencilClip.fixedClip(), initialState, true); + renderTargetContext->priv().clearStencilClip(stencilClip.fixedClip(), initialState); // walk through each clip element and perform its set op with the existing clip. for (ElementList::Iter iter(fMaskElements); iter.get(); iter.next()) { diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp index a361190c81..585a5126a9 100644 --- a/src/gpu/GrRenderTarget.cpp +++ b/src/gpu/GrRenderTarget.cpp @@ -28,7 +28,7 @@ GrRenderTarget::GrRenderTarget(GrGpu* gpu, const GrSurfaceDesc& desc, SkASSERT(desc.fFlags & kRenderTarget_GrSurfaceFlag); SkASSERT(!(fFlags & GrRenderTargetFlags::kMixedSampled) || fSampleCnt > 0); SkASSERT(!(fFlags & GrRenderTargetFlags::kWindowRectsSupport) || - GrCaps::WindowRectsSupport::kNone != gpu->caps()->windowRectsSupport()); + gpu->caps()->maxWindowRectangles() > 0); fResolveRect.setLargestInverted(); } diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index faa0dbbb69..e1ce24c886 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -345,8 +345,7 @@ void GrRenderTargetContext::internalClear(const GrFixedClip& clip, if (isFull) { this->getRTOpList()->fullClear(*this->caps(), color); } else { - std::unique_ptr<GrOp> op(GrClearOp::Make(clip, color, canIgnoreClip, this->asSurfaceProxy(), - *fContext->caps())); + std::unique_ptr<GrOp> op(GrClearOp::Make(clip, color, this->asSurfaceProxy())); if (!op) { return; } @@ -606,8 +605,7 @@ int GrRenderTargetContextPriv::maxWindowRectangles() const { *fRenderTargetContext->fContext->caps()); } -void GrRenderTargetContextPriv::clearStencilClip(const GrFixedClip& clip, bool insideStencilMask, - bool canIgnoreClip) { +void GrRenderTargetContextPriv::clearStencilClip(const GrFixedClip& clip, bool insideStencilMask) { ASSERT_SINGLE_OWNER_PRIV RETURN_IF_ABANDONED_PRIV SkDEBUGCODE(fRenderTargetContext->validate();) @@ -617,9 +615,8 @@ void GrRenderTargetContextPriv::clearStencilClip(const GrFixedClip& clip, bool i AutoCheckFlush acf(fRenderTargetContext->drawingManager()); std::unique_ptr<GrOp> op(GrClearStencilClipOp::Make( - clip, insideStencilMask, canIgnoreClip, - fRenderTargetContext->fRenderTargetProxy.get(), - *fRenderTargetContext->fContext->caps())); + clip, insideStencilMask, + fRenderTargetContext->fRenderTargetProxy.get())); if (!op) { return; } diff --git a/src/gpu/GrRenderTargetContextPriv.h b/src/gpu/GrRenderTargetContextPriv.h index a7f00706f2..2cfd5c8679 100644 --- a/src/gpu/GrRenderTargetContextPriv.h +++ b/src/gpu/GrRenderTargetContextPriv.h @@ -44,7 +44,7 @@ public: void clear(const GrFixedClip&, const GrColor, bool canIgnoreClip); - void clearStencilClip(const GrFixedClip&, bool insideStencilMask, bool canIgnoreClip); + void clearStencilClip(const GrFixedClip&, bool insideStencilMask); /* * Some portions of the code, which use approximate-match rendertargets (i.e., ImageFilters), diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp index dc1176cef5..09486c7c99 100644 --- a/src/gpu/GrRenderTargetOpList.cpp +++ b/src/gpu/GrRenderTargetOpList.cpp @@ -229,8 +229,7 @@ void GrRenderTargetOpList::fullClear(const GrCaps& caps, GrColor color) { return; } - std::unique_ptr<GrClearOp> op(GrClearOp::Make(GrFixedClip::Disabled(), color, true, - fTarget.get(), caps)); + std::unique_ptr<GrClearOp> op(GrClearOp::Make(GrFixedClip::Disabled(), color, fTarget.get())); if (!op) { return; } diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp index ebe7d7205f..9453ce8204 100644 --- a/src/gpu/GrRenderTargetProxy.cpp +++ b/src/gpu/GrRenderTargetProxy.cpp @@ -29,7 +29,7 @@ GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, const GrSurfaceDesc if (caps.usesMixedSamples() && fSampleCnt > 0) { fRenderTargetFlags |= GrRenderTargetFlags::kMixedSampled; } - if (GrCaps::WindowRectsSupport::kNone != caps.windowRectsSupport()) { + if (caps.maxWindowRectangles() > 0) { fRenderTargetFlags |= GrRenderTargetFlags::kWindowRectsSupport; } } diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 340e42ab9e..9a454ef2b7 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -559,7 +559,6 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, #endif if (ctxInfo.hasExtension("GL_EXT_window_rectangles")) { - fWindowRectsSupport = WindowRectsSupport::kDrawAndClear; GR_GL_GetIntegerv(gli, GR_GL_MAX_WINDOW_RECTANGLES, &fMaxWindowRectangles); } diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 79448e03fd..6b194f98f7 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -1749,12 +1749,9 @@ void GrGLGpu::flushWindowRectangles(const GrWindowRectsState& windowState, #ifndef USE_NSIGHT typedef GrWindowRectsState::Mode Mode; SkASSERT(!windowState.enabled() || rt->renderFBOID()); // Window rects can't be used on-screen. - SkASSERT(!windowState.enabled() || - GrCaps::WindowRectsSupport::kDrawAndClear == this->caps()->windowRectsSupport()); SkASSERT(windowState.numWindows() <= this->caps()->maxWindowRectangles()); - SkASSERT(this->caps()->maxWindowRectangles() <= GrWindowRectangles::kMaxWindows); - if (GrCaps::WindowRectsSupport::kNone == this->caps()->windowRectsSupport() || + if (!this->caps()->maxWindowRectangles() || fHWWindowRectsState.knownEqualTo(origin, rt->getViewport(), windowState)) { return; } @@ -1779,8 +1776,7 @@ void GrGLGpu::flushWindowRectangles(const GrWindowRectsState& windowState, void GrGLGpu::disableWindowRectangles() { #ifndef USE_NSIGHT - if (GrCaps::WindowRectsSupport::kNone == this->caps()->windowRectsSupport() || - fHWWindowRectsState.knownDisabled()) { + if (!this->caps()->maxWindowRectangles() || fHWWindowRectsState.knownDisabled()) { return; } GL_CALL(WindowRectangles(GR_GL_EXCLUSIVE, 0, nullptr)); diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp index ef69f3eca8..3aa632c44f 100644 --- a/src/gpu/gl/GrGLRenderTarget.cpp +++ b/src/gpu/gl/GrGLRenderTarget.cpp @@ -43,7 +43,7 @@ inline GrRenderTargetFlags GrGLRenderTarget::ComputeFlags(const GrGLCaps& glCaps SkASSERT(glCaps.usesMixedSamples() && idDesc.fRTFBOID); // FBO 0 can't be mixed sampled. flags |= GrRenderTargetFlags::kMixedSampled; } - if (GrCaps::WindowRectsSupport::kNone != glCaps.windowRectsSupport() && idDesc.fRTFBOID) { + if (glCaps.maxWindowRectangles() > 0 && idDesc.fRTFBOID) { flags |= GrRenderTargetFlags::kWindowRectsSupport; } return flags; diff --git a/src/gpu/ops/GrClearOp.cpp b/src/gpu/ops/GrClearOp.cpp index 9c1805a5d0..702edcc3da 100644 --- a/src/gpu/ops/GrClearOp.cpp +++ b/src/gpu/ops/GrClearOp.cpp @@ -7,21 +7,15 @@ #include "GrClearOp.h" -#include "GrCaps.h" #include "GrGpuCommandBuffer.h" #include "GrOpFlushState.h" #include "GrResourceProvider.h" -GrClearOp::GrClearOp(const GrFixedClip& clip, GrColor color, bool canIgnoreClip, - GrSurfaceProxy* proxy, const GrCaps& caps) : INHERITED(ClassID()) +GrClearOp::GrClearOp(const GrFixedClip& clip, GrColor color, GrSurfaceProxy* proxy) + : INHERITED(ClassID()) , fClip(clip) , fColor(color) { const SkIRect rtRect = SkIRect::MakeWH(proxy->width(), proxy->height()); - if (fClip.hasWindowRectangles() && - GrCaps::WindowRectsSupport::kDrawAndClear != caps.windowRectsSupport() && - canIgnoreClip) { - fClip.disableWindowRectangles(); - } if (fClip.scissorEnabled()) { // Don't let scissors extend outside the RT. This may improve op combining. if (!fClip.intersect(rtRect)) { diff --git a/src/gpu/ops/GrClearOp.h b/src/gpu/ops/GrClearOp.h index 4f6ee626a3..56ecb13a79 100644 --- a/src/gpu/ops/GrClearOp.h +++ b/src/gpu/ops/GrClearOp.h @@ -18,15 +18,13 @@ public: DEFINE_OP_CLASS_ID static std::unique_ptr<GrClearOp> Make(const GrFixedClip& clip, GrColor color, - bool canIgnoreClip, GrSurfaceProxy* dstProxy, - const GrCaps& caps) { + GrSurfaceProxy* dstProxy) { const SkIRect rect = SkIRect::MakeWH(dstProxy->width(), dstProxy->height()); if (clip.scissorEnabled() && !SkIRect::Intersects(clip.scissorRect(), rect)) { return nullptr; } - return std::unique_ptr<GrClearOp>( - new GrClearOp(clip, color, canIgnoreClip, dstProxy, caps)); + return std::unique_ptr<GrClearOp>(new GrClearOp(clip, color, dstProxy)); } static std::unique_ptr<GrClearOp> Make(const SkIRect& rect, GrColor color, @@ -56,8 +54,7 @@ public: void setColor(GrColor color) { fColor = color; } private: - GrClearOp(const GrFixedClip& clip, GrColor color, bool canIgnoreClip, GrSurfaceProxy* proxy, - const GrCaps&); + GrClearOp(const GrFixedClip& clip, GrColor color, GrSurfaceProxy* proxy); GrClearOp(const SkIRect& rect, GrColor color, bool fullScreen) : INHERITED(ClassID()) diff --git a/src/gpu/ops/GrClearStencilClipOp.h b/src/gpu/ops/GrClearStencilClipOp.h index 9f23a665d9..ffd2fd9b28 100644 --- a/src/gpu/ops/GrClearStencilClipOp.h +++ b/src/gpu/ops/GrClearStencilClipOp.h @@ -9,7 +9,6 @@ #define GrClearStencilClipOp_DEFINED #include "GrFixedClip.h" -#include "GrCaps.h" #include "GrGpuCommandBuffer.h" #include "GrOp.h" #include "GrOpFlushState.h" @@ -20,10 +19,8 @@ public: DEFINE_OP_CLASS_ID static std::unique_ptr<GrOp> Make(const GrFixedClip& clip, bool insideStencilMask, - bool canIgnoreClip, GrRenderTargetProxy* proxy, - const GrCaps& caps) { - return std::unique_ptr<GrOp>( - new GrClearStencilClipOp(clip, insideStencilMask, canIgnoreClip, proxy, caps)); + GrRenderTargetProxy* proxy) { + return std::unique_ptr<GrOp>(new GrClearStencilClipOp(clip, insideStencilMask, proxy)); } const char* name() const override { return "ClearStencilClip"; } @@ -42,16 +39,11 @@ public: } private: - GrClearStencilClipOp(const GrFixedClip& clip, bool insideStencilMask, bool canIgnoreClip, - GrRenderTargetProxy* proxy, const GrCaps& caps) + GrClearStencilClipOp(const GrFixedClip& clip, bool insideStencilMask, + GrRenderTargetProxy* proxy) : INHERITED(ClassID()) - , fInsideStencilMask(insideStencilMask) - , fClip(clip) { - if (fClip.hasWindowRectangles() && - GrCaps::WindowRectsSupport::kDrawAndClear != caps.windowRectsSupport() && - canIgnoreClip) { - fClip.disableWindowRectangles(); - } + , fClip(clip) + , fInsideStencilMask(insideStencilMask) { const SkRect& bounds = fClip.scissorEnabled() ? SkRect::Make(fClip.scissorRect()) : SkRect::MakeIWH(proxy->width(), proxy->height()); @@ -67,8 +59,8 @@ private: state->rtCommandBuffer()->clearStencilClip(fClip, fInsideStencilMask); } - const bool fInsideStencilMask; - GrFixedClip fClip; + const GrFixedClip fClip; + const bool fInsideStencilMask; typedef GrOp INHERITED; }; diff --git a/src/gpu/vk/GrVkBackendContext.cpp b/src/gpu/vk/GrVkBackendContext.cpp index a602a50f73..e473178223 100644 --- a/src/gpu/vk/GrVkBackendContext.cpp +++ b/src/gpu/vk/GrVkBackendContext.cpp @@ -76,10 +76,6 @@ 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])) { @@ -91,6 +87,7 @@ 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; @@ -226,10 +223,6 @@ 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 9f635e2f20..2b24205af8 100644 --- a/src/gpu/vk/GrVkCaps.cpp +++ b/src/gpu/vk/GrVkCaps.cpp @@ -75,30 +75,9 @@ 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)); - } - const VkPhysicalDeviceProperties& properties = khrProperties.properties; + VkPhysicalDeviceProperties properties; + GR_VK_CALL(vkInterface, GetPhysicalDeviceProperties(physDev, &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 ba19168b37..8a17a4f033 100644 --- a/src/gpu/vk/GrVkCommandBuffer.cpp +++ b/src/gpu/vk/GrVkCommandBuffer.cpp @@ -34,11 +34,6 @@ 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; } @@ -328,24 +323,6 @@ 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 cf6dc2a750..7d16242e6b 100644 --- a/src/gpu/vk/GrVkCommandBuffer.h +++ b/src/gpu/vk/GrVkCommandBuffer.h @@ -80,11 +80,6 @@ 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 @@ -172,7 +167,6 @@ 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 a14ce8c3e2..52dfede267 100644 --- a/src/gpu/vk/GrVkGpuCommandBuffer.cpp +++ b/src/gpu/vk/GrVkGpuCommandBuffer.cpp @@ -251,11 +251,10 @@ void GrVkGpuRTCommandBuffer::insertEventMarker(const char* msg) { } void GrVkGpuRTCommandBuffer::onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) { - CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo]; - - // We ignore window rectangles as they are not supported by Vulkan during clear. SkASSERT(!clip.hasWindowRectangles()); + CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo]; + GrStencilAttachment* sb = fRenderTarget->renderTargetPriv().getStencilAttachment(); // this should only be called internally when we know we have a // stencil buffer. @@ -314,7 +313,7 @@ void GrVkGpuRTCommandBuffer::onClearStencilClip(const GrFixedClip& clip, bool in void GrVkGpuRTCommandBuffer::onClear(const GrFixedClip& clip, GrColor color) { GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget); - // We ignore window rectangles as they are not supported by Vulkan during clear. + // parent class should never let us get here with no RT SkASSERT(!clip.hasWindowRectangles()); CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo]; @@ -528,7 +527,6 @@ 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(), @@ -538,13 +536,7 @@ GrVkPipelineState* GrVkGpuRTCommandBuffer::prepareDrawState(const GrPipeline& pi rt, pipeline.proxy()->origin(), pipeline.getScissorState().rect()); } - 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::SetDynamicViewportState(fGpu, cbInfo.currentCmdBuf(), rt); GrVkPipeline::SetDynamicBlendConstantState(fGpu, cbInfo.currentCmdBuf(), rt->config(), pipeline.getXferProcessor()); diff --git a/src/gpu/vk/GrVkInterface.cpp b/src/gpu/vk/GrVkInterface.cpp index 04589cd51b..dedc264136 100644 --- a/src/gpu/vk/GrVkInterface.cpp +++ b/src/gpu/vk/GrVkInterface.cpp @@ -59,11 +59,6 @@ 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); @@ -191,11 +186,6 @@ 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 @@ -348,12 +338,6 @@ 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 || @@ -361,13 +345,6 @@ 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 5891f4cb59..a247078f72 100644 --- a/src/gpu/vk/GrVkPipeline.cpp +++ b/src/gpu/vk/GrVkPipeline.cpp @@ -239,21 +239,6 @@ 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, @@ -424,21 +409,17 @@ static void setup_raster_state(const GrPipeline& pipeline, rasterInfo->lineWidth = 1.0f; } -static void setup_dynamic_state(const GrPipeline& pipeline, - VkPipelineDynamicStateCreateInfo* dynamicInfo, - SkSTArray<4, VkDynamicState>* dynamicStates) { +static void setup_dynamic_state(VkPipelineDynamicStateCreateInfo* dynamicInfo, + 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->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(); + 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; } GrVkPipeline* GrVkPipeline::Create(GrVkGpu* gpu, const GrPipeline& pipeline, @@ -477,9 +458,9 @@ GrVkPipeline* GrVkPipeline::Create(GrVkGpu* gpu, const GrPipeline& pipeline, VkPipelineRasterizationStateCreateInfo rasterInfo; setup_raster_state(pipeline, gpu->caps(), &rasterInfo); - SkSTArray<4, VkDynamicState> dynamicStates; + VkDynamicState dynamicStates[3]; VkPipelineDynamicStateCreateInfo dynamicInfo; - setup_dynamic_state(pipeline, &dynamicInfo, &dynamicStates); + setup_dynamic_state(&dynamicInfo, dynamicStates); VkGraphicsPipelineCreateInfo pipelineCreateInfo; memset(&pipelineCreateInfo, 0, sizeof(VkGraphicsPipelineCreateInfo)); @@ -503,15 +484,6 @@ 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, @@ -528,6 +500,31 @@ 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) { @@ -542,48 +539,6 @@ 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 ad77037c52..88c3d5f915 100644 --- a/src/gpu/vk/GrVkPipeline.h +++ b/src/gpu/vk/GrVkPipeline.h @@ -22,7 +22,6 @@ class GrStencilSettings; class GrVkCommandBuffer; class GrVkGpu; class GrVkRenderPass; -class GrWindowRectangles; struct SkIRect; class GrVkPipeline : public GrVkResource { @@ -40,12 +39,9 @@ public: VkPipeline pipeline() const { return fPipeline; } - static void SetDynamicViewportState(GrVkGpu*, GrVkCommandBuffer*, const GrRenderTarget*); static void SetDynamicScissorRectState(GrVkGpu*, GrVkCommandBuffer*, const GrRenderTarget*, GrSurfaceOrigin, SkIRect); - static void SetDynamicDiscardRectanglesState(GrVkGpu*, GrVkCommandBuffer*, - const GrRenderTarget*, GrSurfaceOrigin, - const GrWindowRectangles&); + static void SetDynamicViewportState(GrVkGpu*, GrVkCommandBuffer*, const GrRenderTarget*); static void SetDynamicBlendConstantState(GrVkGpu*, GrVkCommandBuffer*, GrPixelConfig, const GrXferProcessor&); diff --git a/src/gpu/vk/GrVkPipelineState.cpp b/src/gpu/vk/GrVkPipelineState.cpp index 5256c6dbcd..17197750ab 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 GrCaps& caps) { + const GrShaderCaps& caps) { if (!INHERITED::Build(desc, primProc, primitiveType == GrPrimitiveType::kPoints, pipeline, - *caps.shaderCaps())) { + caps)) { return false; } @@ -587,12 +587,5 @@ 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 0eb822a65b..2794b99d22 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 GrCaps&); + const GrShaderCaps&); private: typedef GrProgramDesc INHERITED; }; diff --git a/src/gpu/vk/GrVkPipelineStateCache.cpp b/src/gpu/vk/GrVkPipelineStateCache.cpp index 37dc4a6cf9..caffe05bd5 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())) { + primitiveType, *fGpu->caps()->shaderCaps())) { 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 d250ec6d61..27cb119efc 100644 --- a/src/gpu/vk/GrVkRenderTarget.cpp +++ b/src/gpu/vk/GrVkRenderTarget.cpp @@ -8,7 +8,6 @@ #include "GrVkRenderTarget.h" #include "GrRenderTargetPriv.h" -#include "GrVkCaps.h" #include "GrVkCommandBuffer.h" #include "GrVkFramebuffer.h" #include "GrVkGpu.h" @@ -33,7 +32,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, ComputeFlags(gpu->vkCaps())) + , GrRenderTarget(gpu, desc) , fColorAttachmentView(colorAttachmentView) , fMSAAImage(new GrVkImage(msaaInfo, GrBackendObjectOwnership::kOwned)) , fResolveAttachmentView(resolveAttachmentView) @@ -56,7 +55,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, ComputeFlags(gpu->vkCaps())) + , GrRenderTarget(gpu, desc) , fColorAttachmentView(colorAttachmentView) , fMSAAImage(new GrVkImage(msaaInfo, GrBackendObjectOwnership::kOwned)) , fResolveAttachmentView(resolveAttachmentView) @@ -76,7 +75,7 @@ GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu, GrBackendObjectOwnership ownership) : GrSurface(gpu, desc) , GrVkImage(info, ownership) - , GrRenderTarget(gpu, desc, ComputeFlags(gpu->vkCaps())) + , GrRenderTarget(gpu, desc) , fColorAttachmentView(colorAttachmentView) , fMSAAImage(nullptr) , fResolveAttachmentView(nullptr) @@ -96,7 +95,7 @@ GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu, GrBackendObjectOwnership ownership) : GrSurface(gpu, desc) , GrVkImage(info, ownership) - , GrRenderTarget(gpu, desc, ComputeFlags(gpu->vkCaps())) + , GrRenderTarget(gpu, desc) , fColorAttachmentView(colorAttachmentView) , fMSAAImage(nullptr) , fResolveAttachmentView(nullptr) @@ -106,14 +105,6 @@ 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 2ea065bc34..18a0bd3eea 100644 --- a/src/gpu/vk/GrVkRenderTarget.h +++ b/src/gpu/vk/GrVkRenderTarget.h @@ -15,7 +15,6 @@ #include "GrVkRenderPass.h" #include "GrVkResourceProvider.h" -class GrVkCaps; class GrVkCommandBuffer; class GrVkFramebuffer; class GrVkGpu; @@ -92,8 +91,6 @@ protected: const GrVkImageView* colorAttachmentView, GrBackendObjectOwnership); - static GrRenderTargetFlags ComputeFlags(const GrVkCaps&); - GrVkGpu* getVkGpu() const; void onAbandon() override; |