Corentin Wallez | 4a9ef4e | 2018-07-18 11:40:26 +0200 | [diff] [blame] | 1 | // Copyright 2017 The Dawn Authors |
Austin Eng | 036f76f | 2017-06-29 14:11:43 -0400 | [diff] [blame] | 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 | |
Corentin Wallez | 30965a7 | 2018-07-24 16:42:33 +0200 | [diff] [blame] | 15 | #ifndef DAWNNATIVE_D3D12_BINDGROUPD3D12_H_ |
| 16 | #define DAWNNATIVE_D3D12_BINDGROUPD3D12_H_ |
Austin Eng | 036f76f | 2017-06-29 14:11:43 -0400 | [diff] [blame] | 17 | |
Austin Eng | ae96f04 | 2020-03-13 23:34:40 +0000 | [diff] [blame] | 18 | #include "common/PlacementAllocated.h" |
Austin Eng | e5b361d | 2021-11-29 23:02:49 +0000 | [diff] [blame] | 19 | #include "common/ityp_span.h" |
| 20 | #include "common/ityp_stack_vec.h" |
Corentin Wallez | d37523f | 2018-07-24 13:53:51 +0200 | [diff] [blame] | 21 | #include "dawn_native/BindGroup.h" |
Bryan Bernhart | cb859a2 | 2020-04-06 22:07:42 +0000 | [diff] [blame] | 22 | #include "dawn_native/d3d12/CPUDescriptorHeapAllocationD3D12.h" |
Bryan Bernhart | 303a3da | 2020-04-30 23:19:16 +0000 | [diff] [blame] | 23 | #include "dawn_native/d3d12/GPUDescriptorHeapAllocationD3D12.h" |
Austin Eng | 036f76f | 2017-06-29 14:11:43 -0400 | [diff] [blame] | 24 | |
Corentin Wallez | ec9cf2a | 2022-01-12 09:17:35 +0000 | [diff] [blame] | 25 | namespace dawn::native::d3d12 { |
Austin Eng | 036f76f | 2017-06-29 14:11:43 -0400 | [diff] [blame] | 26 | |
| 27 | class Device; |
Bryan Bernhart | e25ee25 | 2020-05-18 23:25:31 +0000 | [diff] [blame] | 28 | class SamplerHeapCacheEntry; |
Bryan Bernhart | 0363c3e | 2020-02-27 01:14:22 +0000 | [diff] [blame] | 29 | class ShaderVisibleDescriptorAllocator; |
Austin Eng | 036f76f | 2017-06-29 14:11:43 -0400 | [diff] [blame] | 30 | |
Rafael Cintron | c64242d | 2020-04-06 18:20:02 +0000 | [diff] [blame] | 31 | class BindGroup final : public BindGroupBase, public PlacementAllocated { |
Corentin Wallez | 2d62a37 | 2017-11-24 14:04:22 -0500 | [diff] [blame] | 32 | public: |
Corentin Wallez | 50f9958 | 2021-03-31 18:36:32 +0000 | [diff] [blame] | 33 | static ResultOrError<Ref<BindGroup>> Create(Device* device, |
| 34 | const BindGroupDescriptor* descriptor); |
Austin Eng | ae96f04 | 2020-03-13 23:34:40 +0000 | [diff] [blame] | 35 | |
Bryan Bernhart | cb859a2 | 2020-04-06 22:07:42 +0000 | [diff] [blame] | 36 | BindGroup(Device* device, |
| 37 | const BindGroupDescriptor* descriptor, |
| 38 | uint32_t viewSizeIncrement, |
Bryan Bernhart | e25ee25 | 2020-05-18 23:25:31 +0000 | [diff] [blame] | 39 | const CPUDescriptorHeapAllocation& viewAllocation); |
Austin Eng | 036f76f | 2017-06-29 14:11:43 -0400 | [diff] [blame] | 40 | |
Bryan Bernhart | 0363c3e | 2020-02-27 01:14:22 +0000 | [diff] [blame] | 41 | // Returns true if the BindGroup was successfully populated. |
Bryan Bernhart | 303a3da | 2020-04-30 23:19:16 +0000 | [diff] [blame] | 42 | bool PopulateViews(ShaderVisibleDescriptorAllocator* viewAllocator); |
Bryan Bernhart | e25ee25 | 2020-05-18 23:25:31 +0000 | [diff] [blame] | 43 | bool PopulateSamplers(Device* device, ShaderVisibleDescriptorAllocator* samplerAllocator); |
Jiawei Shao | e4c0a82 | 2019-05-16 05:56:49 +0000 | [diff] [blame] | 44 | |
Bryan Bernhart | 303a3da | 2020-04-30 23:19:16 +0000 | [diff] [blame] | 45 | D3D12_GPU_DESCRIPTOR_HANDLE GetBaseViewDescriptor() const; |
Bryan Bernhart | 0363c3e | 2020-02-27 01:14:22 +0000 | [diff] [blame] | 46 | D3D12_GPU_DESCRIPTOR_HANDLE GetBaseSamplerDescriptor() const; |
Austin Eng | 036f76f | 2017-06-29 14:11:43 -0400 | [diff] [blame] | 47 | |
Bryan Bernhart | e25ee25 | 2020-05-18 23:25:31 +0000 | [diff] [blame] | 48 | void SetSamplerAllocationEntry(Ref<SamplerHeapCacheEntry> entry); |
Bryan Bernhart | 303a3da | 2020-04-30 23:19:16 +0000 | [diff] [blame] | 49 | |
Austin Eng | e5b361d | 2021-11-29 23:02:49 +0000 | [diff] [blame] | 50 | using DynamicStorageBufferLengths = |
| 51 | ityp::stack_vec<uint32_t, uint32_t, kMaxDynamicStorageBuffersPerPipelineLayout>; |
| 52 | const DynamicStorageBufferLengths& GetDynamicStorageBufferLengths() const; |
| 53 | |
Bryan Bernhart | e25ee25 | 2020-05-18 23:25:31 +0000 | [diff] [blame] | 54 | private: |
Rafael Cintron | c64242d | 2020-04-06 18:20:02 +0000 | [diff] [blame] | 55 | ~BindGroup() override; |
| 56 | |
Loko Kung | e9c84c0 | 2021-11-11 01:39:52 +0000 | [diff] [blame] | 57 | void DestroyImpl() override; |
Loko Kung | 2c67af9 | 2021-11-11 00:39:22 +0000 | [diff] [blame] | 58 | |
Bryan Bernhart | e25ee25 | 2020-05-18 23:25:31 +0000 | [diff] [blame] | 59 | Ref<SamplerHeapCacheEntry> mSamplerAllocationEntry; |
Bryan Bernhart | cb859a2 | 2020-04-06 22:07:42 +0000 | [diff] [blame] | 60 | |
Bryan Bernhart | e25ee25 | 2020-05-18 23:25:31 +0000 | [diff] [blame] | 61 | GPUDescriptorHeapAllocation mGPUViewAllocation; |
Bryan Bernhart | cb859a2 | 2020-04-06 22:07:42 +0000 | [diff] [blame] | 62 | CPUDescriptorHeapAllocation mCPUViewAllocation; |
Austin Eng | e5b361d | 2021-11-29 23:02:49 +0000 | [diff] [blame] | 63 | |
| 64 | DynamicStorageBufferLengths mDynamicStorageBufferLengths; |
Austin Eng | 036f76f | 2017-06-29 14:11:43 -0400 | [diff] [blame] | 65 | }; |
Corentin Wallez | ec9cf2a | 2022-01-12 09:17:35 +0000 | [diff] [blame] | 66 | } // namespace dawn::native::d3d12 |
Austin Eng | 036f76f | 2017-06-29 14:11:43 -0400 | [diff] [blame] | 67 | |
Corentin Wallez | 30965a7 | 2018-07-24 16:42:33 +0200 | [diff] [blame] | 68 | #endif // DAWNNATIVE_D3D12_BINDGROUPD3D12_H_ |