DirectX 11 render system - work-in-progress

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
chincillya
Halfling
Posts: 94
Joined: Sun Dec 19, 2004 7:12 pm
Location: Finland
x 3
Contact:

Re: DirectX 10 render system - work-in-progress

Post by chincillya »

We are currently in the process of moving to a new appartment, and of course the net does not work there right now. I'll get back to you ASAP.

Thanks!
"Black holes are the result of God dividing by zero."

http://www.sebastian-ahlman.fi/
User avatar
Red5_StandingBy
Greenskin
Posts: 109
Joined: Mon Jun 26, 2006 1:06 pm
Location: Turkey

Re: DirectX 10 render system - work-in-progress

Post by Red5_StandingBy »

Hi,

I have just started using the DirectX 10 render system. I came across a problem related with constant buffer updates. In my test app, I have two different meshes with different materials that use the same vertex program. It seems the vertex program input parameters are not updated correctly. Debugging shows that in the D3D10HLSLProgram::getConstantBuffer() function, there is an "if" check:

if (!iter->wasInit)

that controls updating the source address for shader parameters. After the first render for the first mesh, the second time getConstantBuffer() is called for the vertex program, the iter->src variable is not updated. So for example, same world matrices are applied to all meshes, etc. When I remove the "if" check, everything is fine.

Thanks in advance for your ideas.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 10 render system - work-in-progress

Post by Assaf Raman »

Can you create a small sample of this and post it?
User avatar
Red5_StandingBy
Greenskin
Posts: 109
Joined: Mon Jun 26, 2006 1:06 pm
Location: Turkey

Re: DirectX 10 render system - work-in-progress

Post by Red5_StandingBy »

Hi,

Here is a link to a set of meshes/materials that I use in my test:
http://rapidshare.com/files/185979396/TestMedia.zip

In any simple Ogre demo app (say Demo_EnvMapping), you can add the following and see the results with the "D3D10HLSLProgram::getConstantBuffer() ... if (!iter->wasInit)" code deleted.

Code: Select all

void createScene(void)
    {
		Entity *entCyl = mSceneMgr->createEntity("cyl", "Cylinder_01.mesh");
		Ogre::SceneNode *nodeCyl = mSceneMgr->getRootSceneNode()->createChildSceneNode ();
		nodeCyl->attachObject(entCyl);
		nodeCyl->setPosition(-200,100,0);
		
		Entity *entGrid = mSceneMgr->createEntity("grid", "Grid.mesh");
		Ogre::SceneNode *nodeGrid = mSceneMgr->getRootSceneNode()->createChildSceneNode ();
		nodeGrid->attachObject(entGrid);
		nodeGrid->setPosition(200,-100,0);
    }
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 10 render system - work-in-progress

Post by Assaf Raman »

I see your problem. I will fix it.
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 10 render system - work-in-progress

Post by Assaf Raman »

Yes, the iter->wasInit shouldn't be there.
I removed it for now.
We do need to add some "update only if something changed" code and support for multiple constant buffers.
Latest code is in the trunk.

Thanks for your help - you did a great job.

If there is anything else you find along the way - post I will help you as fast as I can.
Watch out for my OGRE related tweets here.
User avatar
Red5_StandingBy
Greenskin
Posts: 109
Joined: Mon Jun 26, 2006 1:06 pm
Location: Turkey

Re: DirectX 10 render system - work-in-progress

Post by Red5_StandingBy »

Thanks for the quick fix (and for your hard work in general)

We have a quite complicated DirectX10 rendering plugin for Autodesk Maya. I am trying to port the system to our Ogre based game engine, so I am sure I will be asking for many features along the way. Multiple constant buffers with different update frequencies will be probably first on the list, that is, per scene(cameras,lights), per object(world pos, list of lights affecting object, list of shadow textures), per material(artist parameters) cbuffers.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 10 render system - work-in-progress

Post by Assaf Raman »

Sounds great.
Watch out for my OGRE related tweets here.
User avatar
Red5_StandingBy
Greenskin
Posts: 109
Joined: Mon Jun 26, 2006 1:06 pm
Location: Turkey

Re: DirectX 10 render system - work-in-progress

Post by Red5_StandingBy »

Hi,

I wanted to use PerfHUD with DirectX10 renderer. It did not work with the existing code in OgreD3D10RenderSystem.cpp. So I changed the adapter selection code as described in the PerfHUD user manual:

Code: Select all

