1c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez//
2c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez// Copyright 2012 Francisco Jerez
3c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez//
4c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez// Permission is hereby granted, free of charge, to any person obtaining a
5c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez// copy of this software and associated documentation files (the "Software"),
6c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez// to deal in the Software without restriction, including without limitation
7c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez// and/or sell copies of the Software, and to permit persons to whom the
9c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez// Software is furnished to do so, subject to the following conditions:
10c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez//
11c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez// The above copyright notice and this permission notice shall be included in
12c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez// all copies or substantial portions of the Software.
13c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez//
14c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez// THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez// SOFTWARE.
21c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez//
22c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez
23c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez#ifndef __CORE_FORMAT_HPP__
24c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez#define __CORE_FORMAT_HPP__
25c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez
26c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez#include <set>
27c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez
28c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez#include "core/base.hpp"
29c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez#include "pipe/p_defines.h"
30c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez#include "pipe/p_format.h"
31c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez
32c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jereznamespace clover {
33c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez   pipe_texture_target translate_target(cl_mem_object_type type);
34c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez   pipe_format translate_format(const cl_image_format &format);
35c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez
36c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez   ///
37c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez   /// Return all the image formats supported by a given context for
38c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez   /// the given memory object type.
39c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez   ///
40c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez   std::set<cl_image_format> supported_formats(cl_context ctx,
41c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez                                               cl_mem_object_type type);
42c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez}
43c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez
44c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerezstatic inline bool
45c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerezoperator<(const cl_image_format &a, const cl_image_format &b) {
46c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez   return (a.image_channel_order != b.image_channel_order ?
47c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez           a.image_channel_order < b.image_channel_order :
48c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez           a.image_channel_data_type < b.image_channel_data_type);
49c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez}
50c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez
51c6db1b3396384186aab5b685fe1fd540e17b3a62Francisco Jerez#endif
52