Add more flexibility to GrVkRT to support DMSAA.

Support is added so we can differentiate between using discardable
msaa for normal msaa draws and using it for DMSAA. Before this
many asserts and checks throughout GrVk* assumed we could only have
discardable msaa if the actual render target was msaa.

After this change the only thing missing to enable DMSAA on Vulkan
is to fix GrProgramInfo to store the actual sample count the program
will use instead of the same count of the GrRenderTarget.

Change-Id: Ifdb9a3beb641f96f6dfebe3241ccc5a2c8770bb3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441517
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrProgramInfo.h b/src/gpu/GrProgramInfo.h
index df0cb21..3d63f30 100644
--- a/src/gpu/GrProgramInfo.h
+++ b/src/gpu/GrProgramInfo.h
@@ -28,10 +28,12 @@
             , fNeedsStencil(targetView.asRenderTargetProxy()->needsStencil())
             , fBackendFormat(targetView.proxy()->backendFormat())
             , fOrigin(targetView.origin())
-            , fTargetSupportsVkResolveLoad(
-                      targetView.asRenderTargetProxy()->numSamples() > 1 &&
-                      targetView.asTextureProxy() &&
-                      targetView.asRenderTargetProxy()->supportsVkInputAttachment())
+            , fTargetHasVkResolveAttachmentWithInput(
+                    targetView.asRenderTargetProxy()->supportsVkInputAttachment() &&
+                    ((targetView.asRenderTargetProxy()->numSamples() > 1 &&
+                     targetView.asTextureProxy()) ||
+                    targetView.asRenderTargetProxy()->numSamples() == 1))
+            , fTargetsNumSamples(targetView.asRenderTargetProxy()->numSamples())
             , fPipeline(pipeline)
             , fUserStencilSettings(userStencilSettings)
             , fGeomProc(geomProc)
@@ -54,7 +56,7 @@
     const GrUserStencilSettings* userStencilSettings() const { return fUserStencilSettings; }
     // The backend format of the destination render target [proxy]
     const GrBackendFormat& backendFormat() const { return fBackendFormat; }
-    GrSurfaceOrigin origin() const { return fOrigin;  }
+    GrSurfaceOrigin origin() const { return fOrigin; }
     const GrPipeline& pipeline() const { return *fPipeline; }
     const GrGeometryProcessor& geomProc() const { return *fGeomProc; }
 
@@ -64,7 +66,11 @@
         return fTessellationPatchVertexCount;
     }
 
-    bool targetSupportsVkResolveLoad() const { return fTargetSupportsVkResolveLoad; }
+    bool targetHasVkResolveAttachmentWithInput() const {
+        return fTargetHasVkResolveAttachmentWithInput;
+    }
+
+    int targetsNumSamples() const { return fTargetsNumSamples; }
 
     GrXferBarrierFlags renderPassBarriers() const { return fRenderPassXferBarriers; }
 
@@ -89,11 +95,12 @@
 #endif
 
 private:
-    const int                             fNumSamples;
+    int                                   fNumSamples;
     const bool                            fNeedsStencil;
     const GrBackendFormat                 fBackendFormat;
     const GrSurfaceOrigin                 fOrigin;
-    const bool                            fTargetSupportsVkResolveLoad;
+    bool                                  fTargetHasVkResolveAttachmentWithInput;
+    int                                   fTargetsNumSamples;
     const GrPipeline*                     fPipeline;
     const GrUserStencilSettings*          fUserStencilSettings;
     const GrGeometryProcessor*            fGeomProc;