Jump to content

  • Log In with Google      Sign In   
  • Create Account

Calling all IT Pros from Canada and Australia.. we need your help! Support our site by taking a quick sponsored surveyand win a chance at a $50 Amazon gift card. Click here to get started!

directx user

Member Since 03 Jun 2012
Offline Last Active Apr 27 2015 10:45 AM

Posts I've Made

In Topic: X3000 using enum in hlsl shader

15 December 2013 - 06:40 AM

Well thats unfortunate, I dont know why enum is listed in the msdn then. 



Maybe they are only reserving it to implement it later.But anyway thx for the quick explanation.


But anyway I dont know, why it would be so difficult to implement something simple as enums, which is only a mater of replacing strings with numbers.

In Topic: Exceptions using createcomputeshader

07 October 2013 - 10:44 AM

Thank you very much, I didn´t even validated the device pointer, as I knew my other Shaders compiled fine with the device. I unluckily forgot there to be another device declared inside the class overwriting the definition of the one outside the scope of the class. The devicepointer was not assigned to that one yet and was a zero pointer...


Thank you very much for that hint, now I feel really bad having bothered you two with this laughable problem huh.png .




Besides from that, does anyone has a clue why I end up getting those redefinition warnings after transfering visual c++ 2010 projects to visual studio 2012?

In Topic: Exceptions using createcomputeshader

06 October 2013 - 06:57 PM

Unluckily even when everything except the naked function body is commented i get the same results (the compiled length decreased so I guess its updating the file), even though the array is still pretty large with 1000 lines of code, while everything thats left is:

[numthreads(128, 1, 1)]
void BACKPROPAGATE( uint ID : SV_DispatchThreadID  )


There are no erros or warnings being displayed about the shader file.


But I have extremly many warnings about makro redefinitions in the context of directx(80) which could eventually aflict that case (I have those warnings since I exported my project from visual c++ 2010 to visual studio 2012). I dont really knwo why.

In Topic: Exceptions using createcomputeshader

06 October 2013 - 06:08 PM

I added the shader definition. I thought the Array would be fixed size, since its getting written into the header file while compiling the project, its definition is

const BYTE backpropshader[] =
...... tons of code......

so I thought I could just use its size to feed the function, relying on the msdn:




I thought the blob method would only be used when creating the shader at runtime using compileshaderfromfile for example?

In Topic: multiple objects performance issue

22 June 2012 - 01:55 PM

thx for your reply, i now got the instancing working but theres anyway still a question that i want to ask:

As i set the vertexbuffers one for the model and the other one for the instance position etc., how does directx knows wich buffer is ment to be the geometrie buffer and which the instance buffer?

I also experienced a graphic bug with using this code:

struct instancedata
XMFLOAT3 Position;
struct texturedvertex
XMFLOAT2 uvkoord;
struct geometry
ID3D11Buffer*		   vertexbuffer;
int vertsanzahl;
ID3D11Buffer*		   indicesbuffer;
int indicesanzahl;
geometry geometrybuffer;
ID3D11Buffer* instancebuffer = NULL;
ID3D11InputLayout*	  vertexlayouttextured = NULL;

init buffers

inp layout:

	D3D11_INPUT_ELEMENT_DESC layout[] =
hr = device->CreateInputLayout( layout, numElements, pVSBlob->GetBufferPointer(),
										  pVSBlob->GetBufferSize(), &vertexlayouttextured );
if( FAILED( hr ) )
  return hr;


UINT trianglebuff = sizeof(texturedvertex);
UINT instancebuff = sizeof(instancedata);
UINT zerooffset = 0;

immediatecontext->IASetInputLayout( vertexlayouttextured );
immediatecontext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY::D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); //Triangle strip
immediatecontext->IASetVertexBuffers( 0, 1, &geometrybuffer.vertexbuffer ,&trianglebuff , &zerooffset ); //set the geometrybuffer
immediatecontext->IASetVertexBuffers( 1, 1, &instancebuffer ,&instancebuff , &zerooffset ); //set the instance buffer

immediatecontext->VSSetShader( vertexshader, NULL, 0 ); //set vertexshader
immediatecontext->VSSetConstantBuffers( 0, 1, &matrixbuffer ); //containing world view projection matrices  
immediatecontext->PSSetShader( pixelshader, NULL, 0 ); //set pixelshader
//set textur

immediatecontext->Map( instancebuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &MappedResource);
instancedata *data = ( instancedata* )MappedResource.pData;
//map the instance-data
for (int i = 0; i < sys.bodiesl();i++)
  data[i].Position = XMFLOAT3((float)(sys.hks[i].Position.x / scaler),(float)(sys.hks[i].Position.y / scaler),(float)(sys.hks[i].Position.z / scaler));
immediatecontext->Unmap( instancebuffer, 0 );
//update positions

//draw as many instances as  bodies

hlsl shader:

static const float PI = 3.14159265f;

cbuffer matrix : register( b0 ) //matrices
	row_major matrix World;
	row_major matrix View;
	row_major matrix Projection;

Texture2D<float4> Textur : register(t0);
SamplerState Meshtexturesampler
	AddressU = Wrap;
	AddressV = Wrap;
//textures, sampler

struct VS_INPUT
	float4 Pos : POSITION0;
	float2 Textcoord  : TEXCOORD0;
	float4 instancepos : POSITION1;
struct PS_INPUT
	float4 Pos : SV_POSITION;
	float2 Textcoord  : TEXCOORD0;
//input structures

	PS_INPUT output = (PS_INPUT)0;

	input.Pos.x += input.instancepos.x;
	input.Pos.y += input.instancepos.y;
	input.Pos.z += input.instancepos.z;

	output.Pos = mul(input.Pos,World);
	output.Pos = mul(output.Pos,View);
	output.Pos = mul(output.Pos,Projection);
	output.Textcoord = input.Textcoord;

	return output;

float4 PS( PS_INPUT input) : SV_Target
	return Textur.Sample(Meshtexturesampler,input.Textcoord);

Now the problem is that the second instance always stays at the center of the scene but it should move i guess there are some errors in the input layout declaration?