• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
CdrTomalak

DX11
Making SlimDX tutorial code compatible with old graphics hardware...

0 posts in this topic

You might have seen me post about this problem before, but basically I have just merged the SlimDX tutorial code with Ron Pentons game framework as per his C# Game Programming book.

The problem is, this won't run on my Dell Latitude D600 ([i]DXGI ERROR UNSUPPORTED)[/i], whilst is fine on my slightly old gaming rig with an Nvidia 9800GT. All it's doing is displaying a triangle.

The quesiton is, how can I alter the code to make it compatible with the ATI Radeon Mobility 9000 graphics hardware on the D600? The specificaiton for this GPU says it doesn't even officically support DirectX9!

Here's the code anyways (excuse the lack of comments - I've stripped most of them out shorten this post).

[CODE]
using System;
using System.ComponentModel;
using SlimDX;
using SlimDX.Windows;
using System.Windows.Forms;
namespace BasicWindow_1
{
public class Game : Form
{
// --------------------------------------------------------------------
// static variables
// --------------------------------------------------------------------
static string gametitle = "Test";
static int screenwidth = 640;
static int screenheight = 480;
static bool windowed = true;
static bool graphicslost = false;
static bool paused = false;
// --------------------------------------------------------------------

// --------------------------------------------------------------------
// Direct3D9 object
// --------------------------------------------------------------------
SlimDX.Direct3D9.Direct3D myD3D;
// --------------------------------------------------------------------

// --------------------------------------------------------------------
// Devices
// --------------------------------------------------------------------

SlimDX.Direct3D11.Device graphics = null;
SlimDX.DXGI.SwapChain swapChain = null;

SlimDX.D3DCompiler.ShaderSignature inputSignature = null;
SlimDX.Direct3D11.VertexShader vertexShader = null;
SlimDX.Direct3D11.PixelShader pixelShader = null;

SlimDX.Direct3D11.RenderTargetView renderTarget = null;

SlimDX.Direct3D11.DeviceContext context = null;

// KEYBOARD ...
SlimDX.DirectInput.DirectInput directInput = null;
SlimDX.DirectInput.Keyboard keyboard = null;

// MOUSE ...
SlimDX.DirectInput.Mouse mouse = null;

// SOUND ...
SlimDX.DirectSound.DirectSound sound = null;


// --------------------------------------------------------------------

// --------------------------------------------------------------------
// Vertex Object
// --------------------------------------------------------------------
SlimDX.DataStream vertices = new DataStream(12 * 3, true, true);
SlimDX.Direct3D11.Buffer vertexBuffer = null; // This is set in init geom.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


// ********************************************************************
// Game Constructor!
public Game()
{
ClientSize = new System.Drawing.Size( screenwidth, screenheight );

Text = gametitle;

}
// ********************************************************************


// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// START: Method InitialiseGraphics
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
public void InitialiseGraphics()
{

var description = new SlimDX.DXGI.SwapChainDescription()
{
BufferCount = 2,
Usage = SlimDX.DXGI.Usage.RenderTargetOutput,
OutputHandle = this.Handle,
IsWindowed = true,
ModeDescription = new SlimDX.DXGI.ModeDescription(0, 0, new SlimDX.Rational(60, 1), SlimDX.DXGI.Format.R8G8B8A8_UNorm),
SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
Flags = SlimDX.DXGI.SwapChainFlags.AllowModeSwitch,
SwapEffect = SlimDX.DXGI.SwapEffect.Discard
};

SlimDX.Direct3D11.Device.CreateWithSwapChain(
SlimDX.Direct3D11.DriverType.Hardware,
SlimDX.Direct3D11.DeviceCreationFlags.Debug,
description,
out graphics,
out swapChain
);

// create a view of our render target, which is the backbuffer of the swap chain we just created
using (var resource = SlimDX.Direct3D11.Resource.FromSwapChain<SlimDX.Direct3D11.Texture2D>(swapChain, 0))
renderTarget = new SlimDX.Direct3D11.RenderTargetView(graphics, resource);
// setting a viewport is required if you want to actually see anything
context = graphics.ImmediateContext;
var viewport = new SlimDX.Direct3D11.Viewport(0.0f, 0.0f, this.ClientSize.Width, this.ClientSize.Height);
context.OutputMerger.SetTargets(renderTarget);
context.Rasterizer.SetViewports(viewport);
// load and compile the vertex shader
using (var bytecode = SlimDX.D3DCompiler.ShaderBytecode.CompileFromFile("E:\\MY_AREA\\SharpDevelop_Projects\\SlimDX_StartOver\\BasicWindow_1\\BasicWindow_1\ riangle.fx", "VShader", "vs_4_0", SlimDX.D3DCompiler.ShaderFlags.None, SlimDX.D3DCompiler.EffectFlags.None))
{
inputSignature = SlimDX.D3DCompiler.ShaderSignature.GetInputSignature(bytecode);
vertexShader = new SlimDX.Direct3D11.VertexShader(graphics, bytecode);
}

// load and compile the pixel shader
using (var bytecode = SlimDX.D3DCompiler.ShaderBytecode.CompileFromFile("E:\\MY_AREA\\SharpDevelop_Projects\\SlimDX_StartOver\\BasicWindow_1\\BasicWindow_1\ riangle.fx", "PShader", "ps_4_0", SlimDX.D3DCompiler.ShaderFlags.None, SlimDX.D3DCompiler.EffectFlags.None))
pixelShader = new SlimDX.Direct3D11.PixelShader(graphics, bytecode);


// -----------------------------------------------------------------------
}
// END: Method InitialiseGraphics


// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// ***************** InitializeSound START ****************************
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// Initialize the DirectSound subsystem
public void InitialiseSound()
{
// set up a device
sound = new SlimDX.DirectSound.DirectSound();

sound.SetCooperativeLevel( this.Handle, SlimDX.DirectSound.CooperativeLevel.Normal );
}
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


// ********************************************************************
// *************** InitializeInput START ******************************
// ********************************************************************
// Initialize the DirectInput subsystem
public void InitialiseInput()
{
// set up the keyboard
directInput = new SlimDX.DirectInput.DirectInput();
keyboard = new SlimDX.DirectInput.Keyboard(directInput);

keyboard.SetCooperativeLevel(
this,
SlimDX.DirectInput.CooperativeLevel.Background |
SlimDX.DirectInput.CooperativeLevel.Nonexclusive );
keyboard.Acquire();
// set up the mouse
mouse = new SlimDX.DirectInput.Mouse(directInput);
mouse.SetCooperativeLevel(
this,
SlimDX.DirectInput.CooperativeLevel.Background |
SlimDX.DirectInput.CooperativeLevel.Nonexclusive );
mouse.Acquire();
}
// ********************************************************************

// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// Method InitialiseGeometry
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
public void InitialiseGeometry()
{
vertices.Write(new Vector3(0.0f, 0.5f, 0.5f));
vertices.Write(new Vector3(0.5f, -0.5f, 0.5f));
vertices.Write(new Vector3(-0.5f, -0.5f, 0.5f));
vertices.Position = 0; // Rewind the position after we're done.
// create the vertex layout and buffer
var elements = new[] { new SlimDX.Direct3D11.InputElement("POSITION", 0, SlimDX.DXGI.Format.R32G32B32_Float, 0) };
var layout = new SlimDX.Direct3D11.InputLayout(graphics, inputSignature, elements);

// Once we have our vertex data in memory, we need to load it into
// a Direct3D vertex buffer, which can then be passed into the graphics pipeline.
vertexBuffer = new SlimDX.Direct3D11.Buffer(
graphics,
vertices,
12 * 3,
SlimDX.Direct3D11.ResourceUsage.Default,
SlimDX.Direct3D11.BindFlags.VertexBuffer,
SlimDX.Direct3D11.CpuAccessFlags.None,
SlimDX.Direct3D11.ResourceOptionFlags.None,
0);

// configure the Input Assembler portion of the pipeline with the vertex data
context.InputAssembler.InputLayout = layout;
context.InputAssembler.PrimitiveTopology = SlimDX.Direct3D11.PrimitiveTopology.TriangleList;
context.InputAssembler.SetVertexBuffers(0, new SlimDX.Direct3D11.VertexBufferBinding(vertexBuffer, 12, 0));
// set the shaders
context.VertexShader.Set(vertexShader);
context.PixelShader.Set(pixelShader);
}
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// START: Method RenderFrame
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
public void RenderFrame()
{
// GT 01/06/12:
// From what I can tell, the render frame method
}
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// END: Method RenderFrame
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// ************** ProcessFrame START **********************************
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// Process one iteration of the game loop
protected virtual void ProcessFrame()
{
// process the game only while it's not paused
if( !paused )
{

}
else
System.Threading.Thread.Sleep( 1 );
}
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// Render....
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
protected virtual void Render()
{
if( graphics != null )
{
context.ClearRenderTargetView(renderTarget, new SlimDX.Color4(0.5f, 0.5f, 1.0f));

// draw the triangle
context.Draw(3, 0);
swapChain.Present(0, SlimDX.DXGI.PresentFlags.None);

}
}
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// ******************** Run START *************************************
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// Run the game
public void Run()
{
while( this.Created )
{
// Process one frame of the game
ProcessFrame();
// Render the current scene
// I.e. display graphics to the user in the game form.
Render();
// Handle all events
Application.DoEvents();
}
}
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


// ********************************************************************
// **************** HANDLE WINDOWS EVENTS *****************************
// ********************************************************************
// Handle windows events
protected override void OnLostFocus( EventArgs e )
{
base.OnLostFocus( e );
Paused = true;
}
protected override void OnKeyDown( KeyEventArgs e )
{
base.OnKeyDown( e );
if( e.KeyCode == System.Windows.Forms.Keys.Escape )
{
this.Close();
}
if ( e.KeyCode == System.Windows.Forms.Keys.P )
{
Paused = !Paused;
}
}
// ********************************************************************
// ********************************************************************
// Property to pause/unpause the game, or get its pause state
public bool Paused
{
get { return paused; }
set
{
// pause the game
if( value == true && paused == false )
{
// TO DO
//
//gametimer.Pause();
paused = true;
}
// unpause the game
if( value == false && paused == true )
{
// TO DO
//
//gametimer.Unpause();
paused = false;
}
}
}
// ********************************************************************

// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// START: MAIN
[STAThread]
private static void Main(string[] args)
{
Game game;

try
{
game = new Game();

// Initialise Gfx, Sound, Input, Geometry
game.InitialiseGraphics();
game.InitialiseSound();
game.InitialiseInput();

game.InitialiseGeometry();
game.Show();
game.Run();
}
catch( Exception e )
{
MessageBox.Show( "Error: " + e.Message );
}
}
// END: MAIN
}
}
[/CODE]

