在DEV-C++5.11的编译环境下,安装了graphics.h,可是编译报错
错误内容
程序
graphics里的内容
/***
* ==++==
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
--------
* amp_graphics.h
*
* C++ AMP Graphics Library
*
* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
****/
#pragma once
#ifndef _SILENCE_AMP_DEPRECATION_WARNINGS
#error <amp_graphics.h> is part of C++ AMP which is deprecated by Microsoft and will be REMOVED. \
You can define _SILENCE_AMP_DEPRECATION_WARNINGS to acknowledge that you have received this warning.
#endif // _SILENCE_AMP_DEPRECATION_WARNINGS
#include <amp_short_vectors.h>
#include <array>
#include <dxgiformat.h>
#include <sstream>
#define _AMP_GRAPHICS_H
#pragma warning( push )
#pragma warning( disable : 4127 ) // conditional expression is constant
#pragma warning( disable : 4996 ) // writeonly_texture_view is deprecated
#pragma warning( disable : 6326 ) // Potential comparison of a constant with another constant
namespace Concurrency
{
namespace graphics
{
namespace details
{
template<typename _Ty>
struct _Short_vector_type_traits
{
typedef void _Scalar_type;
static const bool _Is_valid_SVT_for_texture = false;
static const _Short_vector_base_type_id _Format_base_type_id = _Invalid_type;
static const unsigned int _Num_channels = 0;
static const unsigned int _Default_bits_per_channel = 0;
};
template<>
struct _Short_vector_type_traits<unsigned int>
{
typedef unsigned int _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Uint_type;
static const unsigned int _Num_channels = 1;
static const unsigned int _Default_bits_per_channel = 32;
};
template<>
struct _Short_vector_type_traits<uint_2>
{
typedef uint_2::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Uint_type;
static const unsigned int _Num_channels = 2;
static const unsigned int _Default_bits_per_channel = 32;
};
template<>
struct _Short_vector_type_traits<uint_3>
{
typedef uint_3::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Uint_type;
static const unsigned int _Num_channels = 3;
static const unsigned int _Default_bits_per_channel = 32;
};
template<>
struct _Short_vector_type_traits<uint_4>
{
typedef uint_4::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Uint_type;
static const unsigned int _Num_channels = 4;
static const unsigned int _Default_bits_per_channel = 32;
};
template<>
struct _Short_vector_type_traits<int>
{
typedef int _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Int_type;
static const unsigned int _Num_channels = 1;
static const unsigned int _Default_bits_per_channel = 32;
};
template<>
struct _Short_vector_type_traits<int_2>
{
typedef int_2::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Int_type;
static const unsigned int _Num_channels = 2;
static const unsigned int _Default_bits_per_channel = 32;
};
template<>
struct _Short_vector_type_traits<int_3>
{
typedef int_3::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Int_type;
static const unsigned int _Num_channels = 3;
static const unsigned int _Default_bits_per_channel = 32;
};
template<>
struct _Short_vector_type_traits<int_4>
{
typedef int_4::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Int_type;
static const unsigned int _Num_channels = 4;
static const unsigned int _Default_bits_per_channel = 32;
};
template<>
struct _Short_vector_type_traits<float>
{
typedef float _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Float_type;
static const unsigned int _Num_channels = 1;
static const unsigned int _Default_bits_per_channel = 32;
};
template<>
struct _Short_vector_type_traits<float_2>
{
typedef float_2::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Float_type;
static const unsigned int _Num_channels = 2;
static const unsigned int _Default_bits_per_channel = 32;
};
template<>
struct _Short_vector_type_traits<float_3>
{
typedef float_3::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Float_type;
static const unsigned int _Num_channels = 3;
static const unsigned int _Default_bits_per_channel = 32;
};
template<>
struct _Short_vector_type_traits<float_4>
{
typedef float_4::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Float_type;
static const unsigned int _Num_channels = 4;
static const unsigned int _Default_bits_per_channel = 32;
};
template<>
struct _Short_vector_type_traits<unorm>
{
typedef unorm _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Unorm_type;
static const unsigned int _Num_channels = 1;
static const unsigned int _Default_bits_per_channel = 16;
};
template<>
struct _Short_vector_type_traits<unorm_2>
{
typedef unorm_2::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Unorm_type;
static const unsigned int _Num_channels = 2;
static const unsigned int _Default_bits_per_channel = 16;
};
template<>
struct _Short_vector_type_traits<unorm_3>
{
typedef unorm_3::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = false;
static const _Short_vector_base_type_id _Format_base_type_id = _Invalid_type;
static const unsigned int _Num_channels = 0;
static const unsigned int _Default_bits_per_channel = 0;
};
template<>
struct _Short_vector_type_traits<unorm_4>
{
typedef unorm_4::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Unorm_type;
static const unsigned int _Num_channels = 4;
static const unsigned int _Default_bits_per_channel = 16;
};
template<>
struct _Short_vector_type_traits<norm>
{
typedef norm _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Norm_type;
static const unsigned int _Num_channels = 1;
static const unsigned int _Default_bits_per_channel = 16;
};
template<>
struct _Short_vector_type_traits<norm_2>
{
typedef norm_2::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Norm_type;
static const unsigned int _Num_channels = 2;
static const unsigned int _Default_bits_per_channel = 16;
};
template<>
struct _Short_vector_type_traits<norm_3>
{
typedef norm_3::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = false;
static const _Short_vector_base_type_id _Format_base_type_id = _Invalid_type;
static const unsigned int _Num_channels = 0;
static const unsigned int _Default_bits_per_channel = 0;
};
template<>
struct _Short_vector_type_traits<norm_4>
{
typedef norm_4::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Norm_type;
static const unsigned int _Num_channels = 4;
static const unsigned int _Default_bits_per_channel = 16;
};
template<>
struct _Short_vector_type_traits<double>
{
typedef double _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Double_type;
static const unsigned int _Num_channels = 2;
static const unsigned int _Default_bits_per_channel = 32;
};
template<>
struct _Short_vector_type_traits<double_2>
{
typedef double_2::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = true;
static const _Short_vector_base_type_id _Format_base_type_id = _Double_type;
static const unsigned int _Num_channels = 4;
static const unsigned int _Default_bits_per_channel = 32;
};
template<>
struct _Short_vector_type_traits<double_3>
{
typedef double_3::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = false;
static const _Short_vector_base_type_id _Format_base_type_id = _Invalid_type;
static const unsigned int _Num_channels = 0;
static const unsigned int _Default_bits_per_channel = 0;
};
template<>
struct _Short_vector_type_traits<double_4>
{
typedef double_4::value_type _Scalar_type;
static const bool _Is_valid_SVT_for_texture = false;
static const _Short_vector_base_type_id _Format_base_type_id = _Invalid_type;
static const unsigned int _Num_channels = 0;
static const unsigned int _Default_bits_per_channel = 0;
};
template<typename _Short_vector_type>
unsigned int _Get_default_bits_per_scalar_element()
{
return _Short_vector_type_traits<_Short_vector_type>::_Format_base_type_id == _Double_type ?
_Short_vector_type_traits<_Short_vector_type>::_Default_bits_per_channel * 2 :
_Short_vector_type_traits<_Short_vector_type>::_Default_bits_per_channel;
}
template<int _Rank>
std::array<size_t, 3> _Get_dimensions(const Concurrency::extent<_Rank> & _Ext, unsigned int _Mip_offset)
{
std::array<size_t, 3> _Arr;
// For un-used dimensions, use value 1.
switch((_Rank)) {
case 1:
_Arr[0] = static_cast<size_t>((_Ext[0] >> _Mip_offset) ? (_Ext[0] >> _Mip_offset) : 1U);
_Arr[1] = 1;
_Arr[2] = 1;
break;
case 2:
_Arr[0] = static_cast<size_t>((_Ext[1] >> _Mip_offset) ? (_Ext[1] >> _Mip_offset) : 1U);
_Arr[1] = static_cast<size_t>((_Ext[0] >> _Mip_offset) ? (_Ext[0] >> _Mip_offset) : 1U);
_Arr[2] = 1;
break;
case 3:
_Arr[0] = static_cast<size_t>((_Ext[2] >> _Mip_offset) ? (_Ext[2] >> _Mip_offset) : 1U);
_Arr[1] = static_cast<size_t>((_Ext[1] >> _Mip_offset) ? (_Ext[1] >> _Mip_offset) : 1U);
_Arr[2] = static_cast<size_t>((_Ext[0] >> _Mip_offset) ? (_Ext[0] >> _Mip_offset) : 1U);
break;
default:
_ASSERTE(false);
_Arr[0] = 1;
_Arr[1] = 1;
_Arr[2] = 1;
break;
}
return _Arr;
}
template <int _Rank>
std::array<size_t, 3> _Get_indices(const index<_Rank> &_Idx)
{
std::array<size_t, 3> _Arr;
// For un-used dimensions, use value 0.
switch((_Rank)) {
case 1:
_Arr[0] = static_cast<size_t>(_Idx[0]);
_Arr[1] = 0;
_Arr[2] = 0;
break;
case 2:
_Arr[0] = static_cast<size_t>(_Idx[1]);
_Arr[1] = static_cast<size_t>(_Idx[0]);
_Arr[2] = 0;
break;
case 3:
_Arr[0] = static_cast<size_t>(_Idx[2]);
_Arr[1] = static_cast<size_t>(_Idx[1]);
_Arr[2] = static_cast<size_t>(_Idx[0]);
break;
default:
_ASSERTE(false);
_Arr[0] = 0;
_Arr[1] = 0;
_Arr[2] = 0;
break;
}
return _Arr;
}
template<int _Rank>
Concurrency::extent<_Rank> _Create_extent(size_t _Width, size_t _Height, size_t _Depth)
{
extent<_Rank> _Ext;
switch((_Rank)) {
case 1:
_Ext[0] = static_cast<int>(_Width);
break;
case 2:
_Ext[0] = static_cast<int>(_Height);
_Ext[1] = static_cast<int>(_Width);
break;
case 3:
_Ext[0] = static_cast<int>(_Depth);
_Ext[1] = static_cast<int>(_Height);
_Ext[2] = static_cast<int>(_Width);
break;
default:
_ASSERTE(false);
break;
}
return _Ext;
}
// forward declaration
template <typename _Value_type, int _Rank> class _Texture_base;
template <typename _Value_type, int _Rank>
_Event _Copy_async_impl(const void * _Src, unsigned int _Src_byte_size, const _Texture_base<_Value_type, _Rank>& _Dst, const index<_Rank> &_Offset, const Concurrency::extent<_Rank> &_Copy_extent);
template <typename OutputIterator, typename _Value_type, int _Rank>
_Event _Copy_async_impl(const _Texture_base<_Value_type, _Rank> &_Src, OutputIterator _Dest_iter);
template<typename _Value_type, int _Rank>
_Event _Copy_async_impl(const _Texture_base<_Value_type, _Rank>& _Src, const index<_Rank> &_Src_offset,
const _Texture_base<_Value_type, _Rank>& _Dst, const index<_Rank> &_Dst_offset, const extent<_Rank> &_Copy_extent);
// The base class for texture, writeonly_texture_view
template <typename _Value_type, int _Rank>
class _Texture_base
{
static_assert(_Rank > 0 && _Rank <= 3, "texture is only supported for rank 1, 2, and 3.");
static_assert(_Short_vector_type_traits<typename std::remove_const<_Value_type>::type>::_Is_valid_SVT_for_texture, "invalid value_type for a texture.");
// Friends
template<typename _T>
friend const _Texture_descriptor& Concurrency::details::_Get_texture_descriptor(const _T& _Tex) __GPU;
template<typename _T>
friend _Ret_ _Texture* Concurrency::details::_Get_texture(const _T& _Tex) __CPU_ONLY;
template<typename _Value_type, int _Rank>
friend _Event _Copy_async_impl(const _Texture_base<_Value_type, _Rank>& _Src, const index<_Rank> &_Src_offset,
const _Texture_base<_Value_type, _Rank>& _Dst, const index<_Rank> &_Dst_offset, const extent<_Rank> &_Copy_extent) __CPU_ONLY;
public:
static const int rank = _Rank;
typedef _Value_type value_type;
typedef typename _Short_vector_type_traits<_Value_type>::_Scalar_type scalar_type;
public:
///
/// Returns the extent that defines the shape of this texture or texture view.
///
__declspec(property(get=get_extent)) Concurrency::extent<_Rank> extent;
Concurrency::extent<_Rank> get_extent() const __GPU
{
return _M_extent;
}
///
/// Returns the extent for specific mipmap level of this texture or texture view.
///
/// <param>
/// Mipmap level for which extent should be calculated.
/// </param>
Concurrency::extent<_Rank> get_mipmap_extent(unsigned int _Mipmap_level) const __CPU_ONLY
{
if (_Mipmap_level >= this->get_mipmap_levels())
{
std::stringstream _Err_msg;
_Err_msg << "Value for _Mipmap_level parameter (" << _Mipmap_level
<< ") cannot be greater than or equal to number of mipmap levels ("
<< this->get_mipmap_levels() << ") on the texture or texture view";
throw runtime_exception(_Err_msg.str().c_str(), E_INVALIDARG);
}
return Concurrency::details::_Get_extent_at_level(_M_extent, _Mipmap_level);
}
///
/// Returns the extent for specific mipmap level of this texture or texture view.
///
/// <param>
/// Mipmap level for which extent should be calculated.
/// </param>
Concurrency::extent<_Rank> get_mipmap_extent(unsigned int _Mipmap_level) const __GPU_ONLY
{
return Concurrency::details::_Get_extent_at_level_unsafe(_M_extent, _Mipmap_level);
}
///
/// Returns the accelerator_view where this texture or texture view is located.
///
__declspec(property(get=get_accelerator_view)) Concurrency::accelerator_view accelerator_view;
Concurrency::accelerator_view get_accelerator_view() const __CPU_ONLY
{
return _Get_texture()->_Get_access_on_accelerator_view();
}
///
/// Returns the number of bits per scalar element
///
__declspec(property(get=get_bits_per_scalar_element)) unsigned int bits_per_scalar_element;
unsigned int get_bits_per_scalar_element() const __CPU_ONLY
{
unsigned int _Bits_per_channel = _Get_texture()->_Get_bits_per_channel();
return _Short_vector_type_traits<_Value_type>::_Format_base_type_id == _Double_type ? _Bits_per_channel * (sizeof(double)/sizeof(int)) : _Bits_per_channel;
}
///
/// Query how many mipmap levels are accessible by this texture (or texture view).
///
/// <returns>
/// Returns number of mipmap levels accessible by this texture (or texture view).
/// </returns>
__declspec(property(get=get_mipmap_levels)) unsigned int mipmap_levels;
unsigned int get_mipmap_levels() const __GPU
{
return _M_texture_descriptor._Get_view_mipmap_levels();
}
///
/// Returns the physical data length (in bytes) that is required in order to represent
/// the texture on the host side with its native format.
/// If the texture contains multiple mipmap levels the value represents the sum of physical data length for each accessible mipmap level by this texture (or texture view).
///
__declspec(property(get=get_data_length)) unsigned int data_length;
unsigned int get_data_length() const __CPU_ONLY
{
return _Get_texture()->_Get_data_length(this->_Get_most_detailed_mipmap_level(), this->get_mipmap_levels());
}
protected:
// internal storage abstraction
typedef Concurrency::details::_Texture_descriptor _Texture_descriptor;
_Texture_base() __CPU_ONLY
{
// This default ctor is required to enable move ctor for a derived types,
// empty _Texture_base is later initialized by move assignment operator
}
_Texture_base(const Concurrency::extent<_Rank>& _Ext, unsigned int _Mipmap_levels = 1) __CPU_ONLY
: _M_extent(_Ext), _M_texture_descriptor(/*_Most_detailed_mipmap_level=*/0, _Mipmap_levels)
{
_Is_valid_extent(_M_extent);
_Are_valid_mipmap_parameters(/*_Most_detailed_mipmap_level=*/0, _Mipmap_levels);
// Validate if we can generate _Mipmap_levels number of mipmap levels given the dimensionality of the texture
unsigned int _Max_mipmap_levels = _Get_max_mipmap_levels(_M_extent);
if (_Mipmap_levels > _Max_mipmap_levels)
{
std::stringstream _Err_msg;
_Err_msg << "The texture extent is too small to generate (" << _Mipmap_levels << ") mipmap levels, the maximum allowed is (" << _Max_mipmap_levels << ")";
throw runtime_exception(_Err_msg.str().c_str(), E_INVALIDARG);
}
else if (_Mipmap_levels == 0)
{
// Generate full range of all mipmaps
// e.g. 2D 10x2 texture would have: 10x2, 5x1, 2x1, 1x1 (4 mipmap levels)
_Mipmap_levels = _Max_mipmap_levels;
}
_M_texture_descriptor._Set_view_mipmap_levels(_Mipmap_levels);
}
// shallow copy for texture_views
_Texture_base(const _Texture_base & _Src) __GPU
: _M_extent(_Src._M_extent), _M_texture_descriptor(_Src._M_texture_descriptor)
{
}
// shallow copy for texture_views that redefine range of mipmaps
_Texture_base(const _Texture_base & _Src, unsigned int _Most_detailed_mipmap_level, unsigned int _View_mipmap_levels) __CPU_ONLY
: _M_extent(_Get_extent_at_level(_Src.extent, _Most_detailed_mipmap_level)), _M_texture_descriptor(_Src._M_texture_descriptor, _Src._Get_most_detailed_mipmap_level() + _Most_detailed_mipmap_level, _View_mipmap_levels)
{
Concurrency::details::_Is_valid_mipmap_range(_Src.get_mipmap_levels(), _Most_detailed_mipmap_level, _View_mipmap_levels);
}
// shallow copy for texture_views that in restrict(amp) context, the texture views can no longer redefine mipmap range,
// but read-write texture view needs to flatten to single mipmap level when created over a texture with multiple mipmap levels.
_Texture_base(const _Texture_base & _Src, bool _Flatten_mipmap_levels) __GPU_ONLY
: _M_extent(_Src.extent), _M_texture_descriptor(_Src._M_texture_descriptor, /*_Most_detailed_mipmap_level=*/0, _Flatten_mipmap_levels ? /*_View_mipmap_levels=*/1 : _Src.get_mipmap_levels())
{
}
// interop
_Texture_base(const Concurrency::extent<_Rank>& _Ext, const _Texture_descriptor & _Desc) __CPU_ONLY
: _M_extent(_Ext), _M_texture_descriptor(_Desc)
{
Concurrency::details::_Is_valid_extent(_M_extent);
}
void _Copy_to(const _Texture_base & _Dest) const __CPU_ONLY
{
if (!(*this == _Dest))
{
_ASSERTE(this->extent == _Dest.extent);
details::_Copy_async_impl(*this, index<_Rank>(), _Dest, index<_Rank>(), _Dest.extent)._Get();
}
}
bool operator==(const _Texture_base & _Other) const __CPU_ONLY
{
return _Other._M_extent == _M_extent && _Other._M_texture_descriptor == _M_texture_descriptor;
}
~_Texture_base() __GPU
{
}
_Ret_ _Texture* _Get_texture() const __CPU_ONLY
{
return _M_texture_descriptor._Get_texture_ptr();
}
unsigned int _Get_most_detailed_mipmap_level() const __GPU
{
return _M_texture_descriptor._Get_most_detailed_mipmap_level();
}
bool _Are_mipmap_levels_overlapping(const _Texture_base &_Other) const __CPU_ONLY
{
return _M_texture_descriptor._Are_mipmap_levels_overlapping(&_Other._M_texture_descriptor);
}
protected:
Concurrency::extent<_Rank> _M_extent;
_Texture_descriptor _M_texture_descriptor;
};
inline void _Is_valid_data_length(unsigned int _Num_elems, unsigned int _Bits_per_elem)
{
unsigned long long _Bytes_per_elem = static_cast<unsigned long long>(_Bits_per_elem / 8U);
unsigned long long _Total_bytes = static_cast<unsigned long long>(_Num_elems) * _Bytes_per_elem;
if (_Total_bytes > static_cast<unsigned long long>(UINT_MAX))
{
throw runtime_exception("Invalid - texture data_length exceeds UINT_MAX", E_INVALIDARG);
}
}
template<typename _Iterator>
struct _Is_iterator
{
template<class _Uty> static auto _Fn(_Uty _Val, decltype(*_Val, ++_Val, 0)) -> std::true_type;
template<class _Uty> static auto _Fn(_Uty _Val, ...) -> std::false_type;
static constexpr bool value = decltype(_Fn(std::declval<_Iterator>(),0))::value;
};
#pragma warning( pop )
请大家解答一下,谢谢