// Search for a PerfHUD adapter
UINT nAdapter = 0;
IDXGIAdapter* pAdapter = NULL;
IDXGIAdapter* pSelectedAdapter = mActiveD3DDriver->getDeviceAdapter();
if ( mUseNVPerfHUD )
{
	IDXGIFactory* pDXGIFactory;
		
	HRESULT hr;
	hr = CreateDXGIFactory( __uuidof( IDXGIFactory), (void**)&pDXGIFactory);
			
	if (FAILED(hr))
	{
		OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, "A DX10 Compliant Video Card is Required",
			"D3D10RenderSystem::D3D10RenderSystem" );
	}

	// Search for a PerfHUD adapter
	while( pDXGIFactory->EnumAdapters( nAdapter, &pAdapter ) != DXGI_ERROR_NOT_FOUND )
	{
		if ( pAdapter )
		{
			DXGI_ADAPTER_DESC adaptDesc;
			if ( SUCCEEDED( pAdapter->GetDesc( &adaptDesc ) ) )
			{
				const bool isPerfHUD = wcscmp( adaptDesc.Description, L"NVIDIA PerfHUD" ) == 0;
				if ( nAdapter == 0 || isPerfHUD ) 
				{
					pSelectedAdapter = pAdapter;
				}
				if ( isPerfHUD )
				{
                			driverType = D3D10_DRIVER_TYPE_REFERENCE;
				}
			}
		        ++nAdapter;
		}
	}

	pDXGIFactory->Release();
}
ID3D10Device * device;
if(FAILED(D3D10CreateDevice(pSelectedAdapter,driverType ,0,deviceFlags,D3D10_SDK_VERSION, &device)))			
{
	OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, 
		"Failed to create Direct3D10 object", 
		"D3D10RenderSystem::D3D10RenderSystem" );
}
This change did not immediately work though. I got a weird error in the CreateDepthStencilView() call in the OgreD3D10RenderWindow.cpp. A web search revealed a solution at this forum:
http://www.gamedev.net/community/forums ... _id=460082
[See their last post for recommended changes]
Making the changes to creation of depth stencil texture as described above cleared the issue. Now PerfHUD works for me.
( My system: Vista, GeForce GTX 280 driver 180.48, PerfHUD 6.5 Beta)
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 10 render system - work-in-progress

Post by Assaf Raman »

I will review and commit later today.
User avatar
Red5_StandingBy
Greenskin
Posts: 109
Joined: Mon Jun 26, 2006 1:06 pm
Location: Turkey

Re: DirectX 10 render system - work-in-progress

Post by Red5_StandingBy »

Hi,

Just realized that the issue with CreateDepthStencilView() also appears in D3D10RenderTexture::rebind() when running in PerfHUD. The same solution applies.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 10 render system - work-in-progress

Post by Assaf Raman »

I just committed what you wrote about on your last 2 posts on this thread.
Nice job of finding the solution to the "CreateDepthStencilView" problem.
Watch out for my OGRE related tweets here.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Re: DirectX 10 render system - work-in-progress

Post by sinbad »

Red5_StandingBy wrote:Multiple constant buffers with different update frequencies will be probably first on the list, that is, per scene(cameras,lights), per object(world pos, list of lights affecting object, list of shadow textures), per material(artist parameters) cbuffers.
I've been doing some optimisation of params in the trunk already, and one of my next tasks after this is supporting shared parameter sets - ie parameter data which is not owned by a single pass but is referenced externally. Obviously on Dx10 this can be implemented as shared constant buffers (I've been thinking about how to make the mapping structures from shared area to program slot rendersystem-specific ).

The idea would be to make GpuProgramParameters use a rendersystem-supplied memory area as the physical buffer (other rendersystems would just allocate it in CPU memory), and also the option to create a rendersystem-specific binding structure of that parameter set to a given program (default implementation would be just a named or logical/physical mapping, Dx10 would be the binding of a constant buffer).

Still thinking about the practicalities but that's my initial thoughts.

BTW for future reference, can you submit a contributor license agreement please?
User avatar
Red5_StandingBy
Greenskin
Posts: 109
Joined: Mon Jun 26, 2006 1:06 pm
Location: Turkey

Re: DirectX 10 render system - work-in-progress

Post by Red5_StandingBy »

I just got the changes in the trunk about variability of shader params. It seems these changes are very much parallel to what I had in mind (and to our existing DirectX10 renderer). I can make more comments as I familiarize myself more with the DirectX10 renderer.

I sent the contributor license agreement as well.
User avatar
Red5_StandingBy
Greenskin
Posts: 109
Joined: Mon Jun 26, 2006 1:06 pm
Location: Turkey

Re: DirectX 10 render system - work-in-progress

Post by Red5_StandingBy »

@sinbad: I tried to run my DirectX9 renderer based game with the trunk version. I got into a few problems in my custom scene manager class. One of them is rendering errors in reflective surfaces and was solved by changing the following line SceneManager::renderSingleObject() (line2982)

