<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Thanks for taking care of in Graphics</title>
    <link>https://community.intel.com/t5/Graphics/Compute-shader-producing-incorrect-output/m-p/1103851#M87515</link>
    <description>&lt;P&gt;Thanks for taking care of filing the reports.&lt;/P&gt;

&lt;P&gt;Although not that important, I appear to show up as "Logged in as (name withheld)".&amp;nbsp; My profile actually shows me as (name withheld).&amp;nbsp; I tried to edit this to my real name but to no avail.&amp;nbsp; Any idea how I can change this?&amp;nbsp; Thanks.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jan 2016 17:01:11 GMT</pubDate>
    <dc:creator>David_Eberly</dc:creator>
    <dc:date>2016-01-26T17:01:11Z</dc:date>
    <item>
      <title>Compute shader producing incorrect output</title>
      <link>https://community.intel.com/t5/Graphics/Compute-shader-producing-incorrect-output/m-p/1103849#M87513</link>
      <description>&lt;P&gt;I have a GLSL compute shader designed to compute the distance between two line segments. &amp;nbsp;The output on Intel HD 4600 is incorrect, whereas I get the correct results on NVIDIA/AMD cards.&lt;/P&gt;

&lt;P&gt;4th Generation Intel® Core™ Processors with Intel® HD Graphics 5000/4600/4400/4200&lt;BR /&gt;
	System Used: &amp;nbsp;Dell Inc. Precision T1700&lt;BR /&gt;
	CPU SKU: i7&lt;BR /&gt;
	GPU SKU: 4600&lt;BR /&gt;
	Processor Line: N/A&lt;BR /&gt;
	System BIOS Version: A16&lt;BR /&gt;
	CMOS settings: N/A&lt;BR /&gt;
	Graphics Driver Version: 10.18.15.4281&lt;BR /&gt;
	GOP/VBIOS Version: N/A&lt;BR /&gt;
	Operating System: Windows 10 Pro 64-bit&lt;BR /&gt;
	OS Version: (10.0, Build 10586) (10586.th2_release.160104-1513)&lt;BR /&gt;
	API: OpenGL 4.3.0&lt;BR /&gt;
	Occurs on non-Intel GPUs?: &amp;nbsp;No (tested on NVIDIA and AMD)&lt;/P&gt;

&lt;P&gt;Steps to Reproduce:&lt;BR /&gt;
	I have provided a stand-alone Microsoft Visual Studio 2015&lt;BR /&gt;
	project that illustrates the problem. &amp;nbsp;The GLSL file&lt;BR /&gt;
	DistanceSegments.glsl computes the distance between two line&lt;BR /&gt;
	segments in 3D.&lt;/P&gt;

&lt;P&gt;Expected Results: &amp;nbsp;Comments at the end of DistanceBug.cpp show&lt;BR /&gt;
	the correct results for a pair of segments. &amp;nbsp;The answers are&lt;BR /&gt;
	exact, and NVIDIA and AMD OpenGL drivers are computing the correct&lt;BR /&gt;
	results.&lt;/P&gt;

&lt;P&gt;Actual Results: Comments at the end of DistanceBug.cpp show that&lt;BR /&gt;
	the Intel OpenGL driver is producing incorrect results.&lt;/P&gt;

&lt;P&gt;Additional Information:&lt;BR /&gt;
	I created a project that executes the HLSL equivalent for Direct3D 11&lt;BR /&gt;
	and the results are correct on the Intel driver. &amp;nbsp;However, I originally&lt;BR /&gt;
	saw this problem in a somewhat more complicated scenario where I was&lt;BR /&gt;
	computing segment-segment distances for batches of segments. &amp;nbsp;In that&lt;BR /&gt;
	scenario, even the Intel Direct3D 11 driver was producing incorrect&lt;BR /&gt;
	results. &amp;nbsp;I will try to create a project that reduces that scenario&lt;BR /&gt;
	to a minimum set of code.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2016 07:56:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Graphics/Compute-shader-producing-incorrect-output/m-p/1103849#M87513</guid>
      <dc:creator>David_Eberly</dc:creator>
      <dc:date>2016-01-26T07:56:19Z</dc:date>
    </item>
    <item>
      <title>Hi Dave,</title>
      <link>https://community.intel.com/t5/Graphics/Compute-shader-producing-incorrect-output/m-p/1103850#M87514</link>
      <description>&lt;P&gt;Hi Dave,&lt;/P&gt;

