<?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>264449</bug_id>
          
          <creation_ts>2023-11-08 16:13:03 -0800</creation_ts>
          <short_desc>[WebGPU] Clamp depth values to the viewport range</short_desc>
          <delta_ts>2024-02-16 11:03:51 -0800</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="Nobody">webkit-unassigned</assigned_to>
          <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1990993</commentid>
    <comment_count>0</comment_count>
    <who name="Mike Wyrzykowski">mwyrzykowski</who>
    <bug_when>2023-11-08 16:13:03 -0800</bug_when>
    <thetext>[WGSL] Emit code gen for clamping depth to the viewport

This only impacts when frag_depth / ([[depth(any)]] ) is used in the shader.

Something like this I think would work:

struct FragOutput {
...
float depthValue [[depth(any)]];
};

void fragmentShader(const constant unsigned* __DynamicOffsets [[buffer(4)]]) {
  FragOutput o;
...
  float minDepth = as_type&lt;float&gt;(__DynamicOffsets[maxDynamicOffsetIndex + 1]);
  float maxDepth = as_type&lt;float&gt;(__DynamicOffsets[maxDynamicOffsetIndex + 2]);
  o.depthValue = clamp(o.depthValue, minDepth, maxDepth);
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1990994</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-11-08 16:13:20 -0800</bug_when>
    <thetext>&lt;rdar://problem/118144869&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2011548</commentid>
    <comment_count>2</comment_count>
    <who name="Mike Wyrzykowski">mwyrzykowski</who>
    <bug_when>2024-02-07 14:50:42 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/24039</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2013674</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-02-14 15:12:12 -0800</bug_when>
    <thetext>Committed 274666@main (d8d655468dab): &lt;https://commits.webkit.org/274666@main&gt;

Reviewed commits have been landed. Closing PR #24039 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2014093</commentid>
    <comment_count>4</comment_count>
    <who name="Mike Wyrzykowski">mwyrzykowski</who>
    <bug_when>2024-02-15 13:07:03 -0800</bug_when>
    <thetext>Reverted by https://github.com/WebKit/WebKit/pull/24536</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2014094</commentid>
    <comment_count>5</comment_count>
    <who name="Mike Wyrzykowski">mwyrzykowski</who>
    <bug_when>2024-02-15 13:07:04 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/24536</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2014173</commentid>
    <comment_count>6</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-02-15 14:54:32 -0800</bug_when>
    <thetext>Committed 274769@main (b9e6095447e8): &lt;https://commits.webkit.org/274769@main&gt;

Reviewed commits have been landed. Closing PR #24536 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2014199</commentid>
    <comment_count>7</comment_count>
    <who name="Mike Wyrzykowski">mwyrzykowski</who>
    <bug_when>2024-02-15 15:46:35 -0800</bug_when>
    <thetext>Re-opening for pull request https://github.com/WebKit/WebKit/pull/24558</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2014567</commentid>
    <comment_count>8</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-02-16 11:03:49 -0800</bug_when>
    <thetext>Committed 274856@main (57f26e7cc5c4): &lt;https://commits.webkit.org/274856@main&gt;

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

    </bug>

</bugzilla>