14 D3D12_RESOURCE_STATES newResourceState,
15 unsigned int subresource) {
16 D3D12_RESOURCE_STATES currentResourceState = this->
currentState();
17 if (newResourceState == currentResourceState) {
21 D3D12_RESOURCE_TRANSITION_BARRIER barrier;
23 barrier.Subresource = subresource;
24 barrier.StateBefore = currentResourceState;
25 barrier.StateAfter = newResourceState;
32 D3D12_RESOURCE_STATES initialState,
34 D3D12_CLEAR_VALUE* clearValue,
36 if (0 ==
desc.Width || 0 ==
desc.Height) {
48 D3D12_HEAP_TYPE_DEFAULT, &
desc, initialState, &
info->fAlloc, clearValue);
49 if (!
info->fResource) {
53 info->fResourceState = initialState;
56 info->fSampleCount =
desc.SampleDesc.Count;
57 info->fSampleQualityPattern =
desc.SampleDesc.Quality;
58 info->fProtected = isProtected;
70 D3D12_RESOURCE_DESC msTextureDesc = {};
71 msTextureDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
72 msTextureDesc.Alignment = 0;
73 msTextureDesc.Width = dimensions.
fWidth;
74 msTextureDesc.Height = dimensions.
fHeight;
75 msTextureDesc.DepthOrArraySize = 1;
76 msTextureDesc.MipLevels = 1;
77 msTextureDesc.Format =
info.fFormat;
78 msTextureDesc.SampleDesc.Count = sampleCnt;
79 msTextureDesc.SampleDesc.Quality = DXGI_STANDARD_MULTISAMPLE_QUALITY_PATTERN;
80 msTextureDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
81 msTextureDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
83 D3D12_CLEAR_VALUE clearValue = {};
84 clearValue.Format =
info.fFormat;
85 clearValue.Color[0] = clearColor.fR;
86 clearValue.Color[1] = clearColor.fG;
87 clearValue.Color[2] = clearColor.fB;
88 clearValue.Color[3] = clearColor.fA;
91 info.fProtected, &clearValue, &msInfo)) {
98 return std::make_pair(msInfo, msState);
123 fResource->setRelease(std::move(releaseHelper));
126void GrD3DTextureResource::Resource::freeGPUData()
const {
127 this->invokeReleaseProc();
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
GrD3DMemoryAllocator * memoryAllocator() const
void addResourceBarriers(sk_sp< GrManagedResource > resource, int numBarriers, D3D12_RESOURCE_TRANSITION_BARRIER *barriers) const
virtual gr_cp< ID3D12Resource > createResource(D3D12_HEAP_TYPE, const D3D12_RESOURCE_DESC *, D3D12_RESOURCE_STATES initialResourceState, sk_sp< GrD3DAlloc > *allocation, const D3D12_CLEAR_VALUE *)=0
virtual ~GrD3DTextureResource()
GrD3DTextureResourceInfo fInfo
void prepareForPresent(GrD3DGpu *gpu)
void setResourceState(const GrD3DGpu *gpu, D3D12_RESOURCE_STATES newResourceState, unsigned int subresource=D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES)
void updateResourceState(D3D12_RESOURCE_STATES newState)
ID3D12Resource * d3dResource() const
D3D12_RESOURCE_STATES currentState() const
void setResourceRelease(sk_sp< GrSurface::RefCntedReleaseProc > releaseHelper)
void releaseResource(GrD3DGpu *gpu)
static bool InitTextureResourceInfo(GrD3DGpu *gpu, const D3D12_RESOURCE_DESC &desc, D3D12_RESOURCE_STATES initialState, GrProtected, D3D12_CLEAR_VALUE *, GrD3DTextureResourceInfo *)
sk_sp< Resource > resource() const
static std::pair< GrD3DTextureResourceInfo, sk_sp< GrD3DResourceState > > CreateMSAA(GrD3DGpu *gpu, SkISize dimensions, int sampleCnt, const GrD3DTextureResourceInfo &info, SkColor4f clearColor)
void reset(T *object=nullptr)
void reset(T *ptr=nullptr)
D3D12_RESOURCE_STATES fResourceState
gr_cp< ID3D12Resource > fResource
sk_sp< GrD3DAlloc > fAlloc