Jump to content

  • Log In with Google      Sign In   
  • Create Account

Jason Z

Member Since 04 Feb 2004
Offline Last Active Jul 26 2016 04:26 PM

#5207952 Sending World, View and Projection Matrices To D3D9 Vertex Shader

Posted by Jason Z on 31 January 2015 - 04:14 PM

If you're looking for the function call SetMatrixWithEitherD3D9OrD3D11(...) there ain't no such thing. They are different APIs and they have different methods to accomplish things.

If you choose D3D9, use D3D9 methods. If you choose D3D11, use D3D11 methods.

This, in particular, is the answer to your question.  The point is that you would need to build a small wrapper layer to abstract this particular feature away in order to communize the two APIs. 

#5207887 Ways to render a massive amount of sprites.

Posted by Jason Z on 31 January 2015 - 12:09 PM

Another potential method is to store the sprite info in a buffer resources, and then use an SRV in the vertex shader to grab the data out of it.  The interesting thing that you can do, is to create the vertices completely in the vertex shader, with no vertex buffers required at all!  The general idea is to use your draw call to specify how many vertices are generated, and then use the SV_VertexID semantic value to grab the appropriate data from the SRV.  You would use 4 vertex shader invocations for each of the quads, and the method is relatively efficient.  If you check out the particle storm demo from Hieroglyph 3, there is an example of creating vertices without vertex buffers (although I expand the vertices in the GS as mentioned above).


Regarding the use of instancing, you are probably not going to see an improvement for the use of 4 vertices as your instanced geometry.  In general, unless you are using geometry with 100 or more vertices you won't see much improvement (at least that is general advice, but your particular situation may or may not reflect the general rule of thumb...).

#5207883 Sending World, View and Projection Matrices To D3D9 Vertex Shader

Posted by Jason Z on 31 January 2015 - 11:58 AM

There is no such thing as a constant buffer in D3D9 - instead you set individual registers.  Have you taken a look at some starter D3D9 tutorials yet?

#5207881 "bind slots vs. registers" concern

Posted by Jason Z on 31 January 2015 - 11:55 AM

I have always found that compiling the shader with FXC.exe is a useful learning tool.  This command line tool requires you to tell it the file and the function you are compiling, along with the shader type and target model.  You can create an html output file, which gives you lots of information about the shader, its input resources, and the shader's input and output signatures.


That will tell you about the shader, but you can also programmatically access the same data through the reflection interfaces.  There is examples in my engine (linked in my signature below) about how to use the reflection interface, so feel free to take a look and borrow code as needed.

#5206287 Question about local axes conventions

Posted by Jason Z on 23 January 2015 - 05:57 PM

I would recommend just mimicking whatever you use for the graphics system.  In general, I think the method that you described is common for OpenGL based rendering, while the z-axis is flipped typically for DirectX based rendering.


However, the only important thing is that the sound systems match with the graphical systems.

#5204921 Help, rolling my own D3DX11CreateShaderResourceViewFromFile/Memory

Posted by Jason Z on 17 January 2015 - 08:49 AM

Just another helpful link to understand gamma / linear light spaces: The Importance of Being Linear, from GPU Gems 3.  It helped me quite a bit, so hopefully it can do the same for you!

#5203268 Programming a Level Editor

Posted by Jason Z on 10 January 2015 - 08:21 AM

You could also adapt an existing open source solution, such as Sony's ATF and editor.  Unless you want to learn about GUI programming, it is often better just to reuse an existing solution...

#5202273 Placing Vertices With Mouse Input In DirectX

Posted by Jason Z on 06 January 2015 - 10:42 AM

Do you want the vertices to be in object space, or in world space?  Whichever one you want, you need to provide a homogenous coordinate (3D point with 1 as the w value) and transform it by the inverse of the appropriate matrix.  Your proposed transform above would likely give you world space coordinates.  If you want object space, you need to also include the world transform inside your inverse call.

#5200875 Starting my own game engine - please don't laugh.

