• Advertisement

blackfe2010

Member
  • Content count

    22
  • Joined

  • Last visited

Community Reputation

150 Neutral

About blackfe2010

  • Rank
    Member
  1. Debug pixel shader

    [quote name='DgekGD' timestamp='1355660066' post='5011237'] [CODE] return float4(1.0f, 1.0f, 1.0f, 1.0f); [/CODE] [/quote] I don't see the white object. And i try to use "D3D11_CULL_NONE", it's still not work. so I think the problem seem in the render target because I can see the object in Post-Vertex Shader in the PIX, It can prove the matrix work, isn't it? Here is the code about the render target: [source lang="cpp"] hr = m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&backBufferPtr); CHECK_FAILED(hr) hr = m_device->CreateRenderTargetView(backBufferPtr, NULL, &defaultRenderTargetView); CHECK_FAILED(hr) backBufferPtr->Release(); backBufferPtr = 0; deviceContext->OMSetRenderTargets(1, &defaultRenderTargetView, NULL);[/source] The code is simple. but I only use OMSetRenderTargets at the beginning of the porgram. Shall I use It pre-frame? And I still dont know what's wrong in my code.
  2. Debug pixel shader

    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?
  3. What's wrong about my code?

    you are right. thank you
  4. 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?
  5. Design a render queue

    This blog explain everything clearly. [quote name='zacaj' timestamp='1355518743' post='5010734'] [url="http://realtimecollisiondetection.net/blog/?p=86"]http://realtimecolli....net/blog/?p=86[/url] [/quote] But I haven't support multi-viewport yet. And I think use two render queue at first is suitable for me. I'm start to do it now!!!
  6. 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?
  7. DX11 How to debug in DirectX11

    Hi, all I found the problem. Because of i use the ID3D11DepthStencilView. If I use the code: [source lang="cpp"]deviceContext->OMSetRenderTargets(1, &defaultRenderTargetView, NULL);[/source] everything is ok. What's wrong with ID3D11DepthStencilView in my code? [source lang="cpp"] // Initialize the description of the depth buffer. ZeroMemory(&depthBufferDesc, sizeof(depthBufferDesc)); // Set up the description of the depth buffer. depthBufferDesc.Width = m_screenWidth; depthBufferDesc.Height = m_screenHeight; depthBufferDesc.MipLevels = 1; depthBufferDesc.ArraySize = 1; depthBufferDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; depthBufferDesc.SampleDesc.Count = 1; depthBufferDesc.SampleDesc.Quality = 0; depthBufferDesc.Usage = D3D11_USAGE_DEFAULT; depthBufferDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL; depthBufferDesc.CPUAccessFlags = 0; depthBufferDesc.MiscFlags = 0; // Create the texture for the depth buffer using the filled out description. hr = m_device->CreateTexture2D(&depthBufferDesc, NULL, &defaultDepthStencilBuffer); CHECK_FAILED(hr) // Initialize the description of the stencil state. ZeroMemory(&depthStencilDesc, sizeof(depthStencilDesc)); // Set up the description of the stencil state. depthStencilDesc.DepthEnable = true; depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; depthStencilDesc.DepthFunc = D3D11_COMPARISON_LESS; depthStencilDesc.StencilEnable = true; depthStencilDesc.StencilReadMask = 0xFF; depthStencilDesc.StencilWriteMask = 0xFF; // Stencil operations if pixel is front-facing. depthStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; depthStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR; depthStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; depthStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; // Stencil operations if pixel is back-facing. depthStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; depthStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR; depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; // Create the depth stencil state. hr = m_device->CreateDepthStencilState(&depthStencilDesc, &defaultDepthStencilState); CHECK_FAILED(hr) deviceContext->OMSetDepthStencilState(defaultDepthStencilState, 1); // Initialize the depth stencil view. ZeroMemory(&depthStencilViewDesc, sizeof(depthStencilViewDesc)); // Set up the depth stencil view description. depthStencilViewDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; depthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; depthStencilViewDesc.Texture2D.MipSlice = 0; // Create the depth stencil view. hr = m_device->CreateDepthStencilView(defaultDepthStencilBuffer, &depthStencilViewDesc, &defaultDepthStencilView); CHECK_FAILED(hr) deviceContext->OMSetRenderTargets(1, &defaultRenderTargetView, defaultDepthStencilView);[/source]
  8. 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: [quote] 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 [/quote] 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?
  9. How to use boost::unordered_map with for_each?

    I'm find the problem. I haven't wrt the default constructor...
  10. How to use boost::unordered_map with for_each?

    Hi, I'm come back. Sorry, I found i use vs2008 in one of my computer. So I can't use c++11 like: [quote name='Álvaro' timestamp='1352198432' post='4997966']<br /> for (auto entry : g_map) entry.second->doSomething(p1, p2);<br />[/quote] and [quote name='Brother Bob' timestamp='1352197847' post='4997965']<br />for_each( g_map.begin(), g_map.end() [=](std::pair<int, std::shared_ptr<TEST>> const &foo){ foo.second->doSomething(p1, p2); } );<br />[/quote] And I want use boost::bind to solute this problem. At first, I want to bind [url="http://www.boost.org/doc/libs/1_52_0/doc/html/lambda/le_in_details.html#lambda.members_variables_as_targets"]member variables[/url] std::pair<int,boost::shared_ptr<TEST>>::second [source lang="cpp"] for_each( g_map.begin(), g_map.end(), boost::bind(&std::pair<int,boost::shared_ptr< TEST > >::second,_1)); [/source] But it's failed, why?
  11. How to use boost::unordered_map with for_each?

    ok, i think i need to learn some lambda expression. but Is this the only solution to use "lumbda"? And what the performance about the lumbda? Can i use huge amount of lumbda expressions in my code?
  12. How to use boost::unordered_map with for_each?

    thanks, it's works well. but what's means of [=] ?
  13. Hi [CODE] 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; } [/CODE] Who can tell me how to write the for_each? p1 and p2 are the parameters should send to TEST::doSomething.
  14. Question on boost::shared_ptr

    Thank you for your help!!! I think it's clear for me.
  15. Question on boost::shared_ptr

    [quote name='rip-off' timestamp='1351848403' post='4996478'] why does the Component class need to talk to the "Object Manager"? I would question the necessity of an "Object Manager" class. [/quote] Because i want Component can communicate to other Components [CODE] class Component { public: void sendMessage(string str) { m_objectManager->sendGlobalMessage(str); } }; class ObjectManager { pubic: void sendGlobalMessage(string str) { for_each(m_allComponents.begin(),m_allComponents.end(),...); } }; [/CODE] And about the weak_ptr<>, you means i should do something like: [CODE] class Component { boost::weak_ptr<ObjectManager> m_ojbectManager; }; [/CODE] right? but weak_ptr haven't operator -> how can i use it?
  • Advertisement