osiris11

Members
  • Content count

    11
  • Joined

  • Last visited

Community Reputation

100 Neutral

About osiris11

  • Rank
    Member
  1. DX11 ID3dX11Effect constant buffer

    @ Quat: Your answer sounds good: it's easy, would not require me to do too much changes, and would not need me to do obscure things. @ Asesh: It's quite the opposite to what Quat suggested: You tell me to actually take everything in my own responsibility, and actually mapping the buffer. In this case, would I have to create the buffers myself? As I see it, the effect creates the declared buffers within it on compilation(?) and I can just access it with the GetConstantBufferFunction. Where can I make it's usage DYNAMIC? Do I have to create the buffer myself and replace it with the one the shader generated? Actually, now I'm as wise as before: It seems to me I have two concurring opinions on this topic, and (of course I am tempted to use the easier one for the time being) still can't decide which option to settle with. Are there any more opinions?
  2. Hey. I am investigating the use of constant buffers in effect files. Say, my effect file had buffer declarations like this: [CODE] cbuffer cbPerViewBuffer { matrix viewMatrix; }; [/CODE] When initializing my shader, i would get a pointer to this effect variable by name, and store it in my object: [CODE] ID3DX11EffectMatrixVariable *p_view; ID3DX11Effect* p_effect; //... Compiling effect ...// p_view = p_effect->GetVariableByName("viewMatrix")->AsMatrix(); [/CODE] On rendering, I do [CODE] D3DXMATRIX v; //... doing the math on v ...// p_view->SetMatrix( v); [/CODE] There is no buffer mapping or else involved. So my question is, is this even using the advantages of constant buffers, or is this an absurdely abuse of mentioned features? Should I instead create a custom buffer type, create a buffer of this type, bind it as dynamic to the effect, and use map on each render call? Can the view buffer even be updated, I have seen no flag specifying it as DYNAMIC? Thanks for your help.
  3. Multipe views

    Hey. I have been setting up a multi monitor framework, that is, I am rendering to multiple outputs on multiple adapters, with one device per adapter and one swapchain per output. Each output additionally has its own backbuffer and zBuffer. I do not want clones of the scene, which is working fine so far. Instead, I want the scene to span the entire area spanned by all monitors ( easy to get as DXGI_OUTPUT_DESC). So naturally, my thought was to use and set a different viewport before each Draw call. But what it does instead, is clipping my scene to the size of, what it seems, is my back buffer (On a screen of 1280x1024, if I set [CODE]viewport.TopLeftX = -640;[/CODE] my scene gets clipped vertically in the middle, showing only the left half) It seems to me now, I could be creating a larger back buffer, but for n outputs I would at least let a (n-1)th of the buffer go to waste, while I seriously doubt most devices could create buffers that large. Am I right? Second, I might have to vary the camera matrix or the projection matrix (or even both?) for each render call, but I am a bit clueless as to how this should be done. Currently my cam matrix is generated using [i]D3DXMatrixLookAtLH [/i]. To vary for a different viewport, I would have to multiply a Translation onto it for sure. I think, the translation in screen coordinates would be the vector from the center of the first monitor to the center of a second. But then? How do I get this 2d translation into my 3d view space? Or should it be entirely different? Thanks for your help. Just a small edit: I reconsidered the part with different views, and came to the conclusion, that my program could only benefit from this, if the user actually ordered the displays in a circle around them. So after a bit more experimenting, I think my desired result could be achieved using different projectionMatrices for each output. I maybe could use [i]D3DXMatrixPerspectiveOffCenterLH [/i]to render for different monitors. Then I would have to specify different view volumes. Here's where I'm lost at now: I should once calculate the entire bounding box of all view volumes, maybe determine the barycentre of the view volumes, make this barycentre origin of an additional coordinate system, so that it can be the vanishing point for all windows, and then express all view volumes relative to this origin??
  4. DX11 Compile Effects11_*.sln

    I finally got it working. Not quite the way you suggested, but here's how: I reinstalled the Windows sdk. That is, I first removed all Windows SDK components, then reinstalled it using the x86 package. Then I opened the Effects11_2010.sln and modified the include and library paths to explicitely provide the Windows SDK path before the DirectX SDK path. And somehow it worked. Thanks for your efforts anyway.
  5. Hey. I want to use a complete effect file, and from what I read about loading effect files, I need the library Effects11.lib to do this. Next, I found out, I have to compile this library myself (as stated here: [url="http://msdn.microsoft.com/en-us/library/windows/desktop/ff476273(v=vs.85).aspx"]http://msdn.microsof...3(v=vs.85).aspx[/url] , Section "Requirements"). So I pay a visit to the DirectX SDK directory ( which is in my case located at "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)") and open .\Samples\C++\Effects11\Effects11_2010.sln , as I am using Visual Studio 2010. Then I just try to compile, but I get a bunch of errors (Should I get errors at all, when compiling Microsoft's Sources???), see the complete output listed below. [CODE] 1>------ Erstellen gestartet: Projekt: Effects11, Konfiguration: Release Win32 ------ 1>Der Buildvorgang wurde am 10.03.2012 01:49:21 gestartet. 1>InitializeBuildStatus: 1> Aktualisieren des Timestamps von "Release\Effects11.unsuccessfulbuild". 1>ClCompile: 1> d3dx11dbg.cpp 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11280): error C2061: Syntaxfehler: Bezeichner '__RPC__out_xcount_part' 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11281): error C2059: Syntaxfehler: ')' 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11281): fatal error C1903: Weiterverarbeitung nach vorherigem Fehler nicht möglich; Kompilierung wird abgebrochen. 1> d3dxGlobal.cpp 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11280): error C2061: Syntaxfehler: Bezeichner '__RPC__out_xcount_part' 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11281): error C2059: Syntaxfehler: ')' 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11281): fatal error C1903: Weiterverarbeitung nach vorherigem Fehler nicht möglich; Kompilierung wird abgebrochen. 1> EffectAPI.cpp 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11280): error C2061: Syntaxfehler: Bezeichner '__RPC__out_xcount_part' 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11281): error C2059: Syntaxfehler: ')' 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11281): fatal error C1903: Weiterverarbeitung nach vorherigem Fehler nicht möglich; Kompilierung wird abgebrochen. 1> EffectLoad.cpp 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11280): error C2061: Syntaxfehler: Bezeichner '__RPC__out_xcount_part' 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11281): error C2059: Syntaxfehler: ')' 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11281): fatal error C1903: Weiterverarbeitung nach vorherigem Fehler nicht möglich; Kompilierung wird abgebrochen. 1> EffectNonRuntime.cpp 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11280): error C2061: Syntaxfehler: Bezeichner '__RPC__out_xcount_part' 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11281): error C2059: Syntaxfehler: ')' 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11281): fatal error C1903: Weiterverarbeitung nach vorherigem Fehler nicht möglich; Kompilierung wird abgebrochen. 1> EffectReflection.cpp 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11280): error C2061: Syntaxfehler: Bezeichner '__RPC__out_xcount_part' 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11281): error C2059: Syntaxfehler: ')' 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11281): fatal error C1903: Weiterverarbeitung nach vorherigem Fehler nicht möglich; Kompilierung wird abgebrochen. 1> EffectRuntime.cpp 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11280): error C2061: Syntaxfehler: Bezeichner '__RPC__out_xcount_part' 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11281): error C2059: Syntaxfehler: ')' 1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(11281): fatal error C1903: Weiterverarbeitung nach vorherigem Fehler nicht möglich; Kompilierung wird abgebrochen. 1> 1>Fehler beim Erstellen 1> 1>Verstrichene Zeit 00:00:01.33 ========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ========== [/CODE] While I don't understand these completely, my investigation has shown that I was missing the Windows 7 SDK. Ouch. So I downloaded it, still in the hope these errors might vanish. No luck. Being on a x64 System, I additionaly gave the x64 WINDOWS 7 SDK a try, nothing improved. So what is it, I'm missing? Can anyone help me here? Or can anyone point me to the compiled library? Maybe my system information can be helpful here: IDE: Visual Studio 2010; OS: Server 2008R2 SP1;
  6. Hey. I have set up a framework to render to a multi-monitor system, using a separate window, swap chain, buffers, etc per monitor, and seperate devices per adapter. It is completely working in windowed mode, but when I go fullscreen (Test system has two monitors only, I render a gray background for testing, cursor is shown), on the right monitor there is a black vertical bar, that keeps the pointer from moving out. I go fullscreen, after I have created all devices, using a loop over [CODE] p_swapChain->SetFullscreenState(true, p_output); [/CODE] where p_output is a valid pointer to the corresponding IDXGIOutput interface of my display. The display mode for each display is enumerated to be the highest possible resolution and refresh rate for each display. I my test case, I traced the values to be[list] [*]1280x1024px @ 75Hz [*]1280x1024px @ [b]76[/b]Hz [/list] Yes, the 76 is intended, I have two different refresh rates (even astounding to me). So, my question is: Can I have different resolutions per buffer, or will I have to settle with the greatest common? (seems this can be done!) Can I have different refresh rates per swap chain, and does anyone know a convenient way to check for an all display supporting refresh rate? Or am I missing something completely different?
  7. DX11 Instancing

    That actually did the trick. Thank you so very much, i thought I had tried this before, but my mind was so messed up with this, I screwed it completely and tested it with some update code disabled. I was already going to tell you how it doesn't work, but kept trying once more to consider your answer, and Voila. It actually works.
  8. DX11 Instancing

    Hey. I have been following [url="http://rastertek.com/dx11tut37.html"]this tutorial[/url] , but while experimenting I reached a dead end. The addition I was trying to implement is a dynamic updating rotation per instance. So first, i define [CODE] // TriangleTest.h struct InstanceType { D3DXVECTOR3 position; D3DXVECTOR3 rotation; }; [/CODE] for my Instance buffer Type, which leads me to define [CODE] // vertexshader.vs struct VertexInputType { float3 position : POSITION; float4 color : COLOR; float3 instancePosition : POSITION1; float3 instanceRotation : POSITION2; }; [/CODE] in my vertex Shader file. Note that I have changed the usage of semantic type TEXCOORD from the tutorial, as I feel more comfortable having positions use POSITION, as well as giving the position a [b]float3 type[/b]. I set up my InputElementDescription array like this [CODE] //shaderclass.cpp polygonLayout[0].SemanticName = "POSITION"; polygonLayout[0].SemanticIndex = 0; polygonLayout[0].Format = DXGI_FORMAT_R32G32B32_FLOAT; polygonLayout[0].InputSlot = 0; polygonLayout[0].AlignedByteOffset = 0; polygonLayout[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; polygonLayout[0].InstanceDataStepRate = 0; polygonLayout[1].SemanticName = "COLOR"; polygonLayout[1].SemanticIndex = 0; polygonLayout[1].Format = DXGI_FORMAT_R32G32B32A32_FLOAT; polygonLayout[1].InputSlot = 0; polygonLayout[1].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT; polygonLayout[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; polygonLayout[1].InstanceDataStepRate = 0; polygonLayout[2].SemanticName = "POSITION"; polygonLayout[2].SemanticIndex = 1; polygonLayout[2].Format = DXGI_FORMAT_R32G32B32_FLOAT; polygonLayout[2].InputSlot = 1; polygonLayout[2].AlignedByteOffset = 0; polygonLayout[2].InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA; polygonLayout[2].InstanceDataStepRate = 1; polygonLayout[3].SemanticName = "POSITION"; polygonLayout[3].SemanticIndex = 2; polygonLayout[3].Format = DXGI_FORMAT_R32G32B32_FLOAT; polygonLayout[3].InputSlot = 1; polygonLayout[3].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT; polygonLayout[3].InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA; polygonLayout[3].InstanceDataStepRate = 1; [/CODE] and create the input layouts. In my model class (TriangeTest), i use this to update the dynamic instance buffer ( completely created as D3D11_USAGE_DYNAMIC, with D3D11_CP_ACCESS_WRITE) [CODE] void TriangleTest::Frame(ID3D11DeviceContext* deviceContext) { for (int i = 0; i < this->i_instanceCount; i++) { D3DXVec3Add(&(m_instanceList[i].rotation), &(m_instanceList[i].rotation), &D3DXVECTOR3(1,0,0.0f)); } UpdateBuffers(deviceContext); } void TriangleTest::UpdateBuffers(ID3D11DeviceContext* deviceContext) { HRESULT result; D3D11_MAPPED_SUBRESOURCE mappedResource; InstanceType* instancePtr; result =deviceContext->Map(m_instanceBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource); if(FAILED(result)) throw CException("Could not remap instance buffer"); instancePtr = (InstanceType*)mappedResource.pData; memcpy(instancePtr, (void*)m_instanceList, (sizeof(InstanceType) * i_instanceCount)); deviceContext->Unmap(m_instanceBuffer, 0); } [/CODE] , where m_instanceList is an array of InstanceType holding all information on the position and rotation per triangle. Of course, theFrame(...) function gets called once per frame. Then I use the shader as provided and replace instancePosition with [b]instanceRotation[/b],which should make my triangles slide out to the right. [CODE] PixelInputType TextureVertexShader(VertexInputType input) { PixelInputType output; // Change the position vector to be 4 units for proper matrix calculations. input.position.w = 1.0f; Here is where we use the instanced position information to modify the position of each triangle we are drawing. // Update the position of the vertices based on the data for this particular instance. input.position.x += input.[b]instanceRotation[/b].x; input.position.y += input.[b]instanceRotation[/b].y; input.position.z += input.[b]instanceRotation[/b].z; // Calculate the position of the vertex against the world, view, and projection matrices. output.position = mul(input.position, worldMatrix); output.position = mul(output.position, viewMatrix); output.position = mul(output.position, projectionMatrix); // Store the texture coordinates for the pixel shader. output.tex = input.tex; return output; } [/CODE] But when I run it (complete without errors), the triangles stay still on the screen. Even when using [b]instancePosition[/b] again. They move however, if I change the semantic type of inputPosition to TEXCOORD and update the position in the Frame procedure, but even then I get no motion from the instanceRotation. Which leads me to think, that my InputElementLayoutDescription is wrong. But how? I have tried many a combination already, but don't understand. Can anyone enlighten me with their ideas?
  9. Primitive Performance

    I'm goin to try option one as soon as I get home. I hadn't thought about this option so far. Correct me if I am wrong, but it seems to me that option 2) would not be practicable in my case either, when I want to update each matrix on each update sequence? So I would go through the list of CTriangles, which store some yaw, pitch and roll data, generate a new Matrix, put it into the second vertex Buffer. But then? I have not seen matrices stored in vertex buffers before? Why would I do this? Wouldn't that mean I have to get data back from my VertexBuffer, which I have also not seen before?
  10. Primitive Performance

    Thank you very much, but that's not quite what I intended to do. I suppose there should also be a way to rotate and translate each triangle individually. Does anyone know some more suitable approaches to this requirement? Over night I came up with a different idea: What about loading the vertex data into the buffer once on init, and then storing the offset and length of the vertex buffer data with my objects, instead of loading them in each draw call? Would that make my program reasonably faster, if I just needed to apply a world matrix for each triangle per draw call but not loading the triangle into the buffer?
  11. Hey everyone, i'm quite new to DirectX programming, and have read quite a lot of tutorials. They mostly left me with this question though: I think i understand the procedure of rendering ONE triangle: Create triangle vertices on init and store them in any field of my DirectX manager class On each Draw call, do - Map the vertex buffer - Put the vertices in - Unmap - Set the world transform for this triangle - Present - start over But then I get tired of this single triangle and want to start with any given number. To do so, I assume instead of one field, i'd use a list of a custom Class CTriangle, which holds position in the world, a simple triangle vertex array, and the world rotation. To print those, I'd loop over this list and do the aforementioned for each CTriangle. Needless to say, this works for a list size of 10 to 100, but say I want to render 10000 triangles, this becomes very laggy. So the point is, how should I approach this i a better way? How should I render a long list of custom-class objects?