Jump to content
  • Advertisement
Sign in to follow this  
brekehan

Help with error messages

This topic is 3590 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 finished alot of reorganization of my engine and as I expected nothing was displayed on the first run. Well, I stepped through all the code in the application. Made a checklist of all the steps and everything looks OK. So, second step was to crank up PIX and see what's going on in my shaders. Keep in mind I am very new at using PIX. I captured a frame, selected the draw call: 1) pull up the render view - blank. 2) pull up the mesh view - both pre and post vs have something displayed, but nothing in the viewport. 3) pull up output log - there are 2 errors that I do not understand! Render|Debugger D3D10: ERROR: ID3D10Device::DrawIndexed: The resource return type for component 0 declared in the shader code (FLOAT) is not compatible with the resource type bound to slot 0 of the Pixel Shader unit (UINT). [ EXECUTION ERROR #361: DEVICE_DRAW_RESOURCE_RETURN_TYPE_MISMATCH ] Render|Debugger D3D10: ERROR: ID3D10Device::DrawIndexed: The Shader Resource View in slot 0 of the Pixel Shader unit is using the Format (R32G32B32A32_UINT). This format does not support 'Sample', 'SampleLevel', 'SampleBias' or 'SampleGrad', at least one of which is being used on the Resource by the shader. [ EXECUTION ERROR #371: DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_UNSUPPORTED ] Well this leads me to believe there is something wrong with my pixel shader. I do not know what component 0 is or how to change the format of the pixel shader. In case something obvious is in my HLSL, please point it out for me. Other ideas are also appreciated.
//--------------------------------------------------------------------------------------
// File: default.fx
//
//--------------------------------------------------------------------------------------

#include "EffectPool.fxh"

matrix world : World;

Texture2D textureDiffuse;

SamplerState samplerLinear
{
   Filter = MIN_MAG_MIP_LINEAR;
   AddressU = Wrap;
   AddressV = Wrap;
};


//////// CONNECTOR DATA STRUCTURES ///////////

/* Data from application vertex buffer */
struct VS_INPUT
{
   float3 position : POSITION;
   float3 normal	 : NORMAL;
   float2 uv		 : TEXCOORD0;
   
};

/* Data passed from vertex shader to pixel shader */
struct PS_INPUT
{
   float4 position : SV_POSITION;
   float3 normal   : NORMAL;
   float2 uv       : TEXCOORD0;
};


//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------
// Simply transforms positions and normals
// 
PS_INPUT VS( VS_INPUT input )
{
   PS_INPUT output = (PS_INPUT)0;
   
   // Transform the position
   matrix worldViewProjection = mul(world, view);
   worldViewProjection = mul(worldViewProjection, projection);
   
   output.position = mul(input.position, worldViewProjection );
   
   // Transform the normal
   output.normal = mul(input.normal, world);
   normalize(output.normal);
   
   // Copy the UV 
   output.uv = input.uv;
   
   return output;
}


//--------------------------------------------------------------------------------------
// Pixel Shaders
//--------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------
// Simply shades an object at 100% opacity, with no lights or shadows
//
float4 PS( PS_INPUT input ) : SV_Target
{  
   float4 finalColor = textureDiffuse.Sample(samplerLinear, input.uv);
   finalColor.a = 1;
   
   return finalColor;
}

//--------------------------------------------------------------------------------------
// Techniques
//--------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------
// Renders an object at 100% opacity, with no lights or shadows
//
technique10 RenderDefault
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_4_0, VS() ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, PS() ) );
    }
}

Other ideas are, I changed things to use two vertex streams instead of one, but I doubt that is the problem since all the data seems to make it into the VS OK. Please help. I am stumped.

Share this post


Link to post
Share on other sites
Advertisement
I don't think the problem is the shader it is the data you are binding to the DirectX10 Input Assembler (IA).

Its a problem in your applications render code, post it and someone will give a solution, if its still unsolved in the morning I will post my suggestions

Share this post


Link to post
Share on other sites
After doing some more pondering, I am beginning to suspect this snippet since it seem to correspond to the error messages about UINT and FLOAT mismatch.


//------------------------------------------------------------------------------------------
Texture::Texture(ID3D10Device & device, const std::string & filePath)
:
m_device(device),
m_texture(0),
m_transparent(false),
m_width(0),
m_height(0)
{
// Attempt to load the image file as a resource in R32G32B32A32 format
D3DX10_IMAGE_LOAD_INFO loadInfo;
ZeroMemory(&loadInfo, sizeof(D3DX10_IMAGE_LOAD_INFO));
loadInfo.BindFlags = D3D10_BIND_SHADER_RESOURCE;
loadInfo.Format = DXGI_FORMAT_R32G32B32A32_UINT;

ID3D10Resource * resource = NULL;
if( FAILED(D3DX10CreateTextureFromFile(&m_device, filePath.c_str() , &loadInfo, NULL, &resource, NULL)) )
{
throw BaseException(std::string("Failed to load texture from file: ") + filePath,
"Texture::Texture(ID3D10Device & device, const std::string & filePath)",
"Texture.cpp");
}

// Cast the resource into a 2D texture
D3D10_RESOURCE_DIMENSION type;
resource->GetType(&type);

if( type != D3D10_RESOURCE_DIMENSION_TEXTURE2D )
{
resource->Release();

throw BaseException(std::string("Only 2D textures are supported : ") + filePath,
"Texture::Texture(ID3D10Device & device, const std::string & filePath)",
"Texture.cpp");
}

ID3D10Texture2D * texture = static_cast<ID3D10Texture2D *>(resource);

// Get a description of the texture
D3D10_TEXTURE2D_DESC texDesc;
texture->GetDesc(&texDesc);

// Check if that the texture is in R32G32B32A32 format
if( texDesc.Format != DXGI_FORMAT_R32G32B32A32_UINT )
{
texture->Release();

throw BaseException(std::string("Failed to load texture : ") + filePath + " in R32B32G32A32 uint format",
"Texture::Texture(ID3D10Device & device, const std::string & filePath)",
"Texture.cpp");
}

// Create a shader resource view from the texture for use with directx effects
D3D10_SHADER_RESOURCE_VIEW_DESC srvDesc;
srvDesc.Format = texDesc.Format;
srvDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
srvDesc.Texture2D.MostDetailedMip = 0;
srvDesc.Texture2D.MipLevels = texDesc.MipLevels;

if( FAILED(m_device.CreateShaderResourceView(texture, &srvDesc, &m_texture)) )
{
texture->Release();

throw BaseException(std::string("Failed to create shader resource view : ") + filePath,
"Texture::Texture(ID3D10Device & device, const std::string & filePath)",
"Texture.cpp");
}

// Get the width and height
m_width = texDesc.Width;
m_height = texDesc.Height;

// Release the texture interface now that we have a shader resource view
texture->Release();
}





I suspect it is telling me I must create the shader resource view in a R32G32B32A32_FLOAT format?

Is it not smart enough to convert itself?
What dictates that I am using a float format in the shader code?
What format should I be using?

-------------------------------------------------

Ok, I changed the texture to load in R32B32G32A32_FLOAT format and the errors went away. However, my screen is still blank. I have zero error messages. I still see geometry in preVS and postVS in PIX, but nothing in the viewport.

Perhaps there is something wrong with my transforms?

I'll start another post about it.

[Edited by - brekehan on January 21, 2009 11:56:17 PM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!