Sign in to follow this  

issues with D3D10

This topic is 3490 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

im having some major issues with D3D10.... right now im rendering a scene with 100 boxes on a 8600GS... and i get mostly an FPS of 100... however my problem is that sometimes without any apparent reason it drops down to 50-60 FPS... sometimes its stays there sometimes it just goes back up to around 100... and i have no idea whats causing it... ive had this problem for about 2 weeks now without any progress... im pretty sure it has something to do with my rendering code.... but i cant figure out what... and perfHUD doesnt work with my computer... what can i do?... is there any other tool similar to perfhud but doesnt require "instrumental drivers" (which is what doesnt work on my computer)

Share this post


Link to post
Share on other sites
let me guess: does each of those boxes have a different material on it with a dedicated shader. If this is the case the driver-compiler might re-compile your shaders ...
I would just ignore it and move on and create a real scene. Then you can measure much better what is going on. 100 boxes is not very representative for a game scene.

Share this post


Link to post
Share on other sites
im not quite with u....

its 100 boxes using the same shader and same texture... only thing differing is the world matrix...

how can i see if the shader is re-compiled...? i liked the d3d9 debugger... it would tell u if u were doin something wrong in the debugger output... doesnt wseem to work that way in d3d10??

should i rly continue without solving this? if i write more code and make it more complex it will get alot harder to fix it...

also i did some tries... and now its 250 FPS... i dont think ive changed anything... but either way... i dont do ANYTHING in the scene... but after running it for around20-40 seconds the fps drops to 100 fps over several seconds and then go back 250 fps.. its totally random

it doesnt say much but this is how i render it...


std::vector<graphics::IGeometryPtr> SimpleGeometries;
graphics::IEffectPtr SimpleEffect;
graphics::ITexturePtr SimpleTexture;

void onFrameRender()
{
SimpleEffect->SetTexture("baseTexture", SimpleTexture);
SimpleEffect->SetMatrix("ModelViewProjection", camera_->ModelViewProjectionMatrix());

int n = 0;
for ( n = 0; n < SimpleGeometries.size(); ++n)
{
SimpleEffect->SetMatrix("World", SimpleGeometries[n]->WorldMatrix());

SimpleEffect->ApplyPass(0);
SimpleEffect->Render(SimpleGeometries[n]);
}
}






effect class

struct Effect::Implementation
{
Implementation(const std::string& id, RenderDevicePtr pRenderdevice, const std::wstring& filename) : nActivePass_(0)
{
pRenderdevice_ = pRenderdevice;
filename_ = filename;
HRESULT hr = D3DX10CreateEffectFromFile(filename.c_str(),
NULL,
NULL,
"fx_4_0",
D3D10_SHADER_ENABLE_STRICTNESS,
0,
pRenderdevice->Device(),
NULL,
NULL,
&pEffect_,
NULL,
NULL);


if (FAILED(hr))
throw Exception(L"Failed to load effect", hr);

pTech_ = pEffect_->GetTechniqueByIndex(0);
if (!pTech_)
throw Exception(L"Could not find technique in effect file", 0);
}

void SetTechnique(const std::string& techname)
{
pTech_ = pEffect_->GetTechniqueByName(techname.c_str());
if (!pTech_)
throw Exception(L"Could not find specified technique", 0);
}


void Render(graphics::IGeometryPtr geometry, UINT vertexstart)
{
if (!pCurInputLayout_ || !pCurInputLayout_->Equal(geometry->VertexDecleration(), pTech_))
{
pCurInputLayout_.reset();
for (int n = 0; n < vInputlayouts_.size(); ++n)
{
if (vInputlayouts_[n]->Equal(geometry->VertexDecleration(), pTech_))
pCurInputLayout_ = vInputlayouts_[n];
}

if(!pCurInputLayout_)
{
geometry->VertexDecleration()->Lock();
pCurInputLayout_ = InputLayoutPtr(new InputLayout(pRenderdevice_, geometry->VertexDecleration(), pTech_));
vInputlayouts_.push_back(pCurInputLayout_);
}

pRenderdevice_->Device()->IASetInputLayout(pCurInputLayout_->Layout(nActivePass_).get());
}

if(!pCurInputLayout_)
Exception(L"InputLayout not found/created", 0);

geometry->Render(vertexstart);
}


std::wstring filename_;

int nActivePass_;

InputLayoutPtr pCurInputLayout_;
std::vector<InputLayoutPtr> vInputlayouts_;


ID3D10EffectTechnique* pTech_;
ID3D10Effect* pEffect_;
RenderDevicePtr pRenderdevice_;
};

Effect::Effect(const std::string& id, RenderDevicePtr pRenderdevice, const std::wstring& filename) : IEffect(id), pImpl_(new Implementation(id, pRenderdevice, filename))
{
std::wcout <<">> Created Effect: \"" << id.c_str() << "\". (D3D10)\n";
}


void Effect::ApplyPass(int n)
{
HRESULT hr = GetTech()->GetPassByIndex(n)->Apply(0);
pImpl_->nActivePass_ = n;
if (FAILED(hr))
throw Exception(L"Failed to apply technique pass", hr);

pImpl_->pCurInputLayout_.reset();
}

