Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been particularly annoyed by a 'bug' for a couple days involving D3DCompile and vertex shaders with constant buffers. I'm assuming the bug is my fault (missing flag or small nuance of the poorly documented API).

During my asset compile process I compile this vertex shader:

cbuffer Frame : register(b0) {
  float4x4 model_view_proj;
  float4x4 inv_model;
  float4x4 inv_view;
  float4x4 inv_projection;

struct VS_INPUT {
  float3 position  : POSITION;
  float2 tex_coord : TEXCOORD0;
  float3 normal    : NORMAL;
  float3 binormal  : BINORMAL;

struct VS_OUTPUT {
  float4 position  : POSITION;
  float2 tex_coord : TEXCOORD0;

  OUT.position = mul(IN.position, Frame.model_view_proj);
  OUT.tex_coord = IN.tex_coord;
  return OUT;

With this code:

const D3D_SHADER_MACRO defines[] = {
  { "VERTEX_SHADER", "1" },
  { "D3D11",         "1" },
  { NULL, NULL },

  src, src_len,

I have verified (by stepping through) that my ID3DInclude implementation works and all input data is correct. However, I receive a E_FAIL with an associated error message:

error X3004: undeclared identifier 'Frame'

What gives?

share|improve this question
up vote 2 down vote accepted

Constant buffers don't create a namespace; their members are visible at global scope. So instead of Frame.model_view_proj you just want model_view_proj.

share|improve this answer
Thanks! Makes sense in retrospect; it's a natural extension to DX9. – devbug Jan 16 '13 at 7:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.