Jump to content
  • Advertisement

Sobe118

Member
  • Content Count

    18
  • Joined

  • Last visited

Everything posted by Sobe118

  1. I am rendering a large number of objects for a simulation. Each object has instance data and the size of the instance data * number of objects is greater than 4GB. CreateCommittedResource is giving me: E_OUTOFMEMORY Ran out of memory. My PC has 128GB (only 8% ish used prior to testing this), I am running the DirectX app as x64. <Creating a CPU sided resource so GPU ram doesn't matter here, but using Titan X cards if that's a question> Simplified code test that recreates the issue (inserted the code into Microsofts D3D12HelloWorld): unsigned long long int siz = pow(2, 32) + 1024; D3D12_FEATURE_DATA_D3D12_OPTIONS options; //MaxGPUVirtualAddressBitsPerResource = 40 m_device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &options, sizeof(options)); HRESULT oops = m_device->CreateCommittedResource( &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD), D3D12_HEAP_FLAG_NONE, &CD3DX12_RESOURCE_DESC::Buffer(siz), D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&m_vertexBuffer)); if (oops != S_OK) { printf("Uh Oh"); } I tried enabling "above 4G" in the bios, which didn't do anything. I also tested using malloc to allocate a > 4G array, that worked in the app without issue. Are there more options or build setup that needs to be done? (Using Visual Studio 2015) *Other approaches to solving this are welcome too. I thought about splitting up the set of items to render into a couple of sets with a size < 4G each but would rather have one set of objects. Thank you.
  2. Thank you, there seem to be a few good solutions that have been suggested. Currently testing scalability of my app so I borrowed a 32GB card. Interesting issues arrise when going beyond the normal case. Learned a bunch.
  3. I broke up the render items into two sets as an initial solution, made two resources of about 3.8GB, and it works. Just a bit more logic needed to handle when render counts fluctuate 0-max. I plan to experiment more with the 4GB limit when I have time.
  4. Vinterberg, eventually it would matter but I don't think it would for this specific error from CreateCommittedResource. It gives an error when allocating a size greater than 2^32, so I have been testing with just a little over that value. Which is still several GB less than the current GPU card I am using. Also, I am watching my GPU with nvidia-smi so I can see live memory usage.
  5. Hello Hodgman, When checking D3D12_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT MaxGPUVirtualAddressBitsPerResource = 40 MaxGPUVirtualAddressBitsPerProcess = 40 I'm attempting to allocate about 5-12GB so 40 bits would be enough for that. ------------ I will probably use a multiple heap or related method as a workaround later. But still interested if there is a way to allocate >4 GB.
  6. I tried searching "graphics memory manager" and couldn't find any listed limits. On this page, I found the "Max Primitive Count" (The simplest primitive is a collection of points in a 3D coordinate system). So that limitation might be connected to buffers/resources? https://msdn.microsoft.com/en-us/library/windows/desktop/ff476876(v=vs.85).aspx Thanks for the tip.
  7. Sobe118

    Rotational Matrix confusion

    Thanks, that was the right part to look at for the issue.  For my coordinate system the code below created the correct visual appearance (objects are symmetrical on one plane though) rotationRadians = atan2f(unitVector.z, unitVector.x); rotationRadians = atan2f(unitVector.x, -unitVector.z); rotationRadians = atan2f(-unitVector.x, unitVector.z);
  8. I'm having issues with rotating 3D objects towards a location.  As a test I tried to rotate every object towards the origin.    The main part of the code is below along with a resulting image. (fyi my unit system is not standard, x-horazantal, z-depth(vertical from this images perspective), y-up(towards camera)   When the objects are positioned towards a point the flat surface points towards the target, looks perpendicular. The red lines drawn show when the objects point at the center correctly. If I add PI/2 to the rotation then the diagonals point at the center.    The resulting image should form a layered ring like design of  aligned objects.  But it seems to create a series of 4 hyperbolas.    I'm guessing I made a simple error.  float3 origin = {0.0f, 0.0f, 0.0f}; float3 unitVector = normalize(make_float3(origin.x-object.x, origin.y-object.y, origin.z-object.z)); //x,z are the surface plain : y is vertical : atan2f returns -PI to PI float rotationRadians = atan2f(unitVector.x, unitVector.z); XMMATRIX rotateMat = XMMATRIX( cosf(rotationRadians), 0.0f, sinf(rotationRadians), 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, -sinf(rotationRadians), 0.0f, cosf(rotationRadians), 0.0f, 0.0f, 0.0f, 0.0f, 1.0f);
  9. I am looking for exmple code that uses SLI with DirectX11 So far I have found:    Seems like a good reference and fairly up to date http://developer.download.nvidia.com/whitepapers/2011/SLI_Best_Practices_2011_Feb.pdf Old SLI example code for DX9, outdated and difficult to compile. (main issue is not directly applicable to my problem because I use DX11) http://developer.download.nvidia.com/SDK/9.5/Samples/samples.html#slibestpract   I'm sure I could figure out what I need from the first link, but it seems like a waist to re-code everything from scratch if it has already been done.  Is anyone aware of a DirectX 11 example code that demonstrates various SLI usages?  As a side note: I know in certain situations there is no benefit from SLI depending on what is the bottleneck. Does instancing, like millions of objects, work well with SLI?      Thanks
  10. That would be sad   I found a little more.  NVAPI is NVIDIA's core software development kit. I think this is what can help mange SLI.  Also found a site that said the screen must be set to full screen. Windowed doesn't work with SLI (good to know... usually run games in windowed) Currently hoping SLI magically works when I figure out how to switch to full screen.  http://www.geeks3d.com/20101209/tips-how-to-enable-sli-and-crossfire-support-for-opengl-applications/   Not quite related but, I found Alt-Enter is the standard way to go full screen but doesn't work if remote software like Teamviewer is active. (Testing using a remote computer, looks like I will need to go to the computer) Still looking into it. 
  11. I am trying to move a object around a sphere.  The object has its own rotation and forward speed. Then it also has its location.  The location can be used for the creation of the first quaternion but, I do not know how to make the target quaternion from the objects rotation and forward speed.    Almost all of the examples for this type of math are for a camera looking at the origin.  I cant figure out how to convert these examples. Because my object doesn't have a target that it is looking at. 
  12. Sobe118

    Moving around a sphere with quaternions

    I got the code working. I don't intend on using this code for my final program. Like you said it is not so efficient, but was a good way to learn about all this.    float3 up = make_float3(loc[0], loc[1], loc[2]); up = normalize(up); float4 q1 = {up.x, up.y, up.z, 0};   //Turn, yaxis of quat is up-vector of object float turnSpeed = 2.0f * 3.14159265359f / 180.0f; float3 yaxis = {0, 0, 0}; yaxis.x = 2.0f * (q1.x*q1.y + q1.w*q1.z); yaxis.y = 1.0f - 2.0f * (q1.x*q1.x + q1.z*q1.z); yaxis.z = 2.0f * (q1.y*q1.z - q1.w*q1.x); float4 yq = quatFromVectAngel(yaxis, turnSpeed); q1 = multiplyQuat(q1, yq);   float zSpeed = 2.0f * 3.14159265359f / 180.0f; float3 zaxis = {0, 0, 0}; zaxis.x = 2.0f * (q1.x*q1.z - q1.w*q1.y); zaxis.y = 2.0f * (q1.y*q1.z + q1.w*q1.x); zaxis.z = 1.0f - 2.0f * (q1.x*q1.x + q1.y*q1.y); float4 zq = quatFromVectAngel(zaxis, zSpeed); q1 = multiplyQuat(q1, zq);   float walkSpeed = 2.0f * 3.14159265359f / 180.0f; float3 xaxis = {0, 0, 0}; xaxis.x = 1.0f - 2.0f * (q1.y*q1.y + q1.z*q1.z); xaxis.y = 2.0f * (q1.x*q1.y - q1.w*q1.z); xaxis.z = 2.0f * (q1.x*q1.z + q1.w*q1.y); float4 xq = quatFromVectAngel(xaxis, walkSpeed); float4 r = multiplyQuat(q1, xq);
  13. Sobe118

    Moving around a sphere with quaternions

    I just used pos because Olof did, I wanted to be consistent.    float4 multiplyQuat(float4 k, float4 q)  {  float4 n; n.w = k.w*q.w - k.x*q.x - k.y*q.y - k.z*q.z; n.x = k.w*q.x + k.x*q.w + k.y*q.z - k.z*q.y; n.y = k.w*q.y + k.y*q.w + k.z*q.x - k.x*q.z; n.z = k.w*q.z + k.z*q.w + k.x*q.y - k.y*q.x; return n; } I think I see the issue I am not using any matrix in the calculations. I only convert it to a matrix for rendering and never really save that value outside of directX buffers
  14. Sobe118

    Moving around a sphere with quaternions

    Still a bit confused if pos.yaxis() returns the y value of pos, that is just a single value.  Then the single value is used to set a Vec3?  Doses the y pos magically end up in vec3's y?  Or does vec3 look like {pos.y, pos.y, pos.y} I further expanded the code (not working for me):   float3 yaxis = {0, pos.y, 0}; float4 yq = quatFromVectAngel(yaxis, turnSpeed); pos = multiplyQuat(pos, yq);   float3 xaxis = {pos.x, 0, 0}; float4 xq = quatFromVectAngel(xaxis, walkSpeed); float4 result = multiplyQuat(pos, xq);   ----------------------------------------------------------------------- This code is working for me to make a nice slightly off-set rotation. But when using the code below the movement from the objects perspective is not clear.    float4 q2 = quatFromVectAngel(make_float3(0, 1, 0.4f), angleRadian); float4 r = multiplyQuat(pos, q2);
  15. Sobe118

    Moving around a sphere with quaternions

    Maybe I'm not sure how to use quaternions. I assumed the "target" was there the object was going to or looking at.  The object is rotating around the origin, not going to it or looking at it.  What I have is a movement vector in relation to the object x,y,z. But z is always zero because that would be moving away or towards the origin.  Then I have a location vector from the origin to the objects center.    How do I change the location vector based on the movement vector that is from the perspective of the object. 
  16. I am attempting to just draw a few thousand instanced basic spheres that will move around in the scene. Also I need to eventually use both DrawIndexed and DrawIndexedInstanced or DrawInstanced, and beable to change each instances rotation as well but don't need to worry about that atm.    The main question is just how to get the instanced spheres to draw? Currently the instancing version of my program is drawing one flat sphere at position (0,0,0)   There are no compile or run time errors in the code it just doesn't work correctly. Below is what I think is the relevant code. Thanks!   Vertex.cpp const D3D11_INPUT_ELEMENT_DESC InputLayoutDesc::PosNormal[6] = { {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, {"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0}, {"WORLD", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D11_INPUT_PER_INSTANCE_DATA, 1}, {"WORLD", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 16, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, {"WORLD", 2, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 32, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, {"WORLD", 3, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 48, D3D11_INPUT_PER_INSTANCE_DATA, 1 } }; #pragma endregion #pragma region InputLayouts ID3D11InputLayout* InputLayouts::PosNormal = 0; void InputLayouts::InitAll(ID3D11Device* device) { // // PosNormal // D3DX11_PASS_DESC passDesc; Effects::BasicFX->Light1Tech->GetPassByIndex(0)->GetDesc(&passDesc); HR(device->CreateInputLayout(InputLayoutDesc::PosNormal, 6, passDesc.pIAInputSignature, passDesc.IAInputSignatureSize, &PosNormal)); } void InputLayouts::DestroyAll() { ReleaseCOM(PosNormal); } From Basic.fx file cbuffer cbPerFrame { DirectionalLight gDirLights[3]; float3 gEyePosW; float gFogStart; float gFogRange; float4 gFogColor; }; cbuffer cbPerObject { float4x4 gWorld; float4x4 gWorldInvTranspose; float4x4 gWorldViewProj; float4x4 gTexTransform; Material gMaterial; }; // Nonnumeric values cannot be added to a cbuffer. Texture2D gDiffuseMap; SamplerState samAnisotropic { Filter = ANISOTROPIC; MaxAnisotropy = 4; AddressU = WRAP; AddressV = WRAP; }; struct VertexIn { float3 PosL : POSITION; float3 NormalL : NORMAL; row_major float4x4 World : WORLD; uint InstanceId : SV_InstanceID; }; struct VertexOut { float4 PosH : SV_POSITION; float3 PosW : POSITION; float3 NormalW : NORMAL; }; VertexOut VS(VertexIn vin) { VertexOut vout; // Transform to world space space. vout.PosW = mul(float4(vin.PosL, 1.0f), vin.World).xyz; vout.NormalW = mul(vin.NormalL, (float3x3)vin.World); // Transform to homogeneous clip space. vout.PosH = mul(float4(vin.PosL, 1.0f), gWorldViewProj); return vout; } Creating buffer instanced object's locations D3D11_BUFFER_DESC instBuffDesc; ZeroMemory( &instBuffDesc, sizeof(instBuffDesc) ); instBuffDesc.Usage = D3D11_USAGE_DEFAULT; instBuffDesc.ByteWidth = sizeof(InstancedData) * OBJECTCOUNT; instBuffDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; instBuffDesc.CPUAccessFlags = 0; instBuffDesc.MiscFlags = 0; HR(md3dDevice->CreateBuffer( &instBuffDesc, NULL, &segmentInstanceBuffer)); Updating buffer in UpdateScene() //Copy Data to buffers for(int i = 0; i < OBJECTCOUNT; ++i) { //XMStoreFloat3(&objVector[i], XMVectorSet(segList[i].loc[0], segList[i].loc[1], segList[i].loc[2], 0.0f)); XMMATRIX sphereOffset = XMMatrixTranslation(segList[i].loc[0], segList[i].loc[1], segList[i].loc[2]); XMStoreFloat4x4(&objVector[i].World, sphereOffset); } md3dImmediateContext->UpdateSubresource( segmentInstanceBuffer, 0, NULL, &objVector, 0, 0); Relevant code from the Draw (I think) UINT strides[2] = {sizeof(Vertex::PosNormal), sizeof(InstancedData)}; UINT offsets[2] = {0,0}; md3dImmediateContext->IASetInputLayout(InputLayouts::PosNormal); ID3D11Buffer* vbs[2] = {mSphereVB, segmentInstanceBuffer}; md3dImmediateContext->IASetVertexBuffers(0, 2, vbs, strides, offsets); md3dImmediateContext->IASetIndexBuffer(mSphereIB, DXGI_FORMAT_R32_UINT, 0); world = XMLoadFloat4x4(&mSphereWorld); worldInvTranspose = MathHelper::InverseTranspose(world); Effects::BasicFX->SetWorld(world); Effects::BasicFX->SetWorldInvTranspose(worldInvTranspose); Effects::BasicFX->SetWorldViewProj(worldViewProj); Effects::BasicFX->SetMaterial(mSphereMat); activeTech->GetPassByIndex(p)->Apply(0, md3dImmediateContext); md3dImmediateContext->DrawIndexedInstanced(mSphereIndexCount, OBJECTCOUNT, 0, 0, 0); Let me know if there is any more code that I should show, Thanks! 
  17. I just re did the project a bit to fix the issue.    solved
  18. When I changed it to :  // Transform to homogeneous clip space. vout.PosH = mul(float4(vout.PosW, 1.0f), gViewProj); I had the shape drawn everywhere (not a sphere any more, covered screen)   When I changed it to this :  // Transform to homogeneous clip space. vout.PosH = mul(float4(vin.PosL, 1.0f), gViewProj); It is no longer a flat, and looks like a normal sphere, but there is only one stationary.    I know for sure the location data is being created. I, cant seem to verify the information going to the Buffer (no symbol for the dll, and cant seem to download) but I dont think that's the issue.   Im confused why I lost reputation, but I still have a problem...   So if this is correct why does is mess up all my visuals?  vout.PosH = mul(float4(vout.PosW, 1.0f), gViewProj);
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!