1 // Copyright 2019 The Dawn Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 #ifndef DAWNNATIVE_D3D12_COMMANDRECORDINGCONTEXT_H_ 15 #define DAWNNATIVE_D3D12_COMMANDRECORDINGCONTEXT_H_ 16 17 #include "dawn_native/Error.h" 18 #include "dawn_native/IntegerTypes.h" 19 #include "dawn_native/d3d12/BufferD3D12.h" 20 #include "dawn_native/d3d12/d3d12_platform.h" 21 22 #include <set> 23 24 namespace dawn_native { namespace d3d12 { 25 class CommandAllocatorManager; 26 class Device; 27 class Heap; 28 class Texture; 29 30 class CommandRecordingContext { 31 public: 32 void AddToSharedTextureList(Texture* texture); 33 MaybeError Open(ID3D12Device* d3d12Device, 34 CommandAllocatorManager* commandAllocationManager); 35 36 ID3D12GraphicsCommandList* GetCommandList() const; 37 ID3D12GraphicsCommandList4* GetCommandList4() const; 38 void Release(); 39 bool IsOpen() const; 40 41 MaybeError ExecuteCommandList(Device* device); 42 43 void TrackHeapUsage(Heap* heap, ExecutionSerial serial); 44 45 void AddToTempBuffers(Ref<Buffer> tempBuffer); 46 47 private: 48 ComPtr<ID3D12GraphicsCommandList> mD3d12CommandList; 49 ComPtr<ID3D12GraphicsCommandList4> mD3d12CommandList4; 50 bool mIsOpen = false; 51 std::set<Texture*> mSharedTextures; 52 std::vector<Heap*> mHeapsPendingUsage; 53 54 std::vector<Ref<Buffer>> mTempBuffers; 55 }; 56 }} // namespace dawn_native::d3d12 57 58 #endif // DAWNNATIVE_D3D12_COMMANDRECORDINGCONTEXT_H_ 59