Finally, a DirectX 10 video driver for Irrlicht

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Finally, a DirectX 10 video driver for Irrlicht

Post by Nadro »

If you can please put separate patches for instancing and 3d textures. I want to move some textures related stuff from ogl-es to trunk and next merge changes from trunk to shader-pipeline. After this step we'll be able to apply patches for new D3D9 texture types to trunk and D3D11 texture types to shader-pipeline.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Finally, a DirectX 10 video driver for Irrlicht

Post by Granyte »

My session finaly ended i'm gonna try to put my patches up to date


But please Nadro or who ever can fix this CD3D9Driver.cpp is

Code: Select all

MaxTextureUnits = core::min_((u32)Caps.MaxSimultaneousTextures, MATERIAL_MAX_TEXTURES);
when it should be

Code: Select all

MaxTextureUnits = (MATERIAL_MAX_TEXTURES);
the caps are valid only for fixed pipeline and are useless when using shaders so this line is preventing users from using 16 textures in dx9 artificially

and it gets really annoying when ever I try to update my irrlicht I have to hunt wich caps it's listening to it should not be I think I reported this 4 time and even sneaked a fix in my last patch that got integrated to the engine be some one keep changing it back
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Finally, a DirectX 10 video driver for Irrlicht

Post by Nadro »

This is great info :) I'll fix this stuff in trunk and try to merge changes from trunk to shader-pipeline in near future. The ogl-es branch is mostly done, so in near future I'll have much more time for shader-pipeline than before.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Finally, a DirectX 10 video driver for Irrlicht

Post by Granyte »

did something related to mesh manipulator or mesh loading change lately on the fvf branch? cause rightnow I cannot use most of the mesh manipulator methods and the only mesh I have for testing does not render at all
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Finally, a DirectX 10 video driver for Irrlicht

Post by Nadro »

Yes, mesh manipulator was changed due to multiple vertex buffor support. Some mesh manipulator methods are untested (lack of time) thats why some bugs may exist in there. In mesh loaders I just applied minor changes, thats why it should works properly.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Finally, a DirectX 10 video driver for Irrlicht

Post by Granyte »

instancing is working on dx9 I just need to test a bit more and ill upload a patch
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: Finally, a DirectX 10 video driver for Irrlicht

Post by kklouzal »

Like a boss! Amazing accomplishment! Keep up the hard work!
Dream Big Or Go Home.
Help Me Help You.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Finally, a DirectX 10 video driver for Irrlicht

Post by Nadro »

This is really good info!
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Finally, a DirectX 10 video driver for Irrlicht

Post by Granyte »

this should contain only the changes to
IVertexDescriptor
and CVertexDescriptor

https://www.dropbox.com/s/ylw9enqozhh3y ... cing.patch

due to the other modification I have on my CD3D9Driver.cpp I cannot easily create a patch file for it but the changes are only in drawMeshBuffer around line 1620

Code: Select all

