<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>263481</bug_id>
          
          <creation_ts>2023-10-20 16:11:21 -0700</creation_ts>
          <short_desc>[WGSL] texture1d.read(coord, level): level must be zero</short_desc>
          <delta_ts>2023-10-30 04:04:08 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebGPU</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Mike Wyrzykowski">mwyrzykowski</reporter>
          <assigned_to name="Tadeu Zagallo">tzagallo</assigned_to>
          <cc>tzagallo</cc>
    
    <cc>webkit-bot-watchers-bugzilla</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1986583</commentid>
    <comment_count>0</comment_count>
    <who name="Mike Wyrzykowski">mwyrzykowski</who>
    <bug_when>2023-10-20 16:11:21 -0700</bug_when>
    <thetext>The following WGSL:
            struct Constants {
              level : i32
            };

            @group(0) @binding(0) var&lt;uniform&gt; constants : Constants;
            @group(0) @binding(1) var myTexture : texture_1d&lt;f32&gt;;

            struct Result {
              values : array&lt;f32&gt;
            };
            @group(0) @binding(3) var&lt;storage, read_write&gt; result : Result;

            @compute @workgroup_size(1)
            fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3&lt;u32&gt;) {
              let flatIndex : u32 = 1u * (
                2u * 1u * GlobalInvocationID.z +
                2u * GlobalInvocationID.y +
                GlobalInvocationID.x
              );
              let texel : vec4&lt;f32&gt; = textureLoad(
                myTexture, i32(GlobalInvocationID.x), constants.level);

              for (var i : u32 = 0u; i &lt; 1u; i = i + 1u) {
                result.values[flatIndex + i] = texel.r;
              }
            }

produces this Metal code, but doesn&apos;t compile because &quot;global0.level&quot; in the call to read is expected to be a uint, but it is an int.

#include &lt;metal_stdlib&gt;

using namespace metal;

template&lt;typename T&gt;
T __pack(T unpacked)
{
    return unpacked;
}

template&lt;typename T&gt;
T __unpack(T packed)
{
    return packed;
}

struct type0 {
    int level;
};

struct type1 {
    array&lt;float, 1&gt; values;
};

struct __ArgumentBufferT_0 {
    const constant type0&amp; global0 [[id(0)]];
    texture1d&lt;float, access::sample&gt; global1 [[id(1)]];
    device type1&amp; global2 [[id(3)]];
};

[[kernel]]  void function0(vec&lt;unsigned, 3&gt; parameter0 [[thread_position_in_grid]], constant __ArgumentBufferT_0&amp; __ArgumentBuffer_0 [[buffer(0)]])
{
    device type1&amp; global2 = __ArgumentBuffer_0.global2;
    const constant type0&amp; global0 = __ArgumentBuffer_0.global0;
    texture1d&lt;float, access::sample&gt; global1 = __ArgumentBuffer_0.global1;
    unsigned local0 = (1u * (((2u * parameter0.z) + (2u * parameter0.y)) + parameter0.x));
    vec&lt;float, 4&gt; local1 = global1.read(uint(int(parameter0.x)), global0.level);
    for (unsigned local2 = 0u; (local2 &lt; 1u); local2 = (local2 + 1u)) {
        global2.values[(local0 + local2)] = local1.r;
    }
}


MSL compilation error: Error Domain=MTLLibraryErrorDomain Code=3 &quot;program_source:37:36: error: no matching member function for call to &apos;read&apos;
    vec&lt;float, 4&gt; local1 = global1.read(uint(int(parameter0.x)), global0.level);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1986584</commentid>
    <comment_count>1</comment_count>
    <who name="Mike Wyrzykowski">mwyrzykowski</who>
    <bug_when>2023-10-20 16:13:48 -0700</bug_when>
    <thetext>This can be reproduced by running https://gpuweb.github.io/cts/standalone/?q=webgpu:api,operation,resource_init,texture_zero:uninitialized_texture_is_zero:dimension=%221d%22;readMethod=%22Sample%22;format=%22r8unorm%22</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1986585</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-10-20 16:13:50 -0700</bug_when>
    <thetext>&lt;rdar://problem/117283953&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1987978</commentid>
    <comment_count>3</comment_count>
    <who name="Tadeu Zagallo">tzagallo</who>
    <bug_when>2023-10-27 06:17:42 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/19638</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1988443</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-10-30 04:04:06 -0700</bug_when>
    <thetext>Committed 269931@main (f6aecdc2aadb): &lt;https://commits.webkit.org/269931@main&gt;

Reviewed commits have been landed. Closing PR #19638 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>