&lt;P&gt;Thanks for giving me all the details and the project for reproducing the problem. I will update you when we know something.&lt;/P&gt;

&lt;P&gt;-Michael&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2016 16:49:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Graphics/Compute-shader-producing-incorrect-output/m-p/1103850#M87514</guid>
      <dc:creator>Michael_C_Intel2</dc:creator>
      <dc:date>2016-01-26T16:49:42Z</dc:date>
    </item>
    <item>
      <title>Thanks for taking care of</title>
      <link>https://community.intel.com/t5/Graphics/Compute-shader-producing-incorrect-output/m-p/1103851#M87515</link>
      <description>&lt;P&gt;Thanks for taking care of filing the reports.&lt;/P&gt;

&lt;P&gt;Although not that important, I appear to show up as "Logged in as (name withheld)".&amp;nbsp; My profile actually shows me as (name withheld).&amp;nbsp; I tried to edit this to my real name but to no avail.&amp;nbsp; Any idea how I can change this?&amp;nbsp; Thanks.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2016 17:01:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Graphics/Compute-shader-producing-incorrect-output/m-p/1103851#M87515</guid>
      <dc:creator>David_Eberly</dc:creator>
      <dc:date>2016-01-26T17:01:11Z</dc:date>
    </item>
    <item>
      <title>Hi Dave,</title>
      <link>https://community.intel.com/t5/Graphics/Compute-shader-producing-incorrect-output/m-p/1103852#M87516</link>
      <description>&lt;P&gt;Hi Dave,&lt;/P&gt;

&lt;P&gt;We have identified a bug in the driver and are working on a fix. Also we found a bug in the shader code.&lt;/P&gt;

&lt;P&gt;Your code assumes a particular memory layout of variables inside Result structure that you shouldn't, as the default is layout(shared) which gives the freedom to use different layout, and we do so (at least with USC - on Gen7.5 and Gen8).&lt;/P&gt;

&lt;P&gt;Proposed fix: If you change shader code by adding layout(std430), the layout of Result structure on GPU will be the same as expected in C++.&lt;/P&gt;

&lt;P&gt;layout(std430) buffer outResult { Result data[]; } outResultSB;&lt;/P&gt;

&lt;P&gt;For details, please refer to OpenGL specification chapter 7.6.2.2, page 138 or following page:&lt;BR /&gt;
	&lt;A href="https://www.opengl.org/wiki/Interface_Block_(GLSL)#Memory_layout" target="_blank"&gt;https://www.opengl.org/wiki/Interface_Block_(GLSL)#Memory_layout&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Hope this help,&lt;/P&gt;

&lt;P&gt;-Michael&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2016 15:20:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Graphics/Compute-shader-producing-incorrect-output/m-p/1103852#M87516</guid>
      <dc:creator>Michael_C_Intel2</dc:creator>
      <dc:date>2016-02-16T15:20:57Z</dc:date>
    </item>
    <item>
      <title>Hello Michael.</title>
      <link>https://community.intel.com/t5/Graphics/Compute-shader-producing-incorrect-output/m-p/1103853#M87517</link>
      <description>&lt;P&gt;Hello Michael.&lt;/P&gt;

&lt;P&gt;Thank you for the report. &amp;nbsp;When I reduced the code and shader to a minimum set for posting, I forgot that my GLSL compiler-linker wrapper prepends some strings to those in the *.glsl file. &amp;nbsp;The first is the "#version 430", which I included in the file I posted. &amp;nbsp;The second string, which I failed to include in the shader I posted to you, is "layout(std430) buffer;" that specifies the layout to be used by all buffers in the shader. &amp;nbsp;I modified the shader I sent to you to include this second string and the layout appears to be correct now. &amp;nbsp;However, the results are still incorrect, which I assume relates to your comment about finding a driver bug.&lt;/P&gt;

&lt;P&gt;Dave&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2016 05:38:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Graphics/Compute-shader-producing-incorrect-output/m-p/1103853#M87517</guid>
      <dc:creator>David_Eberly</dc:creator>
      <dc:date>2016-02-17T05:38:49Z</dc:date>
    </item>
    <item>
      <title>Hi Dave,</title>
      <link>https://community.intel.com/t5/Graphics/Compute-shader-producing-incorrect-output/m-p/1103854#M87518</link>
      <description>&lt;P&gt;Hi Dave,&lt;/P&gt;

