Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7046675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:40:44+00:00 2026-05-28T02:40:44+00:00

I’m trying to port my DX9 volume renderer to a DX10 version. Currently, i’m

  • 0

I’m trying to port my DX9 volume renderer to a DX10 version. Currently, i’m stuck at the following error:

D3D10: ERROR: ID3D10Device::DrawIndexed: The view dimension declared in the shader code does not match the view type bound to slot 0 of the Pixel Shader unit. This is invalid if the shader actually uses the view (e.g. it is not skipped due to shader code branching). [ EXECUTION ERROR #354: DEVICE_DRAW_VIEW_DIMENSION_MISMATCH ]

My guess is that I’m not sending the 2D and/or 3D textures (shader resources) to the shader in the correct way; or do not use them in the correct (dx10) way. The DX9 code was something like the following (simplified for the sake of this question):

HRESULT hr;
int nVertexShaderIndex = 0;

// Setup the 2D Dependent Lookup Texture
hr = m_pDevice->SetTexture(0, lookupTexture); // lookupTexture is a LPDIRECT3DTEXTURE9
if (hr != D3D_OK) {
        //handle error
}

m_pDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
m_pDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
m_pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
m_pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);

// Maximum Intensity 
m_pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE);    // Enable Alpha blend
m_pDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE);    // 1 * SRC color
m_pDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE);   // 1 * DST color
m_pDevice->SetRenderState( D3DRS_BLENDOP, D3DBLENDOP_MAX);   // MAX blend
m_pDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );           // Disable Z

A 3D volume texture with the actual data is send in a similar manner. The corresponding pixel shader code:

PS_OUTPUT Main(VS_OUTPUT vsIn,
               uniform sampler2D lookupTexture : TEXUNIT0,
               uniform sampler3D dataTexture   : TEXUNIT1)
{
  PS_OUTPUT psOut; 
  float dataValue;

  psOut.color = SampleWith2DLookup(vsIn.TexCoord0,
                                   lookupTexture,
                                   dataTexture,
                                   dataValue);
  return psOut;
}

float4 LookupIn2DTexture(float value, 
                         uniform sampler2D lookupTexture)
{
  float2 lutCoord;
  float4 outColor;

  // Build a 2D Coordinate for lookup
  lutCoord[0] = value;
  lutCoord[1] = 0.0f; 

  outColor = tex2D(lookupTexture, lutCoord);
  return(outColor);
}


float4 SampleWith2DLookup(const float3 TexCoord, 
                          uniform sampler2D lookupTexture, 
                          uniform sampler3D dataTexture,
                          out float dataValue)
{
  float  value;
  float4 outputColor;

  value = Sample(TexCoord, dataTexture);
  outputColor = LookupIn2DTexture(value, lookupTexture);

  dataValue = value;

  return(outputColor);
}

In DX10 we can simplify some of the shader code (as far as I understand). I create an empty texture and fill this texture with map()/unmap(). Next I bind it as a shader resource to my PS. The c++ and shader code become the following:

// CREATE THE EMPTY TEXTURE
D3D10_TEXTURE2D_DESC desc;
ZeroMemory(&desc, sizeof(desc));
desc.Width = 4096;
desc.Height = 1;
desc.ArraySize = 1;
desc.MipLevels = 1;
desc.Format = GetHardwareResourceFormatDX10();
desc.Usage = D3D10_USAGE_DYNAMIC;
desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
desc.SampleDesc.Count = 1;      

hr = m_pDeviceDX10->CreateTexture2D(&desc, NULL, &lookupTexture);

bind to shader:

// SEND TO SHADER 
ID3D10ShaderResourceView* pTexDepSurface = NULL;
D3D10_SHADER_RESOURCE_VIEW_DESC srvDesc;
D3D10_TEXTURE2D_DESC desc;
pTexDep->GetDesc( &desc );
srvDesc.Format = desc.Format;
srvDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
srvDesc.Texture2D.MipLevels = desc.MipLevels;
srvDesc.Texture2D.MostDetailedMip = desc.MipLevels -1;
hr = m_pDeviceDX10->CreateShaderResourceView(pTexDep, &srvDesc, &pTexDepSurface);
if (FAILED(hr)) {
        //handle here
}
m_pDeviceDX10->PSSetShaderResources(0,1, &pTexDepSurface);

Use in shader:

Texture2D LookupTexture : register(t0);
SamplerState LookupSampler : register(s0);

Texture2D VolumeTexture : register(t1);
SamplerState VolumeSampler : register(s1);

PS_OUTPUT Main(VS_OUTPUT vsIn,
               uniform sampler2D lookupTexture : TEXUNIT0,
               uniform sampler3D dataTexture   : TEXUNIT1)
{
  PS_OUTPUT psOut; 
  float dataValue;

  dataValue = VolumeTexture.Sample(VolumeSampler,vsIn.TexCoord0);
  psOut.color = LookupTexture.Sample(LookupSampler,dataValue);
  return psOut;
}

Note that it is just an educated guess that the error is introduced by this code. If the code above looks correct to you, please respond so as well (in comments). In that case, a new direction to find a solution would be valued.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:40:45+00:00Added an answer on May 28, 2026 at 2:40 am

    After a day’s work I did find my problem; I forgot to recompile my updated shaders. So the DX9 version was still loaded instead of the DX10 version of the shader, very stupid, but also very common mistake.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.