Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


blackfe2010

Member Since 23 Nov 2011
Offline Last Active Feb 16 2014 06:15 AM

Topics I've Started

Debug pixel shader

16 December 2012 - 01:41 AM

Hi,

I want draw a model, but nothing displayed on the screen, just background color.
I use the PIX to find the problem. but it's hard for me to detect what's wrong with it.

I look at the mesh in PIX, the Pre-Vertex shader and Post-Vertex Shader are drew well. but nothing in viewport.(I'm not use the Geomethry shader)

I guess there is someting wrong in the Pixel shader.

Here is the code in HLSL:

Texture2D DefaultTexture : register( t0 );
SamplerState DefaultSampler : register( s0 );
cbuffer cbChangesEveryFrame : register( b0 )
{
matrix WorldMatrix;
};
cbuffer cbNeverChanges : register( b1 )
{
matrix ViewMatrix;
};
cbuffer cbChangeOnResize : register( b2 )
{
matrix PerspMatrix;
};

struct VSInputTexture
{
float4 pos : POSITION;
float2 tex0 : TEXCOORD0;
};
struct PSInputTexture
{
float4 pos : SV_POSITION;
float2 tex0 : TEXCOORD0;
};

PSInputTexture VSWithCameraWithTexture(VSInputTexture vertex)
{
PSInputTexture vsOut = ( PSInputTexture )0;
vsOut.pos = mul( vertex.pos, WorldMatrix );
vsOut.pos = mul( vsOut.pos, ViewMatrix );
vsOut.pos = mul( vsOut.pos, PerspMatrix );
vsOut.tex0 = vertex.tex0;
return vsOut;
}

float4 PSWithTexture(PSInputTexture frag) : SV_TARGET
{
float4 col = DefaultTexture.Sample( DefaultSampler, frag.tex0 );
return col;
}

technique11 DefaultTechniqueWithCameraWithTexture
{
pass P0
{
SetVertexShader( CompileShader( vs_5_0, VSWithCameraWithTexture()));
SetGeometryShader( NULL);
SetPixelShader( CompileShader( ps_5_0, PSWithTexture()));
}
}

No compile error about this HLSL.

In Rasterizer:

Viewports
Slot TopLeftX TopLeftY Width Height MinDepth MaxDepth
0 0.000f 0.000f 800.000f 600.000f 0.000f 1.000f
(1-15) N/A N/A N/A N/A N/A N/A

Rasterizer
Rasterizer 0x066294A0
Fill Mode D3D11_FILL_SOLID
Cull Mode D3D11_CULL_BACK
Front Counter-clockwise FALSE
Depth Bias 0
Depth Bias Clamp 0.000f
Slope Scaled Depth Bias 0.000f
Depth Clip Enable FALSE
Scissor Enable FALSE
Multisample Enable FALSE
Antialiased Line Enable FALSE

In Pixel Shader:

Slot Sampler Filter AddressU AddressV AddressW MipMapLODBias MaxAnisotropy ComparisonFunc BorderColorRGBA MinLOD MaxLOD
0 0x06627010 D3D11_FILTER_MIN_MAG_MIP_LINEAR D3D11_TEXTURE_ADDRESS_WRAP D3D11_TEXTURE_ADDRESS_WRAP D3D11_TEXTURE_ADDRESS_WRAP 0.000f 0 D3D11_COMPARISON_NEVER (0.000f, 0.000f, 0.000f, 0.000f) 0.000f 340282346638528860000000000000000000000.000f


I have checked every thing but still don't know why nothing displayed.

Could you help me?

What's wrong about my code?

15 December 2012 - 09:54 AM

Hi

I want display a model. but there is something wrong.

I use PIX to see what's wrong, and I find the data is malposition.

This is the data what my program drew
VTX IDX POSITION[0] POSITION[1] POSITION[2] POSITION[3] TEXCOORD[0] TEXCOORD[1]
0 1 0.453 0.78 0.14 1 61.198 -14.418
1 2 61.198 -14.418 0.453 1 0.653 -7.689
2 0 0.024 55.081 -2.898 1 0.453 0.78

but the correct one is:

VTX IDX POSITION[0] POSITION[1] POSITION[2] POSITION[3] TEXCOORD[0] TEXCOORD[1]
0 1 0.14 61.198 -14.418 1 0.453 0.653
1 2 -7.689 61.197 -11.877 1 0.39 0.653
2 0 0.024 55.081 -2.898 1 0.453 0.78

the issue start at index 1 POSITION[0] and POSITION[1],
They re-use index 0 TEXCOORD[0] and TEXCOORD[1],

And I see the input layout, it is correct.
SemanticName SemanticIndex Format InputSlot AlignedByteOffset InputSlotClass InstanceDataStepRate
POSITION 0 DXGI_FORMAT_R32G32B32_FLOAT 0 0 D3D11_INPUT_PER_VERTEX_DATA 0
TEXCOORD 0 DXGI_FORMAT_R32G32_FLOAT 0 12 D3D11_INPUT_PER_VERTEX_DATA 0

In the .fx file

struct VSInputTexture
{
float4 pos : POSITION;
float2 tex0 : TEXCOORD0;
};

I use a struct in c++

struct VertexTexStr
{
XMFLOAT3 pos;
XMFLOAT2 tex;
};

I used D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST and
create vertex buffer:
[source lang="cpp"]void RenderObject::CreateVertexBuffer(){ try { D3D11_BUFFER_DESC bufferDesc; ZeroMemory( &bufferDesc, sizeof( bufferDesc ) ); D3D11_SUBRESOURCE_DATA initData; ZeroMemory( &initData, sizeof( initData ) ); VertexTexStr* tmpVertexTex=NULL; bufferDesc.Usage=D3D11_USAGE_DEFAULT; bufferDesc.BindFlags=D3D11_BIND_VERTEX_BUFFER; bufferDesc.CPUAccessFlags=0; bufferDesc.MiscFlags=0; bufferDesc.StructureByteStride=0; switch(m_mode) { case RenderWithCameraWithTexture: bufferDesc.ByteWidth=sizeof(VertexTexStr)*m_vertices->size(); tmpVertexTex=new VertexTexStr[m_vertices->size()]; for(size_t i=0;i<m_vertices->size();i++) { tmpVertexTex[i].pos=(*m_vertices)[i]; tmpVertexTex[i].tex=(*m_texs)[i]; } initData.pSysMem=tmpVertexTex; sendMessage(MSG_CREATE_BUFFER,AuxGroupArgus(&bufferDesc,&initData,&m_verticesBuffer)); delete[] tmpVertexTex; break;[/source]

I use debug to see the initData.pSysMem, it is ok at index 1.
What's wrong?

Design a render queue

14 December 2012 - 03:41 AM

HI,

I want to design a game engine by myself, and now I'm start to design "render" part .

I know change the render state is very expensive. so use a render queue to split the render object in different queue is a good idea(truth?).

But i have no idea how to start this design.

How many kinds of queue i should use?

How can I determine this object is suitable for queue A or queue B?

Could you give me some suggestion?

How to debug in DirectX11

29 November 2012 - 08:57 AM

Hi

I have wrt an game using DX11.
I want display a trangle, but only background color displayed.

And I use the InfoQueue to catch the error message
[source lang="cpp"] HRESULT hr=S_OK; if(m_device==NULL) EXCEPTION("Device not created") hr=m_device->QueryInterface(__uuidof(ID3D11Debug),(LPVOID*)&m_debug); if(FAILED(hr)) EXCEPTION("Create ID3D11Debug failed") hr=m_debug->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL); if(FAILED(hr)) EXCEPTION("Set ReportLiveDeviceObjects failed") hr=m_device->QueryInterface(__uuidof(ID3D11InfoQueue),(LPVOID*)&m_infoQueue); if(FAILED(hr)) EXCEPTION("Create ID3D11InfoQueue failed") m_infoQueue->ClearStoredMessages(); m_infoQueue->ClearRetrievalFilter(); m_infoQueue->ClearStorageFilter(); D3D11_INFO_QUEUE_FILTER filter; ZeroMemory(&filter, sizeof(D3D11_INFO_QUEUE_FILTER)); D3D11_MESSAGE_SEVERITY severity; severity=D3D11_MESSAGE_SEVERITY_ERROR; filter.DenyList.NumSeverities=1; filter.DenyList.pSeverityList=&severity; m_infoQueue->AddStorageFilterEntries(&filter); m_infoQueue->AddRetrievalFilterEntries(&filter);[/source]


In the log file:

Create RenderTargetView: Name="unnamed", Addr=0x00FDB034, ExtRef=1, IntRef=0
Create Texture2D: Name="unnamed", Addr=0x00FDB15C, ExtRef=1, IntRef=0
Create DepthStencilState: Name="unnamed", Addr=0x00FDB334, ExtRef=1, IntRef=0
Create DepthStencilView: Name="unnamed", Addr=0x00FDB42C, ExtRef=1, IntRef=0

But I don't know what's the meaning of it.
Because when I create the RenderTargetView,Texture2D,DepthStencilState and DepthStencilView, ther are all return S_OK.

How can I detect the bug?

And here is an other question.

Every function in ID3D11Device interface will return the HRESULT. so I can know the function run success or failed.
But the function in ID3D11DeviceContext interface have no return value.
How can I know the result?

How to use boost::unordered_map with for_each?

06 November 2012 - 03:14 AM

Hi

class TEST
{
public:
  TEST() {};
  void doSomething(int a,int b);
};
boost::unordered_map<int,boost::shared_ptr<TEST>> g_map;
int main()
{
  int p1=0;
  int p2=1;
  g_map[0]=boost::make_shared<TEST>();
  g_map[1]=boost::make_shared<TEST>();
  for_each(g_map.begin(),g_map.end(),how to write?);
  returns 0;
}

Who can tell me how to write the for_each?
p1 and p2 are the parameters should send to TEST::doSomething.

PARTNERS