Posted by Jason Z on 30 December 2014 - 03:10 PM


Sorry for not to answer earlier, I decided to use visual studio 2012 for an IDE

Just FYI, 2013 is free (in fact, more free than any previous version of VS) as has fairly significant updates and changes over 2012.



That's true, assuming he isn't working for a company that is larger than the allowed size...

#5200874 Starting my own game engine - please don't laugh.

Posted by Jason Z on 30 December 2014 - 03:09 PM

Eric's comments are really spot on - if you accept any of the advice in this thread, re-read his post!  While not as extensive as C4, I have a similar feeling and background with Hieroglyph 3.  It started out as a learning project, and has over time been upgraded, piece by piece, into what it is today.  The only additional caveat that I would add is that instead of throwing away an entire component, be sure to take away whatever you can from it.  Even if it is learning what not to do, there is always information available from a given implementation!


Good luck, and gamedev.net is your friend :)

#5200790 Text-rendering solutions (with international support?)

Posted by Jason Z on 30 December 2014 - 07:50 AM

Washu has recently made some great posts about this: here and here.  Those look to be a good source of information for your investigations!

#5200415 Compute shader: varying the number of threads

Posted by Jason Z on 28 December 2014 - 09:21 AM

Sounds funny. So, the best scenario would be (at least in 1D case) to make groups with the number of threads multiple by 32 and then dispatch enough of these groups. Do they state it explicitely in their documentation that perfomance can be hit that much just if you dont guess the right size? Because you may think that as long as your shader is ok you may expect more or less the same performance in different scaled cases.


It is always better to just try it out and see for yourself how this affects the performance.  It could very well be that you are totally texture bandwidth limited and the threadgroup size won't make much difference - but in general what the others are saying is very relevant.  All other things being equal, it is better to use a multiple of the IHV's threadgroup size suggestions.

#5200414 A few quick questions about compute shaders

Posted by Jason Z on 28 December 2014 - 09:15 AM

Just a small addition to MJP's already great answer: you can check the available feature level without actually creating the device by passing nullptr into the device pointer.  The following function is how I do this in the Hieroglyph 3 framework:

D3D_FEATURE_LEVEL RendererDX11::GetAvailableFeatureLevel( D3D_DRIVER_TYPE DriverType )
	D3D_FEATURE_LEVEL FeatureLevel;

	// If the device has already been created, simply return the feature level.
	// Otherwise perform a test with null inputs to get the returned feature level
	// without creating the device.  The application can then do whatever it needs
	// to for a given feature level.

	if ( m_pDevice ) {
		FeatureLevel = m_pDevice->GetFeatureLevel();
	} else {
		hr = D3D11CreateDevice(
			nullptr );

		if ( FAILED( hr ) ) {
			Log::Get().Write( L"Failed to determine the available hardware feature level!" );
	return( FeatureLevel );

That can allow you to check what feature level you have quickly and easily, and then perform some logic to determine which type and feature level of device to create.

#5200183 Do you put code in your engine/game you don't fully understand?

Posted by Jason Z on 26 December 2014 - 07:35 PM

In general I think most people have used code that isn't theirs.  I think a much more pertinent question is if everyone provides proper credit for the snippet.  There are a few places in Hieroglyph 3 where I link to the StackOverflow topic where some code came from.  In particular, code for converting from std::string to std::wstring is totally ridiculous and complex, but I found a snippet that worked well so I linked to the topic in a comment.  I understand it at a high level, but I couldn't rewrite it from scratch without a reference...

#5200174 openFrameworks for games?

Posted by Jason Z on 26 December 2014 - 06:30 PM

If the framework meets or exceeds your needs, and it is licensed in an acceptable way, then I say go for it.  There are going to be many more 'testers' of the framework than what you will have for your custom system, so there is a great incentive to use an open solution.  In addition, you can get inspiration from other projects that have been posted, and you will have a forum to post questions instead of always having to answer the questions for yourself.


So unless there is a learning motive behind doing your own engine, I would recommend using open frameworks!