Advertisement Jump to content
  • Advertisement

xhcao

Member
  • Content Count

    9
  • Joined

  • Last visited

Community Reputation

2 Neutral

About xhcao

  • Rank
    Newbie

Personal Information

  • Role
    DevOps
  • Interests
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I want to implement one situation. There is a DXGI_FORMAT_R32G32B32A32_FLOAT format texture, its desc is as below, D3D11_TEXTURE2D_DESC desc; desc.Width = 1 desc.Height = 1 desc.MipLevels = 1; desc.ArraySize = 1; desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; I want read this texture content with Texture2D<uint4> variable in compute shader, and save its content in other texture with DXGI_FORMAT_R32G32B32A32_UINT format. My compute shader is like below, Texture2D<uint4> readTexture : register(t0); RWTexture2D<uint4> writeTexture: register(u0); [numthreads(1, 1, 1)] void main(CS_INPUT input){ writeTexture[uint2(0, 0)] = readTexture[uint2(0, 0)]; } But there is always a runtime error when I create a shader resource view with DXGI_FORMAT_R32G32B32A32_UINT or DXGI_FORMAT_R32G32B32A32_FLOAT. D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; srvDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT or DXGI_FORMAT_R32G32B32A32_UINT; srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; srvDesc.Texture2D.MostDetailedMip = 0; srvDesc.Texture2D.MipLevels = 1; If srvDesc.Format is DXGI_FORMAT_R32G32B32A32_FLOAT, the error is as below, D3D11 ERROR: ID3D11DeviceContext::Dispatch: The resource return type for component 0 declared in the shader code (UINT) is not compatible with the Shader Resource View format bound to slot 0 of the Compute Shader unit (FLOAT). This mismatch is invalid if the shader actually uses the view (e.g. it is not skipped due to shader code branching). [ EXECUTION ERROR #361: DEVICE_DRAW_RESOURCE_RETURN_TYPE_MISMATCH] If srvDesc.Format is DXGI_FORMAT_R32G32B32A32_UINT, the error is as below, Message 0: ID3D11Device::CreateShaderResourceView: The Format (0x3, R32G32B32A32_UINT) is invalid, when creating a View; the Resource was already created with a fully qualified Format, which is not castable (0x2, R32G32B32A32_FLOAT). I want to know there is any ways to implement this situation in D3D11 without creating a temp texture and copying to/back the content to temp texture. Thank you. I know that OpenGL ES 3.1 could implement this situation, the compute shader could be as below, #version 310 es precision highp uimage2D; layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout (rgba32ui, binding=0) readonly uniform uimage2D u_image0; layout (rgba32ui, binding=1) writeonly uniform uimage2D u_image1; void main (void) { ivec2 pos = ivec2(gl_GlobalInvocationID.xy); imageStore(u_image1, pos, imageLoad(u_image0, pos)); } Call APIs as below, glBindTexture(GL_TEXTURE_2D, texture[0]); glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32F, kWidth, kHeight); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, kWidth, kHeight, GL_RGBA, GL_FLOAT, kInputValue1); glBindTexture(GL_TEXTURE_2D, texture[1]); glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32UI, kWidth, kHeight); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, kWidth, kHeight, GL_RGBA_INTEGER, GL_UNSIGNED_INT, kInputValue2); glBindImageTexture(0, texture[0], 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA32UI); glBindImageTexture(1, texture[1], 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA32UI); glDispatchCompute(1, 1, 1);
  2. Is Direct3D 11 an api function like glMemoryBarrier in OpenGL? For example, if binds a texture to compute shader, compute shader writes some values to texture, then dispatchCompute, after that, read texture content to CPU side. I know, In OpenGL, we could call glMemoryBarrier before reading to assure that texture all content has been updated by compute shader. How to handle incoherent memory access in Direct3D 11? Thank you.
  3. Does sync be needed to read texture content after access texture image in compute shader? My simple code is as below, glUseProgram(program.get()); glBindImageTexture(0, texture[0], 0, GL_FALSE, 3, GL_READ_ONLY, GL_R32UI); glBindImageTexture(1, texture[1], 0, GL_FALSE, 4, GL_WRITE_ONLY, GL_R32UI); glDispatchCompute(1, 1, 1); // Does sync be needed here? glUseProgram(0); glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer); glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, texture[1], 0); glReadPixels(0, 0, kWidth, kHeight, GL_RED_INTEGER, GL_UNSIGNED_INT, outputValues); Compute shader is very simple, imageLoad content from texture[0], and imageStore content to texture[1]. Does need to sync after dispatchCompute?
  4. Before using void glBindImageTexture( GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
  5. Sorry, I did not understand you clearly. What is the same space? What is the meaning that the registers are shared between descriptors. I need to implement two HLSL RWTexture2D binding to the same resource on D3D11. Is it possible? In my opinion, if separate registers on D3D11, the two RWTexture2D variable must be bound to different resource.
  6. In Direct3D 11, Could I define two RWTexture2D resource variables which share the same register in pixel shader as below, RWTexture2D<float4> tex1 : register(u0); RWTexture2D<float4> tex2 : register(u0); Compile error: error X4500: overlapping register semantics not yet implemented 'u0' It seems that it is illegal to define as above. The reason to define as above is that I want to these two resource variable bind the same texture. I try to create two different unodered access views, and their resources are the same texture. But Two UAVs conflict if they share a subresource (and therefore share the same resource), reference to https://msdn.microsoft.com/en-us/library/windows/desktop/ff476465(v=vs.85).aspx
  7. Thank you. As we all known, unordered access views(UAVs) are available on all shader stages, and the UAVs that are shared across all pipeline stages. For example, a UAV that is bound at slot 0 at the output-merger stage is available at slot 0 to VS/HS/DS/GS/PS. If a RWTexture2D variable are declared the same in vertex shader and pixel shader. Does the compiler ensure to assigned the same slot for the two variables? The vertex shader and pixel shader all declare a variable as below, RWTexture2D<float4> texture; In OpenGL, if two uniform exist in vertex shader and pixel shader respectively, with the same name, they are bound the the same binding value. Does d3d11 is like it?
  8. Thank you for your reply. I have another question, for D3D11, if I declare a RWTexture2D variable without specifying the register in compute shader, for example RWTexture2D<float4> texture; when I call void CSSetUnorderedAccessViews( [in] UINT StartSlot, [in] UINT NumUAVs, [in, optional] ID3D11UnorderedAccessView *const *ppUnorderedAccessViews, [in, optional] const UINT *pUAVInitialCounts ); How I know the “StartSlot” for HLSL texture variable. Does it has a default slot for non-register variable, like zero?
  9. Hi, I am newer of Direct3D 11, and I want to get help from you. In Direct3D samples, we usually define RWTexture2D variables globally, and use it in functions directly. Is it legal to transfer this variable as a parameter of a user-defined function? RWTexture2D<float4> texture : regiters(u0); void setData(RWTexture2D<float4> tex, float2 data) { tex[uint2(0, 0)] = data; } PS_OUTPUT main(PS_INPUT input) { setData(texture, float2(0.0, 0.0)); PS_OUTPUT output; return output; }
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!