-
Notifications
You must be signed in to change notification settings - Fork 411
/
ResourceUploadBatch.h
88 lines (70 loc) · 2.86 KB
/
ResourceUploadBatch.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//--------------------------------------------------------------------------------------
// File: ResourceUploadBatch.h
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkID=615561
//--------------------------------------------------------------------------------------
#pragma once
#ifdef _GAMING_XBOX_SCARLETT
#include <d3d12_xs.h>
#elif (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX)
#include <d3d12_x.h>
#elif defined(USING_DIRECTX_HEADERS)
#include <directx/d3d12.h>
#include <directx/dxgiformat.h>
#include <dxguids/dxguids.h>
#else
#include <d3d12.h>
#include <dxgiformat.h>
#endif
#include <cstdint>
#include <future>
#include <memory>
#include "GraphicsMemory.h"
namespace DirectX
{
// Has a command list of it's own so it can upload at any time.
class ResourceUploadBatch
{
public:
explicit ResourceUploadBatch(_In_ ID3D12Device* device) noexcept(false);
ResourceUploadBatch(ResourceUploadBatch&&) noexcept;
ResourceUploadBatch& operator= (ResourceUploadBatch&&) noexcept;
ResourceUploadBatch(ResourceUploadBatch const&) = delete;
ResourceUploadBatch& operator= (ResourceUploadBatch const&) = delete;
virtual ~ResourceUploadBatch();
// Call this before your multiple calls to Upload.
void __cdecl Begin(D3D12_COMMAND_LIST_TYPE commandType = D3D12_COMMAND_LIST_TYPE_DIRECT);
// Asynchronously uploads a resource. The memory in subRes is copied.
// The resource must be in the COPY_DEST state.
void __cdecl Upload(
_In_ ID3D12Resource* resource,
uint32_t subresourceIndexStart,
_In_reads_(numSubresources) const D3D12_SUBRESOURCE_DATA* subRes,
uint32_t numSubresources);
void __cdecl Upload(
_In_ ID3D12Resource* resource,
const SharedGraphicsResource& buffer
);
// Asynchronously generate mips from a resource.
// Resource must be in the PIXEL_SHADER_RESOURCE state
void __cdecl GenerateMips(_In_ ID3D12Resource* resource);
// Transition a resource once you're done with it
void __cdecl Transition(
_In_ ID3D12Resource* resource,
D3D12_RESOURCE_STATES stateBefore,
D3D12_RESOURCE_STATES stateAfter);
// Submits all the uploads to the driver.
// No more uploads can happen after this call until Begin is called again.
// This returns a handle to an event that can be waited on.
std::future<void> __cdecl End(_In_ ID3D12CommandQueue* commandQueue);
// Validates if the given DXGI format is supported for autogen mipmaps
bool __cdecl IsSupportedForGenerateMips(DXGI_FORMAT format) noexcept;
private:
// Private implementation.
class Impl;
std::unique_ptr<Impl> pImpl;
};
}