Add d3d support for creating command lists.

Currently we only can create direct command lists and we also don't cache anything.

Change also has so minor fixes to GMs allowing the d3d backend to run through all
GMs without crashing (though not actually drawing anything).

Bug: skia:9935
Change-Id: Ibf378e522d2e49bf342c709eb93d6fca4d43eac9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/276097
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2020-03-09 15:18:35 -04:00 committed by Skia Commit-Bot
parent 4054061b0b
commit 85da3368c5
8 changed files with 52 additions and 18 deletions

View File

@ -84,6 +84,9 @@ DEF_SIMPLE_GPU_GM_BG(fpcoordinateoverride, ctx, rtCtx, canvas, 512, 512,
GetResourceAsBitmap("images/mandrill_512_q075.jpg", &bmp);
GrBitmapTextureMaker maker(ctx, bmp);
auto view = maker.view(GrMipMapped::kNo);
if (!view) {
return;
}
std::unique_ptr<GrFragmentProcessor> imgFP =
GrTextureEffect::Make(std::move(view), bmp.alphaType(), SkMatrix());
auto fp = std::unique_ptr<GrFragmentProcessor>(new SampleCoordEffect(std::move(imgFP)));

View File

@ -280,6 +280,9 @@ protected:
mainImage = fMainImage;
auxImage = fAuxImage;
}
if (!mainImage || !auxImage) {
return;
}
SkASSERT(mainImage && (mainImage->isTextureBacked() || !canvas->getGrContext()));
SkASSERT(auxImage && (auxImage->isTextureBacked() || !canvas->getGrContext()));

View File

@ -1517,25 +1517,26 @@ protected:
canvas->drawImage(raster, x, y);
y += kTileWidthHeight + kPad;
auto yuv = fImages[opaque][tagged]->makeColorSpace(fTargetColorSpace);
SkASSERT(SkColorSpace::Equals(yuv->colorSpace(), fTargetColorSpace.get()));
canvas->drawImage(yuv, x, y);
y += kTileWidthHeight + kPad;
if (fImages[opaque][tagged]) {
auto yuv = fImages[opaque][tagged]->makeColorSpace(fTargetColorSpace);
SkASSERT(SkColorSpace::Equals(yuv->colorSpace(), fTargetColorSpace.get()));
canvas->drawImage(yuv, x, y);
y += kTileWidthHeight + kPad;
auto subset = yuv->makeSubset(SkIRect::MakeWH(kTileWidthHeight / 2,
kTileWidthHeight / 2));
canvas->drawImage(subset, x, y);
y += kTileWidthHeight + kPad;
auto subset = yuv->makeSubset(SkIRect::MakeWH(kTileWidthHeight / 2,
kTileWidthHeight / 2));
canvas->drawImage(subset, x, y);
y += kTileWidthHeight + kPad;
auto nonTexture = yuv->makeNonTextureImage();
canvas->drawImage(nonTexture, x, y);
y += kTileWidthHeight + kPad;
SkBitmap readBack;
readBack.allocPixels(yuv->imageInfo());
yuv->readPixels(readBack.pixmap(), 0, 0);
canvas->drawBitmap(readBack, x, y);
auto nonTexture = yuv->makeNonTextureImage();
canvas->drawImage(nonTexture, x, y);
y += kTileWidthHeight + kPad;
SkBitmap readBack;
readBack.allocPixels(yuv->imageInfo());
yuv->readPixels(readBack.pixmap(), 0, 0);
canvas->drawBitmap(readBack, x, y);
}
x += kTileWidthHeight + kPad;
}
}

View File

@ -275,6 +275,10 @@ bool GrBackendFormat::operator==(const GrBackendFormat& that) const {
case GrBackendApi::kMock:
return fMock.fColorType == that.fMock.fColorType &&
fMock.fCompressionType == that.fMock.fCompressionType;
#ifdef SK_DIRECT3D
case GrBackendApi::kDirect3D:
return fDxgiFormat == that.fDxgiFormat;
#endif
default:
SK_ABORT("Unknown GrBackend");
}

View File

@ -25,6 +25,9 @@ GrD3DGpu::GrD3DGpu(GrContext* context, const GrContextOptions& contextOptions,
fCaps.reset(new GrD3DCaps(contextOptions,
backendContext.fAdapter.Get(),
backendContext.fDevice.Get()));
fCurrentDirectCommandList = fResourceProvider.findOrCreateDirectCommandList();
SkASSERT(fCurrentDirectCommandList.Get());
}
GrD3DGpu::~GrD3DGpu() {}

View File

@ -176,6 +176,8 @@ private:
GrD3DResourceProvider fResourceProvider;
gr_cp<ID3D12CommandList> fCurrentDirectCommandList;
std::unique_ptr<GrD3DOpsRenderPass> fCachedOpsRenderPass;
typedef GrGpu INHERITED;

View File

@ -9,4 +9,18 @@
#include "src/gpu/d3d/GrD3DGpu.h"
GrD3DResourceProvider::GrD3DResourceProvider(GrD3DGpu* gpu) /*: fGpu(gpu)*/ {}
GrD3DResourceProvider::GrD3DResourceProvider(GrD3DGpu* gpu) : fGpu(gpu) {
SkDEBUGCODE(HRESULT hr = ) gpu->device()->CreateCommandAllocator(
D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&fDirectCommandAllocator));
SkASSERT(SUCCEEDED(hr));
}
gr_cp<ID3D12GraphicsCommandList> GrD3DResourceProvider::findOrCreateDirectCommandList() {
gr_cp<ID3D12GraphicsCommandList> commandList;
SkDEBUGCODE(HRESULT hr = ) fGpu->device()->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT,
fDirectCommandAllocator.Get(), nullptr, IID_PPV_ARGS(&commandList));
SkASSERT(SUCCEEDED(hr));
return commandList;
}

View File

@ -16,8 +16,12 @@ class GrD3DResourceProvider {
public:
GrD3DResourceProvider(GrD3DGpu*);
gr_cp<ID3D12GraphicsCommandList> findOrCreateDirectCommandList();
private:
// GrD3DGpu* fGpu;
gr_cp<ID3D12CommandAllocator> fDirectCommandAllocator;
GrD3DGpu* fGpu;
};
#endif