DirectX:着色器问题 [英] DirectX : problems with shaders

查看:114
本文介绍了DirectX:着色器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我正在尝试在顶点着色器上传递2个短裤作为UV坐标,当我尝试创建InputLayout时,创建失败,并显示"Invalid arguments"(无效参数).错误.

I'm tryng to pass 2 shorts as UV coordinate on a vertex shader, when I try to create an InputLayout, the creation is failing with "Invalid argument" error.

如果我将布局和着色器更改为具有两个用于UV的浮动,则它可以正常工作.

If I change the layout and the shader to have two float for UV then it works without problems.

这是我的布局代码:

D3D11_INPUT_ELEMENT_DESC* layouts = new D3D11_INPUT_ELEMENT_DESC[numAttribs];

setAttrib(layouts[0], attrib.name.c_str(), 0, DXGI_FORMAT_R16G16_UINT, 0, attrib.offset)
setAttrib(layouts[1], attrib.name.c_str(), 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, attrib.offset)

这是着色器:

And here is the shader :

cbuffer ModelViewProjectionConstantBuffer : register(b0)
{
	matrix model;
	matrix projectionView;
	matrix textureMatrix;
};

struct VertexShaderInput
{
	float3			pos:	POSITION;
	uint2			uv:		TEXCOORD0; 
};


struct VertexShaderOutput
{
	float4 pos : SV_POSITION;
	float2 uv : TEXCOORD;
};

VertexShaderOutput main(VertexShaderInput input)
{
	VertexShaderOutput output;
	float4 pos = float4(input.pos, 1.0f);

	// Transform the vertex position into projected space.
	pos = mul(pos, model);
	pos = mul(pos, projectionView);
	output.pos = pos;
	float4 uv = float4((float) input.uv.x, (float) input.uv.y, 0, 0);
	uv = mul(uv, textureMatrix);
	output.uv = uv.rg;
	return output;
}


我实际上有两个问题:

1.有人知道为什么它不起作用吗?

1. anyone know why it is not working ?

2.有谁知道如何在WPF表面上使用本机代码时将设备设置为调试?

2. anyone know how to set the device to debug when using native code with a WPF surface ?

谢谢!

推荐答案

您能否确切分享您对create input布局调用的论点?我不知道您的setAttrib助手可能在做什么.

Could you share exactly what are your arguments to the create input layout call?  I can't tell what your setAttrib helper might be doing.

不幸的是,我不认为在使用XAML/D3D互操作模式时可以指定D3D11_CREATE_DEVICE_DEBUG标志,因为Silverlight代表您创建了此D3D设备.

Unfortunately I don't think it is possible to specify the D3D11_CREATE_DEVICE_DEBUG flag when using XAML/D3D interop mode, as Silverlight creates this D3D device on your behalf.


这篇关于DirectX:着色器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