Closed carlcc closed 3 years ago
You can you pipeline resource signatures to break resources of a PSO into groups. You then can put all IBL resources into one SRB and material resources into another. https://github.com/DiligentGraphics/DiligentCore/blob/master/Graphics/GraphicsEngine/interface/PipelineResourceSignature.h
Thanks, it's just what I want!
With a little problem,
The following code works.
namespace DG {
using namespace Diligent;
}
//// 3 Signatures, the formal 2 are material and IBL resources, and the following is the 3rd one
const PipelineResourceDesc Resources[] {
{ SHADER_TYPE_VERTEX, "cbTransformUniforms", 1, SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
{ SHADER_TYPE_VERTEX, "cbCameraAttribs", 1, SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
{ SHADER_TYPE_PIXEL, "u_BRDFLutMap", 1, SHADER_RESOURCE_TYPE_TEXTURE_SRV, SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
{ SHADER_TYPE_PIXEL, "cbMaterialUniforms", 1, SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
{ SHADER_TYPE_PIXEL, "cbLightInfoUniforms", 1, SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
{ SHADER_TYPE_PIXEL, "cbCameraAttribs", 1, SHADER_RESOURCE_TYPE_CONSTANT_BUFFER, SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE },
};
DG::ImmutableSamplerDesc ImtblSamplers[] = {
{ DG::SHADER_TYPE_PIXEL, "u_BRDFLutMap_sampler", DG::Sam_LinearClamp },
};
PipelineResourceSignatureDesc Desc;
Desc.Name = "Static Resources Signature";
Desc.Resources = Resources;
Desc.NumResources = _countof(Resources);
Desc.ImmutableSamplers = ImtblSamplers;
Desc.NumImmutableSamplers = _countof(ImtblSamplers);
Desc.BindingIndex = 2;
device->CreatePipelineResourceSignature(Desc, &staticSignature);
/////////////// later we create a SRB for it.
But when I chage the resource type to SHADER_RESOURCE_VARIABLE_TYPE_STATIC
, and bind resources to signature
it self, I get
Diligent Engine: ERROR: No resource is bound to variable 'cbTransformUniforms' in shader 'PBR Color VS' of PSO 'Forward PBR PSO'
Diligent Engine: ERROR: No resource is bound to variable 'cbCameraAttribs' in shader 'PBR Color VS' of PSO 'Forward PBR PSO'
Diligent Engine: ERROR: No resource is bound to variable 'cbMaterialUniforms' in shader 'PBR Color PS' of PSO 'Forward PBR PSO'
Diligent Engine: ERROR: No resource is bound to variable 'cbCameraAttribs' in shader 'PBR Color PS' of PSO 'Forward PBR PSO'
Diligent Engine: ERROR: No resource is bound to variable 'cbLightInfoUniforms' in shader 'PBR Color PS' of PSO 'Forward PBR PSO'
Diligent Engine: ERROR: No resource is bound to variable 'u_BRDFLutMap' in shader 'PBR Color PS' of PSO 'Forward PBR PSO'
You need to bind resource to the signature before creating an SRB from it and pass true to CreateShaderResourceBinding method.
Solved, thank you very much!
Hi,
I am developing a simple renderer for hobby, migrating from OpenGL to DiligentEngine.
Currently, I use a
uniform buffer
and ashader resource binding
to represent a material, I think it's reasonable. But the problem is that, conceptually, the IBL resources (i.e. the irradiance map, the prefiltered envmap and the BRDF LUT), which will vary from envmap to envmap, is not part of material.If I make IBL resource part of material, it seems too intrusive from the perspective of
material class
. If I make IBL resources part of PipelineState's static variable, then swithing envmap seems too expensive; I have to recreate related pipelines each time I use another envmap.So, my question is, what's best/right way to decouple materials and IBL resources.
(I'm sorry if this question looks stupid, I'm not a professional graphics programmer).
Regards.