카메라에서 보낸 8 비트 이미지에 대해 계산을하고 싶습니다. 액세스 방법을 알 수 없습니다.DXGI_FORMAT_R8_UINT 텍스처에 액세스 할 수 없습니다.
if(!g_updateDone) {
D3D11_MAPPED_SUBRESOURCE resource;
resource.pData = g_Images.pData;
resource.RowPitch = 640;
resource.DepthPitch = 1;
okay = pd3dImmediateContext->Map(g_pCurrentImage, 0, D3D11_MAP_WRITE_DISCARD, 0, &resource);
g_updateDone = true;
}
pd3dImmediateContext->PSSetShaderResources(0, 1, &g_pImageRV);
HLSL 파일이 (쿼드 소요, 쿼드로 표시됩니다
D3D11_TEXTURE2D_DESC tDesc;
tDesc.Height = 480;
tDesc.Width = 640;
tDesc.Usage = D3D11_USAGE_DYNAMIC;
tDesc.MipLevels = 1;
tDesc.ArraySize = 1;
tDesc.SampleDesc.Count = 1;
tDesc.SampleDesc.Quality = 0;
tDesc.Format = DXGI_FORMAT_R8_UINT;
tDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
tDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
tDesc.MiscFlags = 0;
V_RETURN(pd3dDevice->CreateTexture2D(&tDesc, NULL, &g_pCurrentImage));
D3D11_SHADER_RESOURCE_VIEW_DESC rvDesc;
g_pCurrentImage->GetDesc(&tDesc);
rvDesc.Format = DXGI_FORMAT_R8_UINT;
rvDesc.Texture2D.MipLevels = tDesc.MipLevels;
rvDesc.Texture2D.MostDetailedMip = tDesc.MipLevels - 1;
rvDesc.ViewDimension = D3D_SRV_DIMENSION_TEXTURE2D;
V_RETURN(pd3dDevice->CreateShaderResourceView(g_pCurrentImage, &rvDesc, &g_pImageRV));
내가 다음 코드로 질감을 업데이트 :
다음
는 텍스처 개체/자원 뷰를 작성하려면 코드입니다 화면에) ://-----------------------------------------------------------------------------------------
// Textures and Samplers
//-----------------------------------------------------------------------------------------
Texture2D <int> g_txDiffuse : register(t0);
SamplerState g_samLinear : register(s0);
//--------------------------------------------------------------------------------------
// shader input/output structure
//--------------------------------------------------------------------------------------
struct VS_INPUT
{
float4 Position : POSITION; // vertex position
float2 TextureUV : TEXCOORD0;// vertex texture coords
};
struct VS_OUTPUT
{
float4 Position : SV_POSITION; // vertex position
float2 TextureUV : TEXCOORD0; // vertex texture coords
};
//--------------------------------------------------------------------------------------
// This shader computes standard transform and lighting
//--------------------------------------------------------------------------------------
VS_OUTPUT RenderSceneVS(VS_INPUT input)
{
VS_OUTPUT Output;
Output.Position = input.Position;
Output.TextureUV = input.TextureUV;
return Output;
}
//--------------------------------------------------------------------------------------
// This shader outputs the pixel's color by modulating the texture's
// color with diffuse material color
//--------------------------------------------------------------------------------------
float4 RenderScenePS(VS_OUTPUT In) : SV_TARGET
{
int3 loc;
loc.x = 0;
loc.y = 0;
loc.z = 0;
int r = g_txDiffuse.Load(loc);
float fTest = (float) r;
fTest = fTest/256;
return float4(In.TextureUV.x, In.TextureUV.y, In.TextureUV.x + In.TextureUV.y, fTest);
}
실행하려고하면 오류가 발생합니다. 교체 할 때 나는 g_pCurrentImage의 데이터를 볼 때 나는 그것을 디버깅 할 때 픽셀 쉐이더 명령이
을 설정, 그것은 단지 표면을 표시 할 수 없습니다라고, 그return float4(In.TextureUV.x, In.TextureUV.y, In.TextureUV.x + In.TextureUV.y, 1);
DirectX를 디버거 (PIX와 이 경우) 첫 번째 줄만 무시하면 도달하지 않으므로 디버깅 할 수 없습니다. 이 문제를 어떻게 처리 할 것인가에 대한 선택권이 없어 졌으므로, 기본적인 수학적 지시 만하고 싶습니다. 그러나 픽셀 쉐이더를 작동시킬 수는 없습니다.
X4532 오류가 발생했을 때 셰이더를 컴파일하는 데 사용하는 인수는 무엇이며보고되는 줄 번호는 무엇입니까? "fxc/Tps_4_0/ERenderScenePS"으로 fxc에서 저를 잘 컴파일합니다. –