void CD3D9Driver::drawMeshBuffer(const scene::IMeshBuffer* mb)
{
    if (!mb || !mb->isVertexBufferCompatible())
        return;
 
    if (!checkPrimitiveCount(mb->getPrimitiveCount()))
        return;
 
    CNullDriver::drawMeshBuffer(mb);
 
    // draw everything
    setRenderStates3DMode();
 
    CD3D9VertexDescriptor* descriptor = (CD3D9VertexDescriptor*)mb->getVertexDescriptor();
    setVertexDescriptor(descriptor);
 
    scene::IIndexBuffer* indexBuffer = mb->getIndexBuffer();
 
    const u32 indexSize = indexBuffer->getIndexSize();
    const u32 indexCount = indexBuffer->getIndexCount();
    const D3DFORMAT indexType = (indexBuffer->getType() == EIT_32BIT) ? D3DFMT_INDEX32 : D3DFMT_INDEX16;
    const scene::E_HARDWARE_MAPPING indexMapping = indexBuffer->getHardwareMappingHint();
    const void* indexData = indexBuffer->getIndices();
 
    scene::IVertexBuffer* vertexBuffer = 0;
 
    u32 vertexCount = 0;
    u32 vertexSize = 0;
    scene::E_HARDWARE_MAPPING vertexMapping = scene::EHM_NEVER;
    u8* vertexData = 0;
    const u32 vertexBufferCount = mb->getVertexBufferCount();
 
    const u32 primitiveCount = mb->getPrimitiveCount();
    const scene::E_PRIMITIVE_TYPE primitiveType = mb->getPrimitiveType();
 
    const bool hwRecommended = (isHardwareBufferRecommend(mb) || vertexBufferCount > 1);
 
    IDirect3DIndexBuffer9* hwIndexBuffer = 0;
    IDirect3DVertexBuffer9* hwVertexBuffer = 0;
 
    u32 streamCount = 0;
    bool PerInstanceBufferPresent = false;
    s32 PerInstanceBufferId = -1;
    s32 IndexedBufferId = -1;
    for (u32 i = 0; i < vertexBufferCount; ++i)
    {
        if ((descriptor->getVertexBufferDataStepRate(i) == EVBDR_PER_INSTANCE))
        {
            PerInstanceBufferPresent = true;
            PerInstanceBufferId = i;
        }
        else if((descriptor->getVertexBufferDataStepRate(i) == EVBDR_PER_VERTEX))
        {
            IndexedBufferId = i;
        }
    }
    for (u32 i = 0; i < vertexBufferCount; ++i)
    {
        vertexBuffer = mb->getVertexBuffer(i);
 
        vertexCount = vertexBuffer->getVertexCount();
        vertexSize = vertexBuffer->getVertexSize();
        vertexMapping = vertexBuffer->getHardwareMappingHint();
        vertexData = static_cast<u8*>(vertexBuffer->getVertices());
 
        // Update Vertex Buffer.
 
        CD3D9HardwareBuffer* vertexBufferObject = (CD3D9HardwareBuffer*)vertexBuffer->getHardwareBuffer();
 
        if (vertexBufferObject)
        {
            if (vertexMapping != scene::EHM_NEVER)
            {
                if (vertexBufferObject->isRequiredUpdate())
                    vertexBufferObject->update(vertexMapping, vertexSize*vertexCount, vertexData);
 
                hwVertexBuffer = vertexBufferObject->getVertexBuffer();
            }
            else
            {
                vertexBuffer->setHardwareBuffer(0);
                hwVertexBuffer = 0;
            }
        }
        else if (vertexMapping != scene::EHM_NEVER && hwRecommended)
        {
            vertexBufferObject = (CD3D9HardwareBuffer*)createHardwareBuffer(vertexBuffer);
            vertexBuffer->setHardwareBuffer(vertexBufferObject);
            vertexBufferObject->drop();
 
            hwVertexBuffer = vertexBufferObject->getVertexBuffer();
        }
        else
        {
            hwVertexBuffer = 0;
        }
 
        if (hwVertexBuffer)
        {
            pID3DDevice->SetStreamSource(i, hwVertexBuffer, 0, vertexSize);
            streamCount = vertexBufferCount;
            if (PerInstanceBufferPresent && (descriptor->getVertexBufferDataStepRate(i)==EVBDR_PER_VERTEX))
            {
                int  count = mb->getVertexBuffer(PerInstanceBufferId)->getVertexCount();
                pID3DDevice->SetStreamSourceFreq(i, D3DSTREAMSOURCE_INDEXEDDATA | count);
            }
            else if (PerInstanceBufferPresent && (descriptor->getVertexBufferDataStepRate(i) == EVBDR_PER_INSTANCE))
            {
                pID3DDevice->SetStreamSourceFreq(i, D3DSTREAMSOURCE_INSTANCEDATA | 1ul);
            }
        }
 
        
        
    }
    
    // Update Index Buffer.
    vertexCount = mb->getVertexBuffer(IndexedBufferId)->getVertexCount();
    CD3D9HardwareBuffer* indexBufferObject = (CD3D9HardwareBuffer*)indexBuffer->getHardwareBuffer();
 
    if (indexBufferObject)
    {
        if (indexMapping != scene::EHM_NEVER)
        {
            if (indexBufferObject->isRequiredUpdate())
                indexBufferObject->update(indexMapping, indexSize*indexCount, indexData);
 
            hwIndexBuffer = indexBufferObject->getIndexBuffer();
        }
        else
        {
            indexBuffer->setHardwareBuffer(0);
            hwIndexBuffer = 0;
        }
    }
    else if (indexMapping != scene::EHM_NEVER && hwRecommended)
    {
        indexBufferObject = (CD3D9HardwareBuffer*)createHardwareBuffer(indexBuffer);
        indexBuffer->setHardwareBuffer(indexBufferObject);
        indexBufferObject->drop();
 
        hwIndexBuffer = indexBufferObject->getIndexBuffer();
    }
    else
    {
        hwIndexBuffer = 0;
    }
 
    if (hwIndexBuffer)
        pID3DDevice->SetIndices(hwIndexBuffer);
 
    renderArray(streamCount > 0 ? 0 : vertexData, vertexSize, vertexCount, hwIndexBuffer ? 0 : indexData, indexType, primitiveCount, primitiveType);
 
    if (hwIndexBuffer)
        pID3DDevice->SetIndices(0);
 
    for (u32 i = 0; i <= streamCount; ++i)
    {
        pID3DDevice->SetStreamSource(i, 0, 0, 0);
        pID3DDevice->SetStreamSourceFreq(i, 1);
    }
}
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Finally, a DirectX 10 video driver for Irrlicht

Post by robmar »

Is this the hardware instancing for DX9?

I´ve read that this will increase performance by off-loading CPU loading of same meshes.

If there is any non-expert level code work/checking, I´d be pleased to lend a hand.
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Finally, a DirectX 10 video driver for Irrlicht

Post by Granyte »

well testing the patch could help me

this patch basically works just like the last one only two differences you signal in the vertex description witch buffer is per instance and witch one is indexed

then you only call drawmeshbuffer instead of the custom methode
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Finally, a DirectX 10 video driver for Irrlicht

Post by Nadro »

I'll try to integrate this patch today.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Finally, a DirectX 10 video driver for Irrlicht

Post by robmar »

As soon as a single download is available I´ll start testing.

If at least one sample works with the new driver it gives a good starting point.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Finally, a DirectX 10 video driver for Irrlicht

Post by Nadro »

Due to some technical problems with my PC I'll probably merge it at the weekend.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Finally, a DirectX 10 video driver for Irrlicht

Post by Granyte »

i'm working on the dx11 driver i got it to compile and render i got a bug with the terrain and some cleanup to do
Post Reply