Jump to content
  • Advertisement

Naruto-kun

Member
  • Content Count

    202
  • Joined

  • Last visited

Community Reputation

452 Neutral

About Naruto-kun

  • Rank
    Member

Personal Information

  • Interests
    Programming
  1. Hi guys Looking for resources on emulating the illumination and after glow of CRT oscilloscope displays, like on these old radar scopes. So far my google searches aren't returning anything useful. Any suggestions?
  2. Resolved. UAV slot needs be >= number of RTVs
  3. Hi guys I am getting this very weird error on my OMSetRenderTargetsAndUnorderedAccessViews call. The UAV is a simple buffer 32 bytes in size containing 2 float4s, and the pixel shader using compiles fine. My OMSetRenderTargetsAndUnorderedAccessViews looks like this: devcon->OMSetRenderTargetsAndUnorderedAccessViews(1, &rtv, NULL, 0, 1, &pTFLIRUAV, uavos); D3D11 CORRUPTION: ID3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews: Fourth parameter out of range. [ MISCELLANEOUS CORRUPTION #16: CORRUPTED_PARAMETER4] Any ideas?
  4. Naruto-kun

    What is a Word worth?

    The best way to become fluent in any language (programming languages are no exception) is to use it.
  5. brushtype.x is a constant buffer flag for switching between solid and hatch brushes. brushtype.y is the hatch brush type (of which there can be over 100). fclip is just a flag telling the shader that a clip region is active, so it will sample the clip texture and discard any pixels outside of the clip mask. I'm not so sure about that. The fmod does absolutely get hit when I step through the instructions in VS2017 shader debug. But for some reason the texcoord input is either being normalized (I only ever see values of 0.5 if I put it in a local variable), or it is not being interpolated.
  6. Hi guys I am having a rather odd pixel shader problem. I have attempted to implement a simple horizontal hatch brush pattern using the y dimension of a 2D quad, where it alternates colors every 4 pixels. It works in my C# test app, but not in my C++ project. Here is my shader code: struct PS_INPUT { float4 p : SV_POSITION; float2 t : TEXCOORD0; float2 tc : TEXCOORD1; }; float4 PS_FILL(PS_INPUT input) : SV_Target { if (fclip != 0) { float clip = ClipTex.SampleLevel(Sample, input.tc, 0); if (clip == 0.0f) discard; } if (brushtype.x == 1) return color1; else { if (brushtype.y == 100) { if (fmod(input.t.y, 8) <= 4.0f)//Fault is here return color1; else return color2; } else return color2; } } When the quad is passed to the pixel shader, I put actual normalized texture coordinates in the tc member of PS_INPUT, which are used for sampling a mask texture for clip regions. The t member however, gets the actual dimensions of the quad in pixels. So for the top left quad t would be 0,0, while the bottom right quad would have width, height in t. Below is a screenshot where you can see the C# app's output. As you can see, the alternating color pattern is clearly working in the brown half of the attitude indicator display. Here is my C++ program's output: Now I must stress that the 2 programs are using functionally identical code, as well as completely identical shader code. I also ran the VS2017 graphics debugger on my program to check the values going into PS_INPUT::t in my geometry shader, and I saw the expected pixel dimensions. But when I check the pixel shader, it tells me that input.t.y's debug info has been optimized away, even though I explicitly disabled optimization and enabled shader debugging during shader compilation. So I tried storing input.t.y into a local variable, which consistently showed a value of 0.5 no matter which pixel I selected for debugging. So for some reason DX11 is either normalizing my TEXCOORD inputs, or it is not linearly interpolating in the area between the vertex positions of the quad. Any ideas?
  7. Hi guys Anyone got any suggestions on how to handle center/right justified quadsprites for text? My current method works fine for single line text but not multi line.
  8. Naruto-kun

    VS2015 Graphics Diagnostics crash

    Yeah upgrading to VS2017 was what solved it.
  9. Naruto-kun

    VS2015 Graphics Diagnostics crash

    Aaand now it is back again....And nothing seems to resolve it. Funny though, it only crashes on draw calls that have some element that doesn't make it to the pixel shader. If everything output from the geometry shader appears in the pixel shader it works fine.
  10. Naruto-kun

    SampleLevel only returns 0s

    And now having tried a structured buffer I want to scream: !Why didn't I try this ages ago!!!!
  11. Naruto-kun

    SampleLevel only returns 0s

    I normally leave it to the compiler to set the registers and then make my code adjust, but I tried manually setting them now as described above, but to no avail. Still get only 0s.
  12. Naruto-kun

    SampleLevel only returns 0s

    Maybe there is a better way to get the data I am after though. Below is the code for the entire geometry shader. It generates a max of 8 quads per point for the purpose of rendering an array of short strings (8 characters per string max). The two texture objects in question contain the texture coordinates (which double for quad size) and character spacing data. Is there a better way than 2D/1D textures to store and access this data? Texture2D StrRect; Texture2D StrOS; SamplerState Sample; struct STRARRAY_INPUTG { int4x2 str : STRDATA; int len : STRLEN; uint id : VERTEXID; }; //pixel shader inputs struct PS_INPUT { float4 p : SV_POSITION; float2 t : TEXCOORD0; float2 tc : TEXCOORD1; }; cbuffer STRBUFFER { float4x4 strxform; float4 strrect; float4 strarraymod; float4 strfont; float2 strscale; float2 strnorm; int2 stralign; int2 sarray; }; [maxvertexcount(80)] void GS_DRAWSTRARRAY(point STRARRAY_INPUTG s[1], inout TriangleStream<PS_INPUT> triStream) { PS_INPUT v; float osx = 0; float osy = 0; float4 rect = strrect; if (sarray.x > 0) { if (sarray.x == 1) rect.xy += float2(strarraymod.xy*float(s[0].id)); if (sarray.x == 2) rect.xy += float2(fmod(strarraymod.x*float(s[0].id), strarraymod.z), fmod(strarraymod.y*float(s[0].id), strarraymod.z)); } float cx = 0; float cy = 0; float max_x = 0; float yos = 0; int slen = s[0].len; float lcnt = 0; for(uint j = 0; j < 8; j++) { if (j < (uint)s[0].len) { int c = s[0].str[j%4][j / 4]; switch (c) { case 13: break; case 10: cx = 0; cy += strfont.x; slen--; lcnt++; break; default: { //float2 tex = float2(float(c) / 256.0f, 0); float4 _r = StrRect.Load(uint3(c, 0, 0)); float4 os = StrOS.Load(uint3(c, 0, 0));//.SampleLevel(Sample, tex, 0); cx += os.x; yos = os.y; float advance = float(_r.z - _r.x); cx += (advance + os.z); if (cx > max_x) max_x = cx; } break; } } } rect.z = rect.z == 0 ? max_x : rect.z; rect.w = rect.w == 0 ? strfont.y + cy + (lcnt*yos) : rect.w; if (stralign.x == 0) osx = rect.x; if (stralign.x == 1) osx = rect.x - (rect.z * 0.5f); if (stralign.x == 2) osx = rect.x - rect.z; if (stralign.y == 0) osy = rect.y; if (stralign.y == 1) osy = rect.y - (rect.w * 0.5f); if (stralign.y == 2) osy = rect.y - rect.w; cx = 0; cy = 0; yos = 0; slen = s[0].len; lcnt = 0; //Left Side for (uint i = 0; i < (uint)s[0].len; i++) { if (j < (uint)s[0].len) { int c = s[0].str[i % 4][i / 4]; switch (c) { case 13: break; case 10: cx = 0; cy += strfont.x; slen--; lcnt++; break; default: { float4 _r = StrRect.SampleLevel(Sample, float2(float(c) / 256.0f, 0), 0); float4 os = StrOS.SampleLevel(Sample, float2(float(c) / 256.0f, 0), 0); cx += os.x; yos = os.y; float advance = float(_r.z - _r.x); float ysize = float(_r.w - _r.y); float tx = strfont.z; float ty = strfont.w; if ((c > 32 && c < 126) || advance > 1.0f || ysize > 1.0f) { float4 p = mul(float4(float2(cx + osx, cy + yos + osy + ysize)*strscale, 0, 1.0f), strxform); v.p = p*float4(strnorm*2.0f, 1.0f, 1.0f); v.p.x -= 1.0f; v.p.y = -v.p.y + 1.0f; v.t = float2(float(_r.x*tx), float(_r.w*ty)); v.tc = float2((v.p.x + 1.0f) * 0.5f, (-v.p.y + 1.0f) * 0.5f); triStream.Append(v); p = mul(float4(float2(cx + osx, cy + yos + osy)*strscale, 0, 1.0f), strxform); v.p = p*float4(strnorm*2.0f, 1.0f, 1.0f); v.p.x -= 1.0f; v.p.y = -v.p.y + 1.0f; v.t = float2(float(_r.x*tx), float(_r.y*ty)); v.tc = float2((v.p.x + 1.0f) * 0.5f, (-v.p.y + 1.0f) * 0.5f); triStream.Append(v); p = mul(float4(float2(cx + osx + advance + (os.x > 0 ? os.x : 0), cy + yos + osy + ysize)*strscale, 0, 1.0f), strxform); v.p = p*float4(strnorm*2.0f, 1.0f, 1.0f); v.p.x -= 1.0f; v.p.y = -v.p.y + 1.0f; v.t = float2(float(_r.z*tx), float(_r.w*ty)); v.tc = float2((v.p.x + 1.0f) * 0.5f, (-v.p.y + 1.0f) * 0.5f); triStream.Append(v); p = mul(float4(float2(cx + osx + advance + (os.x > 0 ? os.x : 0), cy + yos + osy)*strscale, 0, 1.0f), strxform); v.p = p*float4(strnorm*2.0f, 1.0f, 1.0f); v.p.x -= 1.0f; v.p.y = -v.p.y + 1.0f; v.t = float2(float(_r.z*tx), float(_r.y*ty)); v.tc = float2((v.p.x + 1.0f) * 0.5f, (-v.p.y + 1.0f) * 0.5f); triStream.Append(v); triStream.RestartStrip(); } cx += (advance + os.z); } break; } } } }
  13. Naruto-kun

    SampleLevel only returns 0s

    So then I guess the next question is, how do we figure out if the texture is actually being loaded into that texture object in the shader....
  14. Naruto-kun

    SampleLevel only returns 0s

    The only call that returns anything would be the CreateSamplerState call. The other calls (GSSetShaderResources/GSSetSamplerState) are all type void and as such cannot return any value even if I wanted them to. I have checked in the VS2015 shader debugger to see what values are being sent to the shader (like that "c" variable) and I know that they are valid. The problem is isolated at the attempt to sample the textures. This is why I asked in my previous reply if texture loading/sampling is even supported in a geometry shader. I would show all the code but it is a pretty big function. I double checked all object pointers in the debugger and did all the narrowing down before I made this post so I can assure you those aren't involved. The vertex buffer is valid and showing valid data in VS Graphics analyser and so are the textures. Just so we are clear, I normally don't come asking for help unless I have exhausted a good many hours searching on my own . I did all the narrowing down/isolating work before I made this post, so I could keep things short and sweet and not waste your time on other wild goose chases.
  15. Naruto-kun

    SampleLevel only returns 0s

    Quite sure. If there was a return failure my sampler would be a null value and that would show up in my debugging. It always comes back with a valid address however, and I have used that same sampler in other areas of my code and gotten the desired effect (point sample vs linear sample). @CortexDragon I just tried filling my texture with solid color (each channel has a value of 100.0f, can do this because it is not a normalized texture but a R32G32B32A32_FLOAT). Also tried this in conjunction with the Load and array style methods of accessing my texture objects. No luck though. Still only returns 0s. On a side note, I tried commenting out my GSSetShaderResources calls and got no warnings from my debug device during the draw call and also got the same 0,0,0,0 return. This is why I asked in my first post if there is some way to find out where should my textures be bound. Perhaps I should be asking the question, is texture loading/sampling even supported in a geometry shader? I know the Sample method (not SampleLevel) is not supported in vertex and geometry shaders.
  • 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!