6#include <unordered_set>
11#include "shader/general/resource/binding/ShaderResourceBinding.h"
12#include "render/directx/descriptors/DirectXDescriptorHeap.h"
13#include "render/general/pipeline/PipelineShaderConstantsManager.hpp"
14#include "render/directx/resource/DirectXResource.h"
43 Error error(std::format(
44 "shader resource \"{}\" was requested to set its root constant "
45 "index but this shader resource does not reference the specified pipeline",
52 const auto& [pSrvDescriptorRange, iShaderConstantIndex] =
56 unsigned int iRootConstantValue = 0;
60 const auto pDirectXTexture =
66 auto result = pSrvDescriptorRange->getResourceDescriptorOffsetFromRangeStart(
67 pDirectXTexture, DirectXDescriptorType::SRV);
68 if (std::holds_alternative<Error>(result)) [[unlikely]] {
69 auto error = std::get<Error>(std::move(result));
70 error.addCurrentLocationToErrorStack();
72 throw std::runtime_error(error.getFullErrorMessage());
75 iRootConstantValue = std::get<unsigned int>(result);
93 [[nodiscard]]
virtual std::optional<Error>
94 useNewTexture(std::unique_ptr<TextureHandle> pTextureToUse)
override;
112 [[nodiscard]]
virtual std::optional<Error>
128 const std::string& sResourceName,
129 std::unique_ptr<TextureHandle> pTextureToUse,
130 std::unordered_map<
DirectXPso*, std::pair<ContinuousDirectXDescriptorRange*, size_t>>&&
131 usedDescriptorRanges);
155 static std::variant<std::unique_ptr<ShaderTextureResourceBinding>,
Error>
create(
157 const std::unordered_set<Pipeline*>& pipelinesToUse,
158 std::unique_ptr<TextureHandle> pTextureToUse);
170 static std::variant<std::pair<ContinuousDirectXDescriptorRange*, size_t>,
Error>
187 std::recursive_mutex,
188 std::unordered_map<DirectXPso*, std::pair<ContinuousDirectXDescriptorRange*, size_t>>>
Definition: DirectXPso.h:22
Definition: DirectXResource.h:32
std::string getFullErrorMessage() const
Definition: Error.cpp:84
void showError() const
Definition: Error.cpp:102
Definition: HlslShaderTextureResourceBinding.h:22
void copyResourceIndexToRootConstants(PipelineShaderConstantsManager *pShaderConstantsManager, DirectXPso *pUsedPipeline)
Definition: HlslShaderTextureResourceBinding.h:35
std::pair< std::recursive_mutex, std::unordered_map< DirectXPso *, std::pair< ContinuousDirectXDescriptorRange *, size_t > > > mtxUsedPipelineDescriptorRanges
Definition: HlslShaderTextureResourceBinding.h:189
virtual std::optional< Error > changeUsedPipelines(const std::unordered_set< Pipeline * > &pipelinesToUse) override
Definition: HlslShaderTextureResourceBinding.cpp:233
static std::variant< std::unique_ptr< ShaderTextureResourceBinding >, Error > create(const std::string &sShaderResourceName, const std::unordered_set< Pipeline * > &pipelinesToUse, std::unique_ptr< TextureHandle > pTextureToUse)
Definition: HlslShaderTextureResourceBinding.cpp:101
std::pair< std::mutex, std::unique_ptr< TextureHandle > > mtxUsedTexture
Definition: HlslShaderTextureResourceBinding.h:175
virtual std::optional< Error > useNewTexture(std::unique_ptr< TextureHandle > pTextureToUse) override
Definition: HlslShaderTextureResourceBinding.cpp:205
static constexpr bool bBindSrvToCubemapFaces
Definition: HlslShaderTextureResourceBinding.h:195
virtual std::optional< Error > onAfterAllPipelinesRefreshedResources() override
Definition: HlslShaderTextureResourceBinding.cpp:185
static std::variant< std::pair< ContinuousDirectXDescriptorRange *, size_t >, Error > getSrvDescriptorRangeAndRootConstantIndex(DirectXPso *pPipeline, const std::string &sShaderResourceName)
Definition: HlslShaderTextureResourceBinding.cpp:17
Definition: PipelineShaderConstantsManager.hpp:14
void copyValueToShaderConstant(size_t iShaderConstantIndex, unsigned int iValueToCopy)
Definition: PipelineShaderConstantsManager.hpp:75
std::string getShaderResourceName() const
Definition: ShaderResourceBinding.cpp:11
const std::string sShaderResourceName
Definition: ShaderResourceBinding.h:82
Definition: ShaderTextureResourceBindingManager.h:27
Definition: ShaderResourceBinding.h:86