• Content count

  • Joined

  • Last visited

Community Reputation

105 Neutral

About andyhansen

  • Rank
  1. I am attempting to use the reflection features of the effects11 library to retrieve the argument list for a pass's vertex shader. When I call GetInputSignatureElementDesc() I get a runtime check error, "Run-Time Check Failure #2 - Stack around the variable ParamDesc was corrupted." Is this something other people have experienced? I'm hoping it isn't due to a memory error buried somewhere in my code. Here is the code where I compile the effect an try to read in a parameter. [CODE] DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS; #if defined( DEBUG ) || defined( _DEBUG ) // Set the D3DCOMPILE_DEBUG flag to embed debug information in the shaders. // Setting this flag improves the shader debugging experience, but still allows // the shaders to be optimized and to run exactly the way they will run in // the release configuration of this program. dwShaderFlags |= D3DCOMPILE_DEBUG; #endif ID3DBlob* pErrorBlob; ID3DBlob* compiled; HRESULT hr=D3DX11CompileFromFile(file.c_str(),NULL,NULL,NULL,GetProfile(device).c_str(),dwShaderFlags,NULL,NULL,&compiled,&pErrorBlob,NULL); if( FAILED(hr) ) { if( pErrorBlob != NULL ){ throw runtime_error((char*)pErrorBlob->GetBufferPointer()); if( pErrorBlob ) pErrorBlob->Release(); } else{ throw runtime_error("Failed to compile effect "+StringUtil::WstrToStr(file)); } } hr=D3DX11CreateEffectFromMemory(compiled->GetBufferPointer(),compiled->GetBufferSize(),NULL,device.GetDevice(),&effect); compiled->Release(); if(FAILED(hr)){ throw runtime_error("Failed to create effect from file"); } UINT i=0; ID3DX11EffectTechnique* technique=effect->GetTechniqueByIndex(i++); while(technique->IsValid()){ D3DX11_PASS_SHADER_DESC vsDesc; technique->GetPassByIndex(0)->GetVertexShaderDesc(&vsDesc); D3D11_SIGNATURE_PARAMETER_DESC paramDesc; vsDesc.pShaderVariable->GetInputSignatureElementDesc(vsDesc.ShaderIndex,0,&paramDesc); technique=effect->GetTechniqueByIndex(i++); } [/CODE] Right now I'm just trying to read the first parameter of the first pass of each technique to see if it will work. After the runtime error is triggered, I can hover my mouse over paramDesc, and it seems to have at least some of the correct data in it. I can't find any actual examples of how to do effect reflection, so I may be doing something wrong.
  2. Shadow map Texture format

    Thanks for the quick replies guys! That's exactly the type of thing I was looking for. I was just wondering, would I not want to pack it into a float4, rather than a float3?
  3. Shadow map Texture format

    [quote name='Adaline' timestamp='1312576195' post='4845203'] Hello Did you effectively try to create your map with R32_FLOAT format ? It seems odd that you can't use this format with DX11 : I use this format for my shadow map with DX10 Here's the [url=""]HW support for DX11[/url] (the page you mentioned is about DX10 formats, not DX11) [/quote] I wasn't able to create a texture with R32_FLOAT, it would give me an error saying that that format was only supported for data buffers at feature level 9_1.
  4. I'm currently working on implementing shadow mapping. I'm using DirectX 11 at feature level 9.1 since that is what my laptop supports. It seems the texture formats supported as render targets at this feature level is pretty limited. The table here shows what is supported. R8G8B8A8_UNORM R8G8B8A8_UNORM_SRGB These seem to be the only supported render target formats. This means that I can only store 8 bits of depth precision, rather than using the full 32. What would be ideal is if I could use R32_FLOAT. Is there a way I can somehow use R8G8B8A8_UNORM or R8G8B8A8_UNORM_SRGB, but use all 32 bits to store a single value, rather than only 8 bits?
  5. Skybox rendering

    Thanks for the reply! I'm still having some trouble getting it to work though. My skybox cube is 2 units long along each side. My scene is 4096 units long. If I use the regular depth settings on the viewport when rendering the skybox, I can't see anything except the skybox, which is how it should behave since the geometry is so small. When I set the depth settings on the viewport to both 1, I can see for a little ways, but my skybox still appears to intersect the scene geometry. I've made sure i'm using the same viewprojection matrix for both the scene and the skybox. If I increase the scale factor of the world matrix of the skybox to a very high value (1000), I am able to get it to not intersect the geometry. If I have the scale set to 1000, but I set the viewport depth settings back to normal, it will still intersect the scene geometry. So I at least know that settings the depth values to 1 is helping to some degree. Should this be expected? I'd rather not have to worry about setting the scale of the skybox depending on how large the scene is. My understanding is that setting the viewport to always use 1 as the depth value, and LESS_EQUAL as the comparison operator should cause the skybox to never intersect the scene geometry.
  6. Skybox rendering

    I've been trying to implement skybox rendering. I have it mostly working, except that when I move the camera, the polygons of my skybox will sometimes flicker out of view, showing the backdrop color behind it. I'm using a textured cube with the vertex order reversed to represent the skybox. I'm setting the depthstencilstate to this: [code] DepthEnable=TRUE; DepthWriteMask=D3D11_DEPTH_WRITE_MASK_ALL; DepthFunc=D3D11_COMPARISON_LESS_EQUAL; StencilEnable=FALSE; StencilReadMask=D3D11_DEFAULT_STENCIL_READ_MASK; StencilWriteMask=D3D11_DEFAULT_STENCIL_WRITE_MASK;[/code] My vertex shader looks like this: [code] VS_OUT VS(float3 Pos : POSITION, float2 Tex: TEXCOORD0) { VS_OUT output = (VS_OUT)0; output.posH=mul(float4(Pos,1),World); //make z and w the same so that the depth is always considered 1 output.posH=mul(output.posH,ViewProjection).xyww; output.tex0=Tex; return output; }[/code] I'm rendering the skybox after everything else. Could this just be a problem with my graphics card? I'm currently running on an intel integrated card on my laptop with dx9. It all works perfectly except for when I start to move or rotate the camera. Edit: I was able to try it on another computer, and the problem disappeared. So it must have something to do with the intel card. Is there any way I could prevent this problem from occurring though?
  7. I've been working on optimizing my render loop to make the best use of the CPU cache. Right now I'm simply keeping a vector of pointers to each object to be rendered. I then iterate through the vector and call each objects Render() method. Inside the render method, each object updates the World matrix that is passed to the shader, then performs the draw call on its geometry. I'm thinking this is very cache inefficient, since each rendered object could be located anywhere in memory. I want to change up the way I do rendering by storing all needed data in a contiguous array. For example struct Model{ XMFLOAT4X4world; ID3D11Buffer* index; ID3D11Buffer* vertices; short iIndexCount; }; Model data[ModelCount]; Then I would loop through data[] and perform the draw call on the data contained at each contiguous location of memory. I would think that this would improve cache usage a lot. The only thing I wonder about is what cache hit the actual draw call would entail. The structure is storing pointers to the index and vertex buffer. Would issuing the draw call cause problems? Would it be better for me to use a command list while looping through the data[] array, and then call the command list after the loop? Or is there an even better way to setup a render loop? I'm open to suggestions.
  8. Ok, I'm guessing it's a driver issue then. I'm on an older laptop with an integrated Intel graphics card. I created a basic application with just a simple window. I got the same exception when I tried to create the d3d device, so I'm pretty sure it isn't my code. I'll just ignore it for now. Thank you, that helped a lot.
  9. I don't even know where to look. My program runs properly as far as I know, it just shows those exceptions in the debug output window, so for now I'm just ignoring them. I'm hoping that someone has encountered these errors before and knows what could cause a _com_error.
  10. I've been working on porting my DirectX Framework over to DX11. At runtime I've been getting the following type of error: First-chance exception at 0x75b69617 (KernelBase.dll) in Engine.exe: Microsoft C++ exception: _com_error at memory location 0x0021e7dc.. Multiple of these exceptions are thrown. It occurs when I call: D3D11CreateDeviceAndSwapChain [code] //Create the swap chain parameters DXGI_SWAP_CHAIN_DESC sd; ZeroMemory(&sd,sizeof(sd)); sd.BufferCount=1; sd.BufferDesc.Width=Engine->GetWindow()->GetWindowWidth(); sd.BufferDesc.Height=Engine->GetWindow()->GetWindowHeight(); sd.BufferDesc.Format=DXGI_FORMAT_R8G8B8A8_UNORM; sd.BufferDesc.RefreshRate.Numerator=60; sd.BufferDesc.RefreshRate.Denominator=1; sd.BufferUsage=DXGI_USAGE_RENDER_TARGET_OUTPUT; sd.OutputWindow=Engine->GetWindow()->GetHandle(); sd.SampleDesc.Count=1; sd.SampleDesc.Quality=0; sd.Windowed=(Engine->GetWindow()->GetWindowMode()==CWindow::WINDOW); //create the swap chain UINT flags=0; D3D_FEATURE_LEVEL fl; #if defined(DEBUG) || defined(_DEBUG) flags |= D3D11_CREATE_DEVICE_DEBUG; #endif if(FAILED(D3D11CreateDeviceAndSwapChain(NULL,D3D_DRIVER_TYPE_HARDWARE,NULL,0,NULL,NULL,D3D11_SDK_VERSION,&sd,&pSwapChain,&pDevice,&fl,&pImmediateContext))){ Engine->ShowError("Failed to create d3d device."); return; }[/code] I'm using VS C++ 2010 professional. I created the project as an empty Win32 project. Does anyone have any ideas? I've been working at this for hours.
  11. So to clarify, checking to see if the query is done is quick, but getting the actual result is slow. However, what you said in the first part of your post didn't quite make sense given what the documentation says. I read that you have to provide time in between issuing the predicate and doing the predicated draw call. This is why I want to be able to check if a query is done. That way I can spend time doing other things while the predicate is processed. I am reading from the dx10 sample "draw predicated" at the bottom of the article. Perhaps this has to do with whether the predicate is a hint or not. Is there a way to specify if a predicate is hinted or not? I'm using dx11, but am basing my knowledge of how it works off this sample.
  12. Thank you for your response. In reading about the predicate queries, it looks like there might be a delay between when the query is issued and when it actually gets checked, so I would want to not try and render the geometry until the query actually completes. Meanwhile I would perform other tasks until the query is done, which is why I want to be able to check it with the CPU. Would even checking whether the query is done slow things down too much? I wouldn't be looping doing nothing until the query is finished. I would be doing other things while periodically checking if it is done.
  13. I'm looking to implement an occlusion culling system using the predicated drawing features of dx11. There is not much documentation on the subject. I read that the predicate query could take some time to complete. If I wanted to check if the query was complete, am I right in using the following code? HRESULT hr=pDeviceContext->GetData(pPredicate,NULL,0,0); If the query was finished, hr would be S_OK, and it would be S_FALSE if it were not finished. Is that right? I also am wondering how this works in conjunction with command lists. Would I have to use the predicate to determine whether or not an entire command list gets executed? There really isn't any documentation I can find that says what works inside a command list. The algorithm I want to implement is at