&lt;P&gt;Thanks for the update, the engineer investigating the issue has some info to pass along:&lt;/P&gt;

&lt;P&gt;You assume indices of the two SSBO to be {0, 1}, which is not guaranteed. To fix it, choose one of these solutions:&lt;/P&gt;

&lt;P&gt;1. Ask OpenGL for SSBO indices using glGetProgramResourceIndex and use them, by changing code to:&lt;/P&gt;

&lt;P&gt;GLuint inSegmentIndex = glGetProgramResourceIndex(programHandle, GL_SHADER_STORAGE_BLOCK, "inSegment");&lt;/P&gt;

&lt;P&gt;GLuint outResultIndex = glGetProgramResourceIndex(programHandle, GL_SHADER_STORAGE_BLOCK, "outResult");&lt;/P&gt;

&lt;P&gt;GLuint inSegmentBinding = 0;&lt;/P&gt;

&lt;P&gt;GLuint outResultBinding = 1;&lt;/P&gt;

&lt;P&gt;// Execute the compute shader.&lt;/P&gt;

&lt;P&gt;glUseProgram(programHandle);&lt;/P&gt;

&lt;P&gt;glShaderStorageBlockBinding(programHandle, inSegmentIndex, inSegmentBinding);&lt;/P&gt;

&lt;P&gt;glBindBufferRange(GL_SHADER_STORAGE_BUFFER, inSegmentBinding, inSegmentHandle, 0, 2 * sizeof(Segment));&lt;/P&gt;

&lt;P&gt;glShaderStorageBlockBinding(programHandle, outResultIndex, outResultBinding);&lt;/P&gt;

&lt;P&gt;glBindBufferRange(GL_SHADER_STORAGE_BUFFER, outResultBinding, outResultHandle, 0, sizeof(Result));&lt;/P&gt;

&lt;P&gt;glDispatchCompute(1, 1, 1);&lt;/P&gt;

&lt;P&gt;glBindBufferBase(GL_SHADER_STORAGE_BUFFER, inSegmentBinding, 0);&lt;/P&gt;

&lt;P&gt;glBindBufferBase(GL_SHADER_STORAGE_BUFFER, outResultBinding, 0);&lt;/P&gt;

&lt;P&gt;glUseProgram(0);&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;2. Remove calls to glShaderStorageBlockBinding and specify binding in GLSL instead, by adding:&lt;/P&gt;

&lt;P&gt;layout(std430, binding=0) buffer inSegment { Segment data[]; } inSegmentSB;&lt;/P&gt;

&lt;P&gt;layout(std430, binding=1) buffer outResult { Result data[]; } outResultSB;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;-Michael&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2016 21:41:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Graphics/Compute-shader-producing-incorrect-output/m-p/1103854#M87518</guid>
      <dc:creator>Michael_C_Intel2</dc:creator>
      <dc:date>2016-02-17T21:41:24Z</dc:date>
    </item>
    <item>
      <title>Hello Michael.</title>
      <link>https://community.intel.com/t5/Graphics/Compute-shader-producing-incorrect-output/m-p/1103855#M87519</link>
      <description>&lt;P&gt;Hello Michael.&lt;/P&gt;

&lt;P&gt;Thanks for the details about the buffers. &amp;nbsp;Other parts of the engine are designed to require the shader writers to specify the bind points. &amp;nbsp;I need to check with the engineer who wrote the code to understand why buffers were handled differently. &amp;nbsp;He developed using AMD graphics and I diagnosed problems in the design when it depended on how AMD does things (I tested on Intel Graphics and NVIDIA). &amp;nbsp;It appears AMD assigns binding points to resources in order of occurrence, whereas NVIDIA appears to assign based on alphabetical sorting.&lt;/P&gt;

&lt;P&gt;Dave&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 07:00:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Graphics/Compute-shader-producing-incorrect-output/m-p/1103855#M87519</guid>
      <dc:creator>David_Eberly</dc:creator>
      <dc:date>2016-02-18T07:00:29Z</dc:date>
    </item>
  </channel>
</rss>