EDIT: I might have found something in the SlimDX tutorial. One of the parameters to the SlimDX.Direct3D11.Device.CreateWithSwapChain() method is for Feature Levels:

[i]"The third parameter to the device creation function is an array of feature levels. Feature levels provide a unified method by which Direct3D 11 can run on lower end hardware. Each feature level mandates a specific set of functionality that an adapter must expose, enabling application developers to reliably scale their applications depending on the hardware a user might have. The array allows you to specify a set of feature levels that you’d like Direct3D to try to use. It will try them in order and create a device with the first one that works. You can use the [size=2]Device[/size][size=2].GetSupportedFeatureLevel[/size] method to get the highest feature level currently supported by the primary adapter. If you don’t care to specify a set and just want to use the highest available, you can skip the parameter and use the less generic overload. Once the device has been created, you can access the [size=2]Device[/size][size=2].FeatureLevel[/size] property to see which feature level is currently active. The [url="http://msdn.microsoft.com/en-us/library/ff476148%28VS.85%29.aspx"]10Level9[/url] reference on MSDN gives in-depth details about exactly which portions of the API are available on which feature levels."[/i]

I don't actually use this in my program, but perhaps this is the key to making my program compatible with the old D600?

EDIT: I think I've concluded something, although it's not good.

On my 9800GT rig the following works fine:

[CODE]
SlimDX.Direct3D11.FeatureLevel[] featureLevels = new SlimDX.Direct3D11.FeatureLevel[] { SlimDX.Direct3D11.FeatureLevel.Level_10_0 };
SlimDX.Direct3D11.Device.CreateWithSwapChain(
SlimDX.Direct3D11.DriverType.Hardware,
SlimDX.Direct3D11.DeviceCreationFlags.Debug,
featureLevels,
description,
out graphics,
out swapChain
);
[/CODE]

But when I use FeatureLevel.Level_10_1 or above, I get DXGI ERROR UNSUPPORTED, because this card doesn't support DX11.

I dropped down to FeatureLevel.Level_9_1 on the D600 laptop, but to no avail. Apparently the GPU supports DX8.1 and Shader 1.4, where as the requirements for Level_9_1 are shader model 2.

Oh dear. Still, it was interesting finding out. Edited by CdrTomalak
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • By bowerbirdcn
      hi, guys, how to understand the math used in CDXUTDirectionWidget ::UpdateLightDir 
      the  following code snippet is taken from MS DXTU source code
       
        D3DXMATRIX mInvView;
          D3DXMatrixInverse( &mInvView, NULL, &m_mView );
          mInvView._41 = mInvView._42 = mInvView._43 = 0;
          D3DXMATRIX mLastRotInv;
          D3DXMatrixInverse( &mLastRotInv, NULL, &m_mRotSnapshot );
          D3DXMATRIX mRot = *m_ArcBall.GetRotationMatrix();
          m_mRotSnapshot = mRot;
          // Accumulate the delta of the arcball's rotation in view space.
          // Note that per-frame delta rotations could be problematic over long periods of time.
          m_mRot *= m_mView * mLastRotInv * mRot * mInvView;
          // Since we're accumulating delta rotations, we need to orthonormalize 
          // the matrix to prevent eventual matrix skew
          D3DXVECTOR3* pXBasis = ( D3DXVECTOR3* )&m_mRot._11;
          D3DXVECTOR3* pYBasis = ( D3DXVECTOR3* )&m_mRot._21;
          D3DXVECTOR3* pZBasis = ( D3DXVECTOR3* )&m_mRot._31;
          D3DXVec3Normalize( pXBasis, pXBasis );
          D3DXVec3Cross( pYBasis, pZBasis, pXBasis );
          D3DXVec3Normalize( pYBasis, pYBasis );
          D3DXVec3Cross( pZBasis, pXBasis, pYBasis );
       
       
      https://github.com/Microsoft/DXUT/blob/master/Optional/DXUTcamera.cpp
    • By YixunLiu
      Hi,
      I have a surface mesh and I want to use a cone to cut a hole on the surface mesh.
      Anybody know a fast method to calculate the intersected boundary of these two geometries?
       
      Thanks.
       
      YL
       
    • By hiya83
      Hi, I tried searching for this but either I failed or couldn't find anything. I know there's D11/D12 interop and there are extensions for GL/D11 (though not very efficient). I was wondering if there's any Vulkan/D11 or Vulkan/D12 interop?
      Thanks!
    • By lonewolff
      Hi Guys,
      I am just wondering if it is possible to acquire the address of the backbuffer if an API (based on DX11) only exposes the 'device' and 'context' pointers?
      Any advice would be greatly appreciated
    • By MarcusAseth
      bool InitDirect3D::Init() { if (!D3DApp::Init()) { return false; } //Additional Initialization //Disable Alt+Enter Fullscreen Toggle shortkey IDXGIFactory* factory; CreateDXGIFactory(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&factory)); factory->MakeWindowAssociation(mhWindow, DXGI_MWA_NO_WINDOW_CHANGES); factory->Release(); return true; }  
      As stated on the title and displayed on the code above, regardless of it Alt+Enter still takes effect...
      I recall something from the book during the swapChain creation, where in order to create it one has to use the same factory used to create the ID3D11Device, therefore I tested and indeed using that same factory indeed it work.
      How is that one particular factory related to my window and how come the MakeWindowAssociation won't take effect with a newly created factory?
      Also what's even the point of being able to create this Factories if they won't work,?(except from that one associated with the ID3D11Device) 
  • Popular Now