int Effect::ActivePass()
{
return pImpl_->nActivePass_;
}



void Effect::Render(graphics::IGeometryPtr geometry, unsigned int vertexstart)
{
pImpl_->Render(geometry, vertexstart);
}






Geoemtry

#include "D3D10Geometry.hpp"

#include <iostream>

namespace drone{
namespace d3d10{

struct Geometry::Implementation
{

Implementation(RenderDevicePtr renderDevice,
graphics::IVertexDeclerationPtr vertexdecleration,
graphics::IVertexBufferPtr vertexbuffer,
graphics::IIndexBufferPtr indexbuffer = graphics::IIndexBufferPtr())
:
pRenderDevice_(renderDevice),
pVertexDecleration_(vertexdecleration),
pVertexBuffer_(vertexbuffer),
pIndexBuffer_(indexbuffer)
{
worldMatrix_.identity();
}

void Render(UINT vertexstart)
{
pRenderDevice_->Device()->IASetPrimitiveTopology(static_cast<D3D10_PRIMITIVE_TOPOLOGY>(graphics::TRIANGLELIST));
pVertexBuffer_->Bind();

//pVertexDecleration_->Bind(pEffect_);

if (pIndexBuffer_)
{
pIndexBuffer_->Bind();
pRenderDevice_->Device()->DrawIndexed(pIndexBuffer_->Count(), 0, 0);
}
else
{
pRenderDevice_->Device()->Draw(pVertexBuffer_->Count(), vertexstart);
}
}

RenderDevicePtr pRenderDevice_;

graphics::IVertexBufferPtr pVertexBuffer_;
graphics::IIndexBufferPtr pIndexBuffer_;
graphics::IVertexDeclerationPtr pVertexDecleration_;

mat4f worldMatrix_;
};



Geometry::Geometry(const std::string& id,
RenderDevicePtr renderDevice,
graphics::IVertexDeclerationPtr vertexdecleration,
graphics::IVertexBufferPtr vertexbuffer,
graphics::IIndexBufferPtr indexbuffer)
:
IGeometry(id), pImpl_(new Implementation(renderDevice, vertexdecleration, vertexbuffer, indexbuffer))
{
std::wcout <<">> Created Geometry: \"" << id.c_str() << "\". (D3D10)\n";
}


void Geometry::Render(UINT vertexstart)
{
pImpl_->Render(vertexstart);

}

graphics::IVertexBufferPtr Geometry::VertexBuffer()
{
return pImpl_->pVertexBuffer_;
}

graphics::IIndexBufferPtr Geometry::IndexBuffer()
{
return pImpl_->pIndexBuffer_;
}

graphics::IVertexDeclerationPtr Geometry::VertexDecleration()
{
return pImpl_->pVertexDecleration_;
}

const mat4f& Geometry::WorldMatrix()
{
return pImpl_->worldMatrix_;
}

void Geometry::Translate(const vec3f& translation)
{
matrix_translation(pImpl_->worldMatrix_, translation);
}


}
}




inputlayout



class InputLayout
{
public:

InputLayout(RenderDevicePtr pRenderDevice, graphics::IVertexDeclerationPtr vertexdecleration, ID3D10EffectTechnique* pTech)
{
vertDecl_ = vertexdecleration;

D3D10_TECHNIQUE_DESC techDesc;
pTech->GetDesc(&techDesc);
nPasses_ = techDesc.Passes;
techName_ = techDesc.Name;

VertexDeclerationPtr d3d10vertexdecl = boost::shared_polymorphic_cast<VertexDecleration>(vertexdecleration);
for (int n = 0; n < nPasses_; ++n)
{

ID3D10InputLayoutPtr layout;
D3D10_PASS_DESC PassDesc;
pTech->GetPassByIndex(n)->GetDesc(&PassDesc);

HRESULT hr = pRenderDevice->Device()->CreateInputLayout(&d3d10vertexdecl->InputElementDesc()[0],
d3d10vertexdecl->NumElements(),
PassDesc.pIAInputSignature,
PassDesc.IAInputSignatureSize,
&layout);
layouts_.push_back(layout);
}
}

bool Equal(graphics::IVertexDeclerationPtr vertexdecleration, ID3D10EffectTechnique* pTech)
{
D3D10_TECHNIQUE_DESC techDesc;
pTech->GetDesc(&techDesc);
return techDesc.Name == techName_ && vertexdecleration->Equal(vertDecl_);
}

const ID3D10InputLayoutPtr& Layout(int pass)
{
if(pass > layouts_.size())
throw Exception(L"Out of bounds", 0);

return layouts_[pass];
}

private:

graphics::IVertexDeclerationPtr vertDecl_;
LPCSTR techName_;
int nPasses_;
std::vector<ID3D10InputLayoutPtr> layouts_;
};



EDIT: added the inputlayout class

Share this post


Link to post
Share on other sites

This topic is 3490 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this