| 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 |
#ifndef GrD3DCommandSignature_DEFINED |
| 9 |
#define GrD3DCommandSignature_DEFINED |
| 10 |
|
| 11 |
#include "include/gpu/ganesh/d3d/GrD3DTypes.h" |
| 12 |
#include "src/gpu/ganesh/GrManagedResource.h" |
| 13 |
|
| 14 |
class GrD3DGpu; |
| 15 |
|
| 16 |
class GrD3DCommandSignature : public GrManagedResource { |
| 17 |
public: |
| 18 |
enum class ForIndexed : bool { |
| 19 |
kYes = true, |
| 20 |
kNo = false |
| 21 |
}; |
| 22 |
static sk_sp<GrD3DCommandSignature> Make(GrD3DGpu* gpu, ForIndexed indexed, unsigned int slot); |
| 23 |
|
| 24 |
bool isCompatible(ForIndexed indexed, unsigned int slot) const { |
| 25 |
return (fIndexed == indexed && fSlot == slot); |
| 26 |
} |
| 27 |
|
| 28 |
ID3D12CommandSignature* commandSignature() const { return fCommandSignature.get(); } |
| 29 |
|
| 30 |
#ifdef SK_TRACE_MANAGED_RESOURCES |
| 31 |
/** Output a human-readable dump of this resource's information |
| 32 |
*/ |
| 33 |
void dumpInfo() const override { |
| 34 |
SkDebugf("GrD3DCommandSignature: %p, (%d refs)\n", |
| 35 |
fCommandSignature.get(), this->getRefCnt()); |
| 36 |
} |
| 37 |
#endif |
| 38 |
|
| 39 |
private: |
| 40 |
GrD3DCommandSignature(gr_cp<ID3D12CommandSignature> commandSignature, ForIndexed indexed, |
| 41 |
unsigned int slot) |
| 42 |
: fCommandSignature(commandSignature) |
| 43 |
, fIndexed(indexed) |
| 44 |
, fSlot(slot) {} |
| 45 |
|
| 46 |
// This will be called right before this class is destroyed and there is no reason to explicitly |
| 47 |
// release the fCommandSignature cause the gr_cp will handle that in the dtor. |
| 48 |
void freeGPUData() const override {} |
| 49 |
|
| 50 |
gr_cp<ID3D12CommandSignature> fCommandSignature; |
| 51 |
ForIndexed fIndexed; |
| 52 |
unsigned int fSlot; |
| 53 |
}; |
| 54 |
|
| 55 |
#endif |