Add GrD3DCommandList class.

This doesn't do much except creates the new class.

Change-Id: I157abaddd173bf1b6ab5eba2539e90c4d530a273
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/278469
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2020-03-23 14:18:37 -04:00 committed by Skia Commit-Bot
parent 0b22f3bc53
commit e52c9784f0
7 changed files with 110 additions and 11 deletions

View File

@ -737,6 +737,8 @@ skia_direct3d_sources = [
"$_src/gpu/d3d/GrD3D12.h",
"$_src/gpu/d3d/GrD3DCaps.cpp",
"$_src/gpu/d3d/GrD3DCaps.h",
"$_src/gpu/d3d/GrD3DCommandList.cpp",
"$_src/gpu/d3d/GrD3DCommandList.h",
"$_src/gpu/d3d/GrD3DGpu.cpp",
"$_src/gpu/d3d/GrD3DGpu.h",
"$_src/gpu/d3d/GrD3DOpsRenderPass.cpp",

View File

@ -0,0 +1,51 @@
/*
* Copyright 2020 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "src/gpu/d3d/GrD3DCommandList.h"
#include "src/gpu/d3d/GrD3DGpu.h"
GrD3DCommandList::GrD3DCommandList(gr_cp<ID3D12GraphicsCommandList> commandList)
: fCommandList(std::move(commandList)) {
}
////////////////////////////////////////////////////////////////////////////////////////////////////
std::unique_ptr<GrD3DDirectCommandList> GrD3DDirectCommandList::Make(
ID3D12Device* device, ID3D12CommandAllocator* cmdAllocator) {
gr_cp<ID3D12GraphicsCommandList> commandList;
SkDEBUGCODE(HRESULT hr = ) device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT,
cmdAllocator, nullptr,
IID_PPV_ARGS(&commandList));
SkASSERT(SUCCEEDED(hr));
auto grCL = new GrD3DDirectCommandList(std::move(commandList));
return std::unique_ptr<GrD3DDirectCommandList>(grCL);
}
GrD3DDirectCommandList::GrD3DDirectCommandList(gr_cp<ID3D12GraphicsCommandList> commandList)
: GrD3DCommandList(std::move(commandList)) {
}
////////////////////////////////////////////////////////////////////////////////////////////////////
std::unique_ptr<GrD3DCopyCommandList> GrD3DCopyCommandList::Make(
ID3D12Device* device, ID3D12CommandAllocator* cmdAllocator) {
gr_cp<ID3D12GraphicsCommandList> commandList;
SkDEBUGCODE(HRESULT hr = ) device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_COPY,
cmdAllocator, nullptr,
IID_PPV_ARGS(&commandList));
SkASSERT(SUCCEEDED(hr));
auto grCL = new GrD3DCopyCommandList(std::move(commandList));
return std::unique_ptr<GrD3DCopyCommandList>(grCL);
}
GrD3DCopyCommandList::GrD3DCopyCommandList(gr_cp<ID3D12GraphicsCommandList> commandList)
: GrD3DCommandList(std::move(commandList)) {
}

View File

@ -0,0 +1,45 @@
/*
* Copyright 2020 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrD3DCommandList_DEFINED
#define GrD3DCommandList_DEFINED
#include "include/gpu/GrTypes.h"
#include "src/gpu/d3d/GrD3D12.h"
#include <memory>
class GrD3DGpu;
class GrD3DCommandList {
public:
protected:
GrD3DCommandList(gr_cp<ID3D12GraphicsCommandList> commandList);
private:
gr_cp<ID3D12CommandList> fCommandList;
};
class GrD3DDirectCommandList : public GrD3DCommandList {
public:
static std::unique_ptr<GrD3DDirectCommandList> Make(ID3D12Device* device,
ID3D12CommandAllocator* cmdAllocator);
private:
GrD3DDirectCommandList(gr_cp<ID3D12GraphicsCommandList> commandList);
};
class GrD3DCopyCommandList : public GrD3DCommandList {
public:
static std::unique_ptr<GrD3DCopyCommandList> Make(ID3D12Device* device,
ID3D12CommandAllocator* cmdAllocator);
private:
GrD3DCopyCommandList(gr_cp<ID3D12GraphicsCommandList> commandList);
};
#endif

View File

@ -27,7 +27,7 @@ GrD3DGpu::GrD3DGpu(GrContext* context, const GrContextOptions& contextOptions,
backendContext.fDevice.Get()));
fCurrentDirectCommandList = fResourceProvider.findOrCreateDirectCommandList();
SkASSERT(fCurrentDirectCommandList.Get());
SkASSERT(fCurrentDirectCommandList);
}
GrD3DGpu::~GrD3DGpu() {}

View File

@ -13,6 +13,7 @@
#include "src/gpu/GrRenderTarget.h"
#include "src/gpu/GrSemaphore.h"
#include "src/gpu/d3d/GrD3DCaps.h"
#include "src/gpu/d3d/GrD3DCommandList.h"
#include "src/gpu/d3d/GrD3DResourceProvider.h"
class GrD3DOpsRenderPass;
@ -171,12 +172,14 @@ private:
GrProtected,
const BackendTextureData*) override;
void submitDirectCommandList();
gr_cp<ID3D12Device> fDevice;
gr_cp<ID3D12CommandQueue> fQueue;
GrD3DResourceProvider fResourceProvider;
gr_cp<ID3D12CommandList> fCurrentDirectCommandList;
std::unique_ptr<GrD3DDirectCommandList> fCurrentDirectCommandList;
std::unique_ptr<GrD3DOpsRenderPass> fCachedOpsRenderPass;

View File

@ -7,6 +7,7 @@
#include "src/gpu/d3d/GrD3DResourceProvider.h"
#include "src/gpu/d3d/GrD3DCommandList.h"
#include "src/gpu/d3d/GrD3DGpu.h"
GrD3DResourceProvider::GrD3DResourceProvider(GrD3DGpu* gpu) : fGpu(gpu) {
@ -15,12 +16,6 @@ GrD3DResourceProvider::GrD3DResourceProvider(GrD3DGpu* gpu) : fGpu(gpu) {
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;
std::unique_ptr<GrD3DDirectCommandList> GrD3DResourceProvider::findOrCreateDirectCommandList() {
return GrD3DDirectCommandList::Make(fGpu->device(), fDirectCommandAllocator.Get());
}

View File

@ -10,13 +10,16 @@
#include "src/gpu/d3d/GrD3D12.h"
#include <memory>
class GrD3DDirectCommandList;
class GrD3DGpu;
class GrD3DResourceProvider {
public:
GrD3DResourceProvider(GrD3DGpu*);
gr_cp<ID3D12GraphicsCommandList> findOrCreateDirectCommandList();
std::unique_ptr<GrD3DDirectCommandList> findOrCreateDirectCommandList();
private:
gr_cp<ID3D12CommandAllocator> fDirectCommandAllocator;