Jump to content
  • Advertisement
Sign in to follow this  
Steven Ford

Passing integers to Feature Level 9.3 VS (DXGI_FORMAT_R8G8B8A8_UINT)

This topic is 801 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



I'm trying to convert a set of VS/GS/PS from a D3D11 (feature level 11) to be able to run against feature level 9_3 (i.e. try to make the application windows phone compatible). For reference, this is a feature to draw individual droplets of water (in an 8-bit look and feel mode). Each droplet is rendered as a quad (using 2 triangles), using an instancing buffer created per frame. The choice of packing all of the information into a 32bit number is to reduce the total amount of data transferred per frame. Realistically, I could have tens of thousands of droplets per frame to render and so am looking for efficiency. 


To do this, I've been able to migrate the logic from the GS to the CPU and have gotten everything to run nicely, subject to creating the initial DX device @ feature level 11 (whilst still compiling the VS for vs_4_0_level_9_3). With this, I was using:

struct VSInputVertex
	// 0 - x
	// 1 - y
	int2 Position : POSITION;

	// Bits:
	//	17-32	WaterX (units)
	//	 2-16	WaterY (units)
	//	 0-1	Water colour
	uint WaterDetails : NORMAL;


		D3D11_INPUT_ELEMENT_DESC inputLayout[2];
		inputLayout[0].AlignedByteOffset = 0;
		inputLayout[0].Format = DXGI_FORMAT::DXGI_FORMAT_R32G32_SINT;
		inputLayout[0].InputSlot = 0;
		inputLayout[0].InputSlotClass = D3D11_INPUT_CLASSIFICATION::D3D11_INPUT_PER_VERTEX_DATA;
		inputLayout[0].InstanceDataStepRate = 0;
		inputLayout[0].SemanticIndex = 0;
		inputLayout[0].SemanticName = "POSITION";

		inputLayout[1].AlignedByteOffset = 0;
		inputLayout[1].Format = DXGI_FORMAT::DXGI_FORMAT_R32_UINT;
		inputLayout[1].InputSlot = 1;
		inputLayout[1].InstanceDataStepRate = 1;
		inputLayout[1].SemanticIndex = 0;
		inputLayout[1].SemanticName = "NORMAL";

		auto hr = _device->CreateInputLayout(inputLayout,
			ARRAYSIZE( inputLayout ),

At this point, I was super happy as it all appeared to work. Unfortunately, when I create the DX device with explicitly feature level 9.3, the creation of the input layout fails. Using the DEBUG device creation flag, it's complaining about the format used, and from the following link:




I can see that neither of my input formats are valid for the 9.3 feature level. I can change my code for the first item to use floats instead of ints and so that's trivial, but I'm struggling to understand how to convert over the instancing information. I can see that the logical approach for me, assuming that I wish to stay with the heavily compressed bit formula, would be to use 'DXGI_FORMAT_R8G8B8A8_UINT' and change the bit compression slightly (0 = colour information, 1 = low bits for x, 2 = low bits for y, 3 = 0-3 high bits for x, 4-7 high bits for y). However, I'm struggling to see how this 4 byte array could be read in by the vertex shader.


So the question is, how does one specify the use of this format type within a 9.3 compatible shader?


Or, any other suggestions gratefully received.






PS Note that my use of 'NORMAL' as the semantic to identify the bit mask is because that was the only way to get it to compile (couldn't find a more suitable SEMANTIC, am using 'BITMASK' in the vs4_0 level version).

Share this post

Link to post
Share on other sites

My first question would be why do you want to support 9_level_3 hardware? These days almost everyone has at least D3D10. According to http://store.steampowered.com/hwsurvey?platform=pc less than 4% of Steam users have PCs that don't support D3D10 or better.


Because of that, if you really do want to support them, I'd do the simplest thing possible. In this case, that is to use floats for everything in the shader, as D3D9 shaders don't have integer instructions. I'd go with something like:


float2 Position : POSITION;

float4 WaterDetails : NORMAL; // { waterX, waterY, colour, unused }


For the data in the vertex buffer your choices are limited: https://msdn.microsoft.com/en-gb/library/windows/desktop/ff471324(v=vs.85).aspx


I'd suggest storing the position as: DXGI_FORMAT_R32G32_FLOAT, and the water details as: DXGI_FORMAT_R16G16B16A16_SINT.

Edited by Adam_42

Share this post

Link to post
Share on other sites

Hi Adam,


thanks for that. I should have clarified at the beginning what I'm trying to do. I'm under the impression that WP8 is still limited to DX9.3 and hence the desire to try to make my little app phone compatible (yes, I know WP8 doesn't have a good market share and is dead vs. Win 10 mobile etc. but this little project is mainly about the learning experience and I've also got an old WP lying around which'd be nice to actually use for something rather than gathering dust :) ) and I also have a very old netbook which'd be perfect for my daughter to play the little game on and it's woefully underpowered :)


So one question on the approach above, does the DX runtime (or compatibility levels) then map between the data type that I specify in the layout and what's specified in the shader?


Also, taking the next question, given that WP8 has been replaced by Windows 10, am I right in assuming that under Windows 10, there's no longer the limitation of all hardware having to be feature level DX9.3 and instead, I'd be able to use the more advanced features on Win10 mobile? I don't suppose you have a good place to find out the various feature levels supported by the Win10Mobile phones do you? I've looked on the MS site:




and it's not clear from that what the feature level would be for this type of phone? My only real concern is whether or not I have access to geometry shaders, 





Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!