Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!

Gavin Williams

Member Since 04 Dec 2010
Offline Last Active Today, 07:10 AM

Posts I've Made

In Topic: vs 2013 hlsl

Today, 06:43 AM

I'm having this problem now myself.

In Topic: Convert index<1> idx in parallel_for_each to integer index

07 January 2015 - 06:32 PM



I'll read up on C++ lambda's too, I'm not that strong with them in C# either :$


And i'd just like to note that VPHeight should be VPWidth in the above code snippets.

In Topic: Convert index<1> idx in parallel_for_each to integer index

07 January 2015 - 03:25 AM

I think the answer is to use parallel_for. Then instead of using index<n>, the iterator (int i) can be used to index the captured array data. Something I didn't understand as well before just now, was the purpose of the equals in square brackets [=] ... which allows me to use captured data even when it's not in the parallel_for call arguments.

In Topic: Convert index<1> idx in parallel_for_each to integer index

07 January 2015 - 02:41 AM

Here's the code showing what I want to achieve (below). So when i try to compute the x and y for the given index, the idx 'variable' doesn't resolve to an integer. And I don't see anyway to convert it or determine the index.

    // grab native pointer to pixelData
    unsigned int* nativePixelData = (unsigned int*)pixelData->Data;
    //unsigned int* nativePixelData = (unsigned int*)malloc(4*size)
    // setup concurrency data (in/out)
    array_view<unsigned int> nativePixelDataView((int)size, nativePixelData);

    parallel_for_each(nativePixelDataView.extent, [=](index<1> idx) restrict(amp)
				// compute x and y for the given index
				unsigned int x = idx % VPWidth; // ** ERROR **
				unsigned int y = idx / VPWidth; // ** ERROR **

				// compute initial ray for the {x,y} pixel
				AMPVector3 rayDirection = camera->NearPlaneTopLeft + AMPVector3::Multiply(camera->HTransform, x) + AMPVector3::Multiply(camera->VTransform, y) - camera->Position;

PS. I have read that these indices can be negative and the array space can have a relocated origin. I don't understand under what circumstances that might be true, and I don't think it would apply in this case. But clearly it's more complex than a simple integer index.

In Topic: Still a little confused about changing structs

29 December 2014 - 09:40 PM


All the discussions that I've read about the problem often center around (im)mutability, but don't raise the difference between properties and fields. I didn't know that properties return copies (of structs). It seems kind of important to know :$

I may be naive by saying this, but it seems wrong that I should even be allowed to create a copy and not use it, without a warning that it's never used.