Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 21 Jun 2009
Offline Last Active Today, 04:22 PM

Posts I've Made

In Topic: Trouble passing multiple lights

11 October 2016 - 10:22 AM

And do I then need to bind them like this? deviceContext->VSSetConstantBuffers(0, 1, lightBuffer); deviceContext->PSSetConstantBuffers(0, 1, lightBuffer);


That's correct.

I don't remember how to use the old (and deprecated for a long time now) D3D11 effect system, perhaps it has a call to bind the buffer to both shader stages at once.

[EDIT]: Apparently there is :)


But as you are not using the effect system to bind the buffers but rather call the context yourself, you should bind the buffer to both stages.

In Topic: Trouble passing multiple lights

11 October 2016 - 09:44 AM

Ok another thing I noticed. In which shader are you trying to use the lights? If it is in the Pixel Shader you are not setting the constant buffer, because you bind it only to the vertex shader with deviceContext->VSSetConstantBuffers(0, 1, lightBuffer);


DaSutt is right. You don't bind the CB to the PS. 

In Topic: What's the difference between dot and * in HLSL

10 October 2016 - 08:25 PM

Dot is a dot product.
'*' is a component-wise multiplication.

float4 a, b;
float4 c = a*b; //c = (a.x*b.x,a.y*b.y,a.z*b.z, a.w*b.w)
When you multiply float by float4, the result is float4. The float will be broadcasted to float4.

float a;
float4 b;
float4 c = a*b; //c = (a*b.x,a*b.y,a*b.z,a*b.w)

In Topic: HLSL switch attributes

07 October 2016 - 12:29 PM

FXC will generate

switch v1.x
  case l(5)
  call label0
  call label1
mov o0.xw, r0.xxxy
mov o0.yz, l(0,1.000000,1.000000,0)
label label0
mov r0.xy, l(1.000000,1.000000,0,0)
label label1
mov r0.xy, l(0,0,0,0)

So there's still a 'switch' in the assembly. It just that the statement following the 'case' will be a subroutine call instead of the actual statement.

In Topic: alignment for between shader stages data structure

28 September 2016 - 10:43 AM

HLSL compiler will pad it or pack it?

HLSL compiler uses the same mechanism for GS as for other stages - it will output to virtual registers. The hardware driver will then optimize it based on the underlying architecture.