Hi guys,
this is my first time that i work with geometry shader and drawing without vertex and index buffer and since some of these errors makes some confusions, i thought it's better to ask my question in here.
this code is based on LPV sample that has been made by DX10 we have discussed here and i just tried to convert that into my DX11 project.
Here are my errors that I've got:
[SPOILER]
D3D11 WARNING: ID3D11DeviceContext::Draw: The Pixel Shader expects a Render Target View bound to slot 0, but none is bound. This is OK, as writes of an unbound Render Target View are discarded. It is also possible the developer knows the data will not be used anyway. This is only a problem if the developer actually intended to bind a Render Target View here. [ EXECUTION WARNING #3146081: DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET]
D3D11 WARNING: ID3D11DeviceContext::Draw: The Pixel Shader expects a Render Target View bound to slot 1, but none is bound. This is OK, as writes of an unbound Render Target View are discarded. It is also possible the developer knows the data will not be used anyway. This is only a problem if the developer actually intended to bind a Render Target View here. [ EXECUTION WARNING #3146081: DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET]
D3D11 WARNING: ID3D11DeviceContext::Draw: The Pixel Shader expects a Render Target View bound to slot 2, but none is bound. This is OK, as writes of an unbound Render Target View are discarded. It is also possible the developer knows the data will not be used anyway. This is only a problem if the developer actually intended to bind a Render Target View here. [ EXECUTION WARNING #3146081: DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Geometry Shader linkage error: Signatures between stages are incompatible. Semantic 'NORMAL' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Geometry Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Geometry Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' of the input stage has a hardware register component mask that is not a subset of the output of the previous stage. [ EXECUTION ERROR #345: DEVICE_SHADER_LINKAGE_REGISTERMASK]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,3) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'NORMAL' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' has mismatched data types between the output stage and input stage. [ EXECUTION ERROR #344: DEVICE_SHADER_LINKAGE_COMPONENTTYPE]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' of the input stage has a hardware register component mask that is not a subset of the output of the previous stage. [ EXECUTION ERROR #345: DEVICE_SHADER_LINKAGE_REGISTERMASK]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' in each signature have different min precision levels, when they must bet identical. [ EXECUTION ERROR #3146050: DEVICE_SHADER_LINKAGE_MINPRECISION]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' of the input stage has a hardware register component mask that is not a subset of the output of the previous stage. [ EXECUTION ERROR #345: DEVICE_SHADER_LINKAGE_REGISTERMASK]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' in each signature have different min precision levels, when they must bet identical. [ EXECUTION ERROR #3146050: DEVICE_SHADER_LINKAGE_MINPRECISION]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,4) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,5) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,6) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,7) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,8) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,9) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,10) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,11) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,12) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,13) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,14) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,15) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,16) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,17) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,18) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,19) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
[/SPOILER]
- first three warning shows that i didn't bind render targets to my progam, but i did it. you can see that in the codes below
- and the next three shows that my Vertex output isn't the same as geometry input, but it also the same, there should be other reason for this.
- for linkage error between geometry and pixel shader, i don't know why so many TEXCOORD sgnatures mentioned here since i've used only wo TEXCOORD in my program.
draw function in my DX program:
[SPOILER]
bool RenderInjection()
{
d3d11DevCon->OMSetRenderTargets(3, Injection_RTV, RT_depthStencilView);
//Refresh the Depth/Stencil view
d3d11DevCon->ClearDepthStencilView(RT_depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);
d3d11DevCon->VSSetShader(injection_vertexShader, 0, 0);
d3d11DevCon->GSSetShader(injection_geometryShader, 0, 0);
d3d11DevCon->PSSetShader(injection_pixelShader, 0, 0);
//Set the Viewport
d3d11DevCon->RSSetViewports(1, &RT_viewport);
d3d11DevCon->IASetInputLayout(NULL);
d3d11DevCon->IASetVertexBuffers(NULL, 0, 0, 0, 0);
d3d11DevCon->IASetIndexBuffer(NULL, DXGI_FORMAT_R32_UINT, 0);
d3d11DevCon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
for (int i = 1; i < MRT_BUFFER_COUNT; i++)
d3d11DevCon->VSSetShaderResources((i - 1), 1, &RT_shaderResourceView[i]);
d3d11DevCon->PSSetShaderResources(0, 3, Injection_SRV);
d3d11DevCon->Draw(RT_Width * RT_Width, 0);
return true;
}
[/SPOILER]
my vertex shader:
[SPOILER]
float lpv_cellSize = 3.0f;
float3 lpv_minCorner = float3(-11.0f, -11.0f, -11.0f);
float3 lpv_size = float3(11.0f, 11.0f, 11.0f);
Texture2D<float4> PositionMap;
Texture2D<float4> NormalMap;
Texture2D<float4> FluxMap;
struct VS_INJECTION_INPUT {
uint posIndex : SV_VertexID;
};
struct VS_INJECTION_OUTPUT {
float4 cellIndex : SV_POSITION;
float3 normal : NORMAL;
float3 flux : TEXCOORD0;
};
VS_INJECTION_OUTPUT VS_gpuInjection(VS_INJECTION_INPUT input) {
float2 RSMsize;
PositionMap.GetDimensions(RSMsize.x, RSMsize.y);
float3 rsmCoords = float3(input.posIndex % RSMsize.x, input.posIndex / RSMsize.x, 0);
float3 posWorld = PositionMap.Load(rsmCoords);
float3 normalWorld = NormalMap.Load(rsmCoords);
float3 flux = FluxMap.Load(rsmCoords);
VS_INJECTION_OUTPUT output;
output.cellIndex = float4(int3((posWorld - lpv_minCorner) / lpv_cellSize + 0.5 * normalWorld), 1.0);
output.normal = normalWorld;
output.flux = flux;
return output;
}
[/SPOILER]
geometry shader:
[SPOILER]
struct VS_INJECTION_OUTPUT {
float4 cellIndex : SV_POSITION;
float3 normal : NORMAL;
float3 flux : TEXCOORD0;
};
struct GS_INJECTION_OUTPUT {
float4 screenPos : SV_Position;
float3 normal : NORMAL;
uint depthIndex : TEXCOORD1;
float3 flux : TEXCOORD2;
};
float lpv_cellSize;
float3 lpv_minCorner;
float3 lpv_size;
[maxvertexcount(1)]
void GS_gpuInjection(point VS_INJECTION_OUTPUT input[1], inout PointStream<GS_INJECTION_OUTPUT> OutputStream) {
GS_INJECTION_OUTPUT output;
output.depthIndex = input[0].cellIndex.z;
output.screenPos.xy = (float2(input[0].cellIndex.xy) + 0.5) / lpv_size.xy * 2.0 - 1.0;
// invert y direction because y points downwards in the viewport?
output.screenPos.y = -output.screenPos.y;
output.screenPos.zw = float2(0, 1);
output.normal = input[0].normal;
output.flux = input[0].flux;
OutputStream.Append(output);
}
[/SPOILER]
pixel shader:
[SPOILER]
struct PS_INJECTION_OUTPUT {
float4 redSH;
float4 greenSH;
float4 blueSH;
};
struct GS_INJECTION_OUTPUT {
float4 screenPos : SV_Position;
float3 normal : NORMAL;
uint depthIndex : TEXCOORD1;
float3 flux : TEXCOORD2;
};
#define SH_cosLobe_c0 0.886226925f /* sqrt(pi)/2 */
#define SH_cosLobe_c1 1.02332671f /* sqrt(pi/3) */
#define Pi 3.1415926f
// helper function
float4 SH_evaluateCosineLobe(float3 direction) {
direction = normalize(direction);
return float4(SH_cosLobe_c0, -SH_cosLobe_c1 * direction.y, SH_cosLobe_c1 * direction.z, -SH_cosLobe_c1 * direction.x);
}
PS_INJECTION_OUTPUT PS_gpuInjection(GS_INJECTION_OUTPUT input) : SV_TARGET
{
PS_INJECTION_OUTPUT output;
if (length(input.normal) < 0.01) {
discard;
}
// the SHcoeffs model an intensity function
// thus the integral over all intensities (over the sphere) should be the original flux
// and that integral = Pi * totalFlux, so divide by Pi
float4 SHcoeffs = SH_evaluateCosineLobe(input.normal) / Pi;
output.redSH = SHcoeffs * input.flux.r;
output.greenSH = SHcoeffs * input.flux.g;
output.blueSH = SHcoeffs * input.flux.b;
return output;
}
[/SPOILER]
PS: sorry i didn't want to simply copy and paste my code in here but i really didn't know how can i figure it out