Jump to content

  • Log In with Google      Sign In   
  • Create Account

Jason Z

Member Since 04 Feb 2004
Offline Last Active Sep 03 2016 05:28 AM

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

Posted by 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 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 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 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 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!

#5199803 Render Text

Posted by on 23 December 2014 - 10:31 PM

Do you have access to the Graphics Debugger in Visual Studio?  If so, please take a frame analysis and look through the sequence of operations that have been performed.  This will likely show you why your frame ended up all white - just be sure to follow the operations and it should become more clear as you go.

#5199400 Can't Load Textures

Posted by on 21 December 2014 - 07:33 AM

I doubt anyone is going to dig into your whole project and debug the issue for you.  Generally speaking, when you are asking for help you should let us know what you have already checked.  Is there return codes for the function you are using?  Did you step through the function call and see what is going on inside?  Have you used the graphics debugger to see what is happening from the API point of view?  These are all things you can try for yourself, and then if you still can't find an answer you can post here and tell us what you see.


I don't mean to come off as harsh - but honestly I hope you try to solve the issue on your own before posting.  You will learn much faster, and will need to post questions less frequently.  If you really do get stuck, the forums are always here to help you out...

#5199351 What is faster cbuffer or data textures for MVP matrices?

Posted by on 20 December 2014 - 08:47 PM

It seems like you have a very specific use case in mind - why don't you try out the three methods and time them to see which one is fastest?


The truth is that you will get different answers depending on what else is going on in your game, but trying things out for yourself is always better than relying on what responses you will get here.  There is a big difference in performance depending on the size and shape of your geometry, which GPU you have, and how well your CPU side code is organized.  Profile it, and you will certainly learn something about your code and the methods you are trying to characterize!

#5196880 Create Geometry Shader with Stream Output

Posted by on 07 December 2014 - 06:45 PM

Thank you for your replies.


Did you create your device with the D3D11_CREATE_DEVICE_DEBUG flag enabled? If you do that, you'll get error messages in the debugger output telling you why API calls failed.


I create the device without that flag, I'll try to put it in and see if there will be error messages.




The geometry shader is compiling, but the "CreateGeometryShaderWithStreamOutput" call will give me a null geometryShader value.


This is an indicator that your GS code is valid but the actual GS bytecode created by compilation won't run on your hardware (compilation doesn't do hardware validation, creation does).  I see that you're compiling with "gs_5_0" so the first thing you should check is that your hardware actually supports shader model 5.



I'm running the program with a geforce gtx 860m, which fully supports shaders v. 5!

Which feature level did you create your device with?  Even if your hardware is capable, you can easily request a lower feature level and cap yourself regarding shader level!

#5196879 How can I get started with the Hieroglyph3 framework?

Posted by on 07 December 2014 - 06:43 PM

That usually means that the Lua project built fine (since it has zero dependencies) and that the Hieroglyph3 library failed, causing all the applications to fail too.  The issue is likely due to the fact that you are using VS2013, and the nuget package is installed for 2012.  If you uninstall the NuGet package for VS2012 from the package manager, and then install the VS2013 version, it should probably work out for you.


I am in the process of updating to VS2013, so it shouldn't be too long before I do this update and push it to the repo.

#5196633 How can I get started with the Hieroglyph3 framework?

Posted by on 06 December 2014 - 09:59 AM

Thank you for your interest in the book and framework - sorry it took a while for me to see this thread...  If you are using VS2012, all of the pre-requisites should already be installed and ready to run.  The NuGet package for DirectXTK should automatically download, or if you disabled automatic downloads you should be prompted about downloading it.


Regarding the older versions of the framework, there is information in the documentation about what commit level was released with the book.  However, the book samples focus on the GPU side of the samples, so you can safely use the latest version and follow along just fine.  This was done intentionally, so that the CPU side could evolve over time while still keeping the samples relevant.


When you have questions like this, it could be faster to post them in the Hieroglyph discussions forum.  There have been a few other questions like this as well, so you might be able to find an answer right away too.  (plus I get email notifications of new discussions, so I will see your post right away...)


EDIT: you don't have to modify any of the settings for linking or includes - all of those should already be set up relative to the project folder.  Just open the Hieroglyph3_Desktop.sln file, rebuild all, and it should take off on its own.  Also be sure to set the desired project as the startup project (which you can do by right clicking it and choosing "Set As Startup Project").

#5195908 Alpha blending

Posted by on 02 December 2014 - 12:13 PM

The main reason that alpha blending is slower is due to the fact that you aren't just writing memory - you first have to read the existing pixel values, perform the blend operation, and then write again.  So you are increasing the per-pixel operations performed, and you are significantly increasing the bandwidth being consumed.


Is it possible for you to do the blending in the pixel shader instead of in the blend unit?  I wouldn't be afraid to experiment a little and see if you can do something better, but just don't get sidetracked into searching for 0.5 ms time improvement until it becomes apparent that you need that time!

#5195815 Should I keep a dev/programming journal?

Posted by on 01 December 2014 - 08:00 PM

I actually do both - I keep a daily written journal for sketching and working out problems, and then I keep a journal here on Gamedev.net to put more polished ideas and progress updates out there.  As the others have mentioned, it is motivating to some degree, and in general I find it beneficial to get other people's inputs on your work.


I have also found that the number of comments varies quite a bit, but if you put in the effort to post good content, people will be viewing it for sure.

#5195813 how to create gui buttons with DirectX 11?

Posted by on 01 December 2014 - 07:56 PM

Yeh i understand you render 2 triangles to make a quad, but can you just specify screencoords for the vertexbuffer and it will understand the vertices are pretransform through the pipeline?

You can do that, but like unbird says, you need a vertex shader no matter what.  You can make your vertex shader just pass through your pre-transformed vertices without modification, so you can sort of emulate how it worked in D3D9.  As far as creating vertices with 4 coordinates, that isn't an issue at all - you have pretty much free will to create vertex layouts of the size and type that you want.

#5194161 Best way to Create a Grid

Posted by on 22 November 2014 - 02:22 PM

Who needs buffers anyway ? wink.png

cbuffer Parameters
	uint Rows;
	matrix WorldViewProjection;

void LineGridVS(uint vid: SV_VertexID,
	out float4 color: COLOR,
	out float4 position: SV_Position)
    // which row ?
    uint n = vid / 2;	
    // line start or end (column coordinate)
    position.x = (vid % 2) * Rows;	
    // row coordinate (modulo needed for later flip to work)	
    position.z = n % (Rows + 1);
    position.y = 0;
    position.w = 1;
    // center around origin
    position.xz -= (Rows / 2);		
    color = float4(1,0,0,1);
    // rows or columns ? flip x and z (and also give a different color)
    if(n > Rows)
        position.xz = position.zx;
        color = float4(0,1,0,1);
    position = mul(position, WorldViewProjection);		
Don't bind neither vertex nor index buffer nor input layout. Call with context->Draw((rows + 1) * 4, 0); (Edit: Line list topology). Anything else (centering around camera and snapping) can be done with the transformation, as pointed out.

Nice weekend y'all!

Edit2: Minor corrections.



That's a easy way to get a grid on the screen, but it may take more GPU effort than is really needed.  It is usually sufficient just to make a grid and store it in some vertex/index buffers, and then you can easily transform the vertices and simply rasterize the geometry.  It will eliminate the vertex work being done to generate the lines, at the cost of a little bit of bandwidth.