▸case-01 I need an HLSL code snippet for a basic 3D rendering pipeline in DirectX. Please write a vertex shader and a pixel shader. The vertex shader should transform object coordinates using a model-view-projection matrix stored in a constant buffer. The pixel shader should just output a solid red color. Provide only the shader code. | fail→pass | 8,766 | 9,555 | +9% | 1 | 1 | 0% | 808 | 1,119 | +38% | 0 | 0 | — |
▸case-02 Write a simple HLSL compute shader for a DirectX engine that performs a basic vector addition on two buffers. Define the execution thread count to be 8x8x1 and bind the output UAV. Many people mistakenly use OpenGL-style layout qualifiers here. | pass→pass | 16,740 | 15,310 | -9% | 1 | 1 | 0% | 2,107 | 2,207 | +5% | 0 | 0 | — |
▸case-03 Define the struct for a DirectX HLSL pixel shader input that receives a transformed coordinate and a UV vector from the rasterizer. Ensure the proper system-value tags are present, avoiding bare variable declarations. | pass→pass | 10,864 | 9,024 | -17% | 1 | 1 | 0% | 1,082 | 772 | -29% | 0 | 0 | — |
▸case-04 Write a minimal HLSL vertex shader function that transforms a 3D vertex position to projection space. To ensure the rasterizer interprets the output correctly, how must the return value or out parameter be tagged? Don't use GLSL's gl_Position. | pass→pass | 11,668 | 8,885 | -24% | 1 | 1 | 0% | 1,165 | 898 | -23% | 0 | 0 | — |
▸case-05 Provide an HLSL snippet to sample a 2D color texture using a sampler state in a pixel shader. Make sure to use the proper DirectX register bindings for both resources. Do not use the deprecated tex2D() or GLSL texture() functions. | pass→pass | 10,887 | 9,310 | -14% | 1 | 1 | 0% | 914 | 998 | +9% | 0 | 0 | — |
▸case-06 I am optimizing a DirectX constant buffer layout in HLSL containing three variables: a float3, a single float, and a float4. To minimize padding waste across 16-byte register boundaries, in what sequential order should they be declared? Show the cbuffer block. | pass→pass | 16,594 | 14,156 | -15% | 1 | 1 | 0% | 2,180 | 2,051 | -6% | 0 | 0 | — |
▸case-07 Create the return structure for an HLSL pixel shader in DirectX that writes to two different color attachments for a G-Buffer. Instead of writing to gl_FragData arrays, use the explicit HLSL tags for multiple render targets. | pass→pass | 10,966 | 10,474 | -4% | 1 | 1 | 0% | 1,422 | 1,122 | -21% | 0 | 0 | — |
▸case-08 In an HLSL compute shader, declare a shared memory array of 64 integers to be accessed and modified by threads within the same thread group. Avoid the standard C++ thread_local or GLSL shared keywords. | pass→pass | 8,645 | 11,636 | +35% | 1 | 1 | 0% | 699 | 1,097 | +57% | 0 | 0 | — |
▸case-09 Write the function signature for a DirectX HLSL Geometry Shader that takes a point primitive and outputs a stream of triangles. Do not use standard arrays; use the specific HLSL template object for the output. | pass→pass | 10,006 | 8,885 | -11% | 1 | 1 | 0% | 899 | 863 | -4% | 0 | 0 | — |
▸case-10 Write an HLSL compute shader snippet that performs an atomic addition on a globally accessible raw integer buffer. Developers familiar with CUDA or GLSL might try atomicAdd, but what is the correct HLSL intrinsic function? | pass→pass | 8,599 | 13,220 | +54% | 1 | 1 | 0% | 1,571 | 1,419 | -10% | 0 | 0 | — |
▸case-11 Declare a read-only buffer of a custom LightData struct in HLSL for a DirectX pipeline, ensuring it is explicitly bound to the first shader resource view slot. Avoid uniform buffer syntax. | pass→pass | 4,596 | 3,368 | -27% | 1 | 1 | 0% | 846 | 760 | -10% | 0 | 0 | — |
▸case-12 Write an HLSL helper function to calculate the diffuse lighting intensity given a normal and light direction. The result must be clamped between 0 and 1. Do not use max(0, x) or clamp()—use the specific HLSL intrinsic optimized for zero-to-one bounds. | pass→pass | 3,733 | 10,229 | +174% | 1 | 1 | 0% | 701 | 954 | +36% | 0 | 0 | — |
▸case-13 I need to smoothly interpolate between two color float4s in an HLSL pixel shader based on a scalar weight. Give the one-line return statement. Avoid branching instructions. Note: many developers accidentally use the GLSL mix() function here. | pass→pass | 4,262 | 4,976 | +17% | 1 | 1 | 0% | 760 | 928 | +22% | 0 | 0 | — |
▸case-14 Write an HLSL pixel shader snippet that cancels rendering for the current pixel if the sampled texture alpha is less than 0.5. Developers coming from GLSL often try to use the discard keyword, but what is the standard HLSL intrinsic function? | pass→pass | 6,744 | 5,563 | -18% | 1 | 1 | 0% | 1,335 | 1,207 | -10% | 0 | 0 | — |
▸case-15 Define an HLSL vertex shader input struct for instanced rendering, where you need to read the ID of the current instance being drawn. Avoid the GLSL gl_InstanceID built-in variable. | pass→pass | 7,182 | 10,897 | +52% | 1 | 1 | 0% | 1,340 | 1,238 | -8% | 0 | 0 | — |
▸case-16 In an HLSL vertex shader, transform a float4 position vector 'pos' by a float4x4 matrix 'mat'. DirectX uses row-major by default, but what intrinsic function should be used for the multiplication? Some mistakenly use the standard '*' operator. | pass→pass | 8,542 | 6,937 | -19% | 1 | 1 | 0% | 1,505 | 1,204 | -20% | 0 | 0 | — |
▸case-17 Define the input parameter for an HLSL compute shader main function that needs to know its global execution coordinate across the entire dispatch grid. Do not use gl_GlobalInvocationID. | pass→pass | 3,764 | 3,428 | -9% | 1 | 1 | 0% | 737 | 757 | +3% | 0 | 0 | — |
▸case-18 Write an HLSL pixel shader that modifies and outputs a custom depth value to the depth buffer instead of returning a color. What specific system-value semantic must the return value be tagged with? Don't use gl_FragDepth. | pass→pass | 8,270 | 8,769 | +6% | 1 | 1 | 0% | 1,144 | 1,499 | +31% | 0 | 0 | — |
▸case-19 Declare a 2D texture in HLSL that a compute shader can both read from and write to. Bind it to the first unordered access view slot. Avoid the OpenGL image2D type. | pass→pass | 3,665 | 4,929 | +34% | 1 | 1 | 0% | 651 | 893 | +37% | 0 | 0 | — |
▸case-20 I have raw binary vertex data in an HLSL compute shader without a specific struct format. Declare a buffer that allows reading 32-bit unsigned integers from raw byte offsets, bound to resource slot 2. | pass→pass | 3,266 | 9,403 | +188% | 1 | 1 | 0% | 615 | 1,385 | +125% | 0 | 0 | — |
▸case-21 In an HLSL cbuffer, I have a float 'alpha' and a float3 'color'. I want to explicitly pack the 'color' starting at the second 32-bit component (the 'y' component) of the first 16-byte vector register. Show the variable declarations using explicit packing keywords. | pass→pass | 6,952 | 5,297 | -24% | 1 | 1 | 0% | 1,059 | 1,150 | +9% | 0 | 0 | — |
▸case-22 I am writing a fragment shader in GLSL for an OpenGL 4.5 application. I need to output a single vec4 color. Show me the main function and the variable declaration for the output. | pass→pass | 4,344 | 3,980 | -8% | 1 | 1 | 0% | 768 | 815 | +6% | 0 | 0 | — |
▸case-23 Write a basic compute shader in Metal Shading Language (MSL) for iOS that adds two arrays of floats. Show the kernel function signature with thread position parameters. | pass→pass | 8,806 | 7,291 | -17% | 1 | 1 | 0% | 1,654 | 1,483 | -10% | 0 | 0 | — |
▸case-24 Provide a Vulkan GLSL vertex shader that takes a vec3 position in layout location 0 and transforms it using a Push Constant matrix. | pass→pass | 5,983 | 4,067 | -32% | 1 | 1 | 0% | 893 | 855 | -4% | 0 | 0 | — |