Debian Codegraph @

src/gpu/ganesh/d3d/GrD3DCommandSignature.cpp

raw
1 /*
2 * Copyright 2020 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "src/gpu/ganesh/d3d/GrD3DCommandSignature.h"
9
10 #include "src/gpu/ganesh/d3d/GrD3DGpu.h"
11
12 sk_sp<GrD3DCommandSignature> GrD3DCommandSignature::Make(GrD3DGpu* gpu, ForIndexed forIndexed,
13 unsigned int slot) {
14 bool indexed = (forIndexed == ForIndexed::kYes);
15 D3D12_INDIRECT_ARGUMENT_DESC argumentDesc = {};
16 argumentDesc.Type = indexed ? D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED
17 : D3D12_INDIRECT_ARGUMENT_TYPE_DRAW;
18 argumentDesc.VertexBuffer.Slot = slot;
19
20 D3D12_COMMAND_SIGNATURE_DESC commandSigDesc = {};
21 commandSigDesc.ByteStride = indexed ? sizeof(D3D12_DRAW_INDEXED_ARGUMENTS)
22 : sizeof(D3D12_DRAW_ARGUMENTS);
23 commandSigDesc.NumArgumentDescs = 1;
24 commandSigDesc.pArgumentDescs = &argumentDesc;
25 commandSigDesc.NodeMask = 0;
26
27 gr_cp<ID3D12CommandSignature> commandSig;
28 HRESULT hr = gpu->device()->CreateCommandSignature(&commandSigDesc, nullptr,
29 IID_PPV_ARGS(&commandSig));
30 if (!SUCCEEDED(hr)) {
31 SkDebugf("Failed to create command signature.\n");
32 return nullptr;
33 }
34
35 return sk_sp<GrD3DCommandSignature>(new GrD3DCommandSignature(std::move(commandSig),
36 forIndexed, slot));
37 }