Jump to content

  • Log In with Google      Sign In   
  • Create Account

Jason Z

Member Since 04 Feb 2004
Offline Last Active Today, 09:19 AM

#5200414 A few quick questions about compute shaders

Posted by Jason Z on Today, 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;
	HRESULT hr;

	// 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,
			DriverType,
			nullptr,
			0,
			nullptr,
			0,
			D3D11_SDK_VERSION,
			nullptr,
			&FeatureLevel,
			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!




#5199803 Render Text

Posted by Jason Z 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 Jason Z 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 Jason Z 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 Jason Z 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 Jason Z 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 Jason Z 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 Jason Z 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 Jason Z 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 Jason Z 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 Jason Z 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.




#5192196 D3D11 Graphics Debugging under VS2012 (Missing Call)

Posted by Jason Z on 10 November 2014 - 07:43 PM

That's pretty strange...  for some reason I can't open the log file - it hangs the graphics debugger as soon as I try to open it :(

 

Even without it though - if you see that the vertex buffer is being set to null, can you check it on your CPU call to see if the buffer is null?  The argument should be directly mirrored with what you see in the log file, so what you are passing to the API should be a null as well.  Perhaps the buffer variable is being overwritten somewhere in between?




#5191724 D3D11 Graphics Debugging under VS2012 (Missing Call)

Posted by Jason Z on 07 November 2014 - 02:19 PM


I can send you the vsglog but if some of my API calls are not even showing up, how will that help you?

You are probably not capturing the first frame where the creation of the buffer takes place.  If you have the vsglog, you can see exactly why a primitive isn't showing up - it could be your input assembler configuration (if your buffer doesn't exist for some reason), it could be your VS transformations, it could be clipping/culling, it could vertex order, it could be depth/stencil buffer issues, it could be alpha blending state misconfigured, or it could even be the output merger state isn't right.  With a vsglog you can clearly identify why a particular draw call ends up the way it does.






PARTNERS