Closed 9MW closed 1 year ago
same style error also posted when bind static buffer use bufferview ,for example
(Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "materials") ->Set(vbufs[(int)mybuffname::materials]->GetDefaultView(srv)));
It is quite hard to answer what is wrong here. Can you post your shader?
blow is outline of fragment shader code ,all code within macro is not activated
struct ParticleCB {
float4x4 previous_view_projection, previous_inverse_view_projection;
float4 forward;
ShaderFrustum frustum;
uint texture_depth_index_prev;
int texture_primitiveID_index;
int texture_depth_index;
int texture_lineardepth_index;
int texture_velocity_index;
#ifndef __cplusplus
inline float4 internal_resolution(){
return g_CameraAttribs.f4ViewportSize;
}
inline float3 forwardf(){
return forward;
}
inline float4x4 view(){
return g_CameraAttribs.mView;
}
#endif // __cplusplus
};
#define GetCamera() g_xCamera
#define texture_depth bindless_textures_float[GetCamera().texture_depth_index]
cbuffer cbParticleAttribs
{
ParticleCB g_xCamera;
};
struct VertextoPixel
{
float4 pos : SV_POSITION;
float4 tex : TEXCOORD0;
nointerpolation float size : TEXCOORD1;
nointerpolation uint color : TEXCOORD2;
float3 P : WORLDPOSITION;
nointerpolation float frameBlend : FRAMEBLEND;
float2 unrotated_uv : UNROTATED_UV;
};
StructuredBuffer<ShaderMaterial> materials;
StructuredBuffer<ShaderGeometry> geometrys;
Texture2D<float> bindless_textures_float[1];
ShaderMaterial EmitterGetMaterial()
{
return materials[xEmitterInstanceIndex];
}
float4 Sampless(in ShaderTextureSlot ss, in SamplerState sam, in float4 uvsets)
{
Texture2D tex = bindless_textures[ss.texture_descriptor];
float2 uv = ss.GetUVSet() == 0 ? uvsets.xy : uvsets.zw;
#ifndef DISABLE_SVT
[branch]
if (sparse_residencymap_descriptor >= 0)
{
Texture2D<uint> residency_map = bindless_textures_uint[UniformTextureSlot(sparse_residencymap_descriptor)];
float2 virtual_tile_count;
residency_map.GetDimensions(virtual_tile_count.x, virtual_tile_count.y);
float2 virtual_image_dim = virtual_tile_count * SVT_TILE_SIZE;
float virtual_lod = get_lod(virtual_image_dim, ddx(uv), ddy(uv));
return SampleVirtual(tex, sam, uv, residency_map, virtual_tile_count, virtual_image_dim, virtual_lod);
}
#endif // DISABLE_SVT
return tex.Sample(sam, uv);
}
#define texture_lineardepth (bindless_textures_float[GetCamera().texture_lineardepth_index])
[earlydepthstencil]
float4 frag(VertextoPixel input) : SV_TARGET
{
ShaderMaterial material = EmitterGetMaterial();
float4 color = 1;
[branch]
if (material.textures[BASECOLORMAP].IsValid())
{
color = Sampless(material.textures[BASECOLORMAP],bindless_textures_sampler, input.tex.xyxy);
[branch]
if (xEmitterOptions & EMITTER_OPTION_BIT_FRAME_BLENDING_ENABLED)
{
float4 color2 = Sampless(material.textures[BASECOLORMAP],bindless_textures_sampler, input.tex.zwzw);
color = lerp(color, color2, input.frameBlend);
}
}
float2 pixel = input.pos.xy;
float2 ScreenCoord = pixel * internal_resolution().zw;
float4 depthScene = compute_lineardepth(texture_lineardepth.GatherRed(bindless_textures_sampler, ScreenCoord)) ;//* g_CameraAttribs.fFarPlaneZ;
float depthFragment = input.pos.w;
float fade = saturate(1.0 / input.size * (max(max(depthScene.x, depthScene.y), max(depthScene.z, depthScene.w)) - depthFragment));
float4 inputColor;
inputColor.r = ((input.color >> 0) & 0xFF) / 255.0f;
inputColor.g = ((input.color >> 8) & 0xFF) / 255.0f;
inputColor.b = ((input.color >> 16) & 0xFF) / 255.0f;
inputColor.a = ((input.color >> 24) & 0xFF) / 255.0f;
float opacity = saturate(color.a * inputColor.a * fade);
color.rgb *= inputColor.rgb * (1 + material.GetEmissive());
color.a = opacity;
#ifdef EMITTEDPARTICLE_DISTORTION
// just make normal maps blendable:
color.rgb = ApplySRGBCurve_Fast(color.rgb); // note: This texture uses basecolormap slot, and this slot is using SRGB descriptor, so we correct it here for normal map
color.rgb = color.rgb - 0.5f;
#endif // EMITTEDPARTICLE_DISTORTION
#ifdef EMITTEDPARTICLE_LIGHTING
[branch]
if (color.a > 0)
{
float3 N;
N.x = -cos(PI * input.unrotated_uv.x);
N.y = cos(PI * input.unrotated_uv.y);
N.z = -sin(PI * length(input.unrotated_uv));
N = mul((float3x3)GetCamera().inverse_view, N);
N = normalize(N);
Lighting lighting;
lighting.create(0, 0, GetAmbient(N), 0);
Surface surface;
surface.init();
surface.create(material, color, 0);
surface.P = input.P;
surface.N = N;
surface.V = 0;
surface.pixel = pixel;
surface.sss = material.subsurfaceScattering;
surface.sss_inv = material.subsurfaceScattering_inv;
surface.update();
TiledLighting(surface, lighting);
color.rgb *= lighting.direct.diffuse + lighting.indirect.diffuse;
//color.rgb = float3(unrotated_uv, 0);
//color.rgb = float3(input.tex, 0);
color = max(0, color);
}
#endif // EMITTEDPARTICLE_LIGHTING
return color;
}
but I have binded buffer with code
Do you create SRB after you set the variable? If you first create an SRB and then set the variable in PSO, it will not be reflected in SRB
I'm bind variable to PSO then create SRB. post some snippet
{
auto& Renderpsbi = PSBs[(int)PSBID::EMITRender];
Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "cbCameraAttribs")->
Set(rt.pCameraAttribs);
Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_VERTEX, "cbCameraAttribs")->
Set(rt.pCameraAttribs);
Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "EmittedParticleCB")->
Set(vbufs[(int)mybuffname::cbEmittedParticle]);
(Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "bindless_textures_float")
->SetArray(bindless_texf, 0, 1));
(Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "cbParticleAttribs")
->Set(vbufs[(int)mybuffname::cbParticleAttribs]));
(Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "materials")
->Set(vbufs[(int)mybuffname::materials]->GetDefaultView(srv)));
}
for (size_t i = 0; i < PSBs.size(); i++)
{
PSBs[i].CreateShaderResourceBinding();
}
I can't tell what is the issue. Try comparing your code with Tutorial 14 and Tutorial 16
THANKS you reply. use SRB instead
After call CreateShaderResourceBinding function output windows show
but I have binded buffer with code
(Renderpsbi.PSO->GetStaticVariableByName((SHADER_TYPE)SHADER_TYPE_PIXEL, "bindless_textures_float") ->SetArray(bindless_texf, 0, 1));
why is Diligent post error output?