Code: Select all

mGpuParamsDirty |= (uint16)GPV_PER_OBJECT;
with

Code: Select all

mGpuParamsDirty |= ( (uint16)GPV_PER_OBJECT | (uint16)GPV_GLOBAL );
I need more debugging to do, but a very "early guess" is the change might be needed to update view matrices (which are GPV_GLOBAL).

But other than that, the GPVs seem to work. I had added some auto params of mine own to GpuProgramParameters class and they all seem to work as expected.

@Assaf:
I came across this when testing shadow textures with R32 format. The D3D10Mappings::_getPF() method has many PF_UNKNOWN value returns. Is there a reason for not defining those formats?
Ex:DXGI_FORMAT_R32_FLOAT --> PF_FLOAT32_R
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Re: DirectX 10 render system - work-in-progress

Post by sinbad »

I've split your GPU_GLOBAL issue off to another topic.
http://www.ogre3d.org/forums/viewtopic.php?f=4&t=47309
chincillya
Halfling
Posts: 94
Joined: Sun Dec 19, 2004 7:12 pm
Location: Finland
x 3
Contact:

Re: DirectX 10 render system - work-in-progress

Post by chincillya »

Sorry for the long delay. Our appartment is still a complete mess, you know how it is...

Anyway, I have a new error message from my app that works with DX9 and OpenGL but not with DX10. The following:

Code: Select all

D3D10: CORRUPTION: ID3D10Device::CreateTexture2D: pDesc has Miplevels (value = -2147483648) and ArraySize (value = 1) that are too large when multiplied. [ MISCELLANEOUS CORRUPTION #13: CORRUPTED_PARAMETER1 ]
gets output when running the following code:

Code: Select all

Ogre::Entity* mesh = m_SceneManager->createEntity("menu_board", "menu_board.mesh");
Any idea on how to fix this? If I understand correctly this has to do with the textures that menu_board.mesh reference, but I don't quite undestand what is wrong with them.

Thanks!
"Black holes are the result of God dividing by zero."

http://www.sebastian-ahlman.fi/
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 10 render system - work-in-progress

Post by Assaf Raman »

can you post the textures that menu_board.mesh references and the material file?
Watch out for my OGRE related tweets here.
chincillya
Halfling
Posts: 94
Joined: Sun Dec 19, 2004 7:12 pm
Location: Finland
x 3
Contact:

Re: DirectX 10 render system - work-in-progress

Post by chincillya »

"Black holes are the result of God dividing by zero."

http://www.sebastian-ahlman.fi/
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 10 render system - work-in-progress

Post by Assaf Raman »

I didn't get your error.
Can you help?
Watch out for my OGRE related tweets here.
chincillya
Halfling
Posts: 94
Joined: Sun Dec 19, 2004 7:12 pm
Location: Finland
x 3
Contact:

Re: DirectX 10 render system - work-in-progress

Post by chincillya »

So you tried the material and it worked? That's weird. I'll compile the app with DX10 enabled so you can test. It'll take some work though. I'll get back to you.
"Black holes are the result of God dividing by zero."

http://www.sebastian-ahlman.fi/
User avatar
Red5_StandingBy
Greenskin
Posts: 109
Joined: Mon Jun 26, 2006 1:06 pm
Location: Turkey

Re: DirectX 10 render system - work-in-progress

Post by Red5_StandingBy »

Hi,

Macros specified with "preprocessor_defines" was not working for DX10, so I added the code from DX9 for adding macro arrays to D3DX10CompileFromMemory() call. It seems to work.
A simple copy/paste, but here is also a patch file.

http://www.momentum-dmt.com/Development ... pile.patch
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 10 render system - work-in-progress

Post by Assaf Raman »

I will review and apply later today.
Watch out for my OGRE related tweets here.
User avatar
Red5_StandingBy
Greenskin
Posts: 109
Joined: Mon Jun 26, 2006 1:06 pm
Location: Turkey

Re: DirectX 10 render system - work-in-progress

Post by Red5_StandingBy »

Hi,

I realized "column_major_matrices" directive in program definitions was not applied. Again, I did a little copy/paste from DX9 renderer. It seems to work for me.

Here is a patch for it:

http://www.momentum-dmt.com/Development ... ices.patch
User avatar
Red5_StandingBy
Greenskin
Posts: 109
Joined: Mon Jun 26, 2006 1:06 pm
Location: Turkey

Re: DirectX 10 render system - work-in-progress

Post by Red5_StandingBy »

Hi,

I was bitten by the code in D3D10RenderSystem::_convertProjectionMatrix(). Somehow it all got commented out. Is there a reason for it?
Post Reply