1d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt/* 2d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * Copyright © 2012 Intel Corporation 3d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * 4d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * Permission is hereby granted, free of charge, to any person obtaining a 5d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * copy of this software and associated documentation files (the "Software"), 6d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * to deal in the Software without restriction, including without limitation 7d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * and/or sell copies of the Software, and to permit persons to whom the 9d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * Software is furnished to do so, subject to the following conditions: 10d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * 11d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * The above copyright notice and this permission notice (including the next 12d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * paragraph) shall be included in all copies or substantial portions of the 13d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * Software. 14d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * 15d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt * IN THE SOFTWARE. 22d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt */ 23d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt 24d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholtstatic void 258c265cf5ef47ac8ae8565456d8ac023d6c847d57Jordan JustenFN_NAME(struct gl_context *ctx, 268c265cf5ef47ac8ae8565456d8ac023d6c847d57Jordan Justen DST_TYPE *dst, 27d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt GLenum dstFormat, 28d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt SRC_TYPE rgba[][4], 29d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt int n) 30d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt{ 31d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt int i; 32d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt 33d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt switch (dstFormat) { 34d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt case GL_RED_INTEGER_EXT: 35d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt for (i=0;i<n;i++) { 36d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i] = SRC_CONVERT(rgba[i][RCOMP]); 37d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt } 38d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt break; 39d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt 40d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt case GL_GREEN_INTEGER_EXT: 41d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt for (i=0;i<n;i++) { 42d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i] = SRC_CONVERT(rgba[i][GCOMP]); 43d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt } 44d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt break; 45d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt 46d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt case GL_BLUE_INTEGER_EXT: 47d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt for (i=0;i<n;i++) { 48d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i] = SRC_CONVERT(rgba[i][BCOMP]); 49d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt }; 50d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt break; 51d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt 52d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt case GL_ALPHA_INTEGER_EXT: 53d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt for (i=0;i<n;i++) { 54d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i] = SRC_CONVERT(rgba[i][ACOMP]); 55d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt } 56d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt break; 57d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt 58d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt case GL_RG_INTEGER: 59d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt for (i=0;i<n;i++) { 60d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*2+0] = SRC_CONVERT(rgba[i][RCOMP]); 61d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*2+1] = SRC_CONVERT(rgba[i][GCOMP]); 62d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt } 63d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt break; 64d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt 65d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt case GL_RGB_INTEGER_EXT: 66d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt for (i=0;i<n;i++) { 67d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*3+0] = SRC_CONVERT(rgba[i][RCOMP]); 68d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*3+1] = SRC_CONVERT(rgba[i][GCOMP]); 69d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*3+2] = SRC_CONVERT(rgba[i][BCOMP]); 70d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt } 71d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt break; 72d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt 73d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt case GL_RGBA_INTEGER_EXT: 74d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt for (i=0;i<n;i++) { 75d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*4+0] = SRC_CONVERT(rgba[i][RCOMP]); 76d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*4+1] = SRC_CONVERT(rgba[i][GCOMP]); 77d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*4+2] = SRC_CONVERT(rgba[i][BCOMP]); 78d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*4+3] = SRC_CONVERT(rgba[i][ACOMP]); 79d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt } 80d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt break; 81d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt 82d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt case GL_BGR_INTEGER_EXT: 83d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt for (i=0;i<n;i++) { 84d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*3+0] = SRC_CONVERT(rgba[i][BCOMP]); 85d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*3+1] = SRC_CONVERT(rgba[i][GCOMP]); 86d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*3+2] = SRC_CONVERT(rgba[i][RCOMP]); 87d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt } 88d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt break; 89d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt 90d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt case GL_BGRA_INTEGER_EXT: 91d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt for (i=0;i<n;i++) { 92d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*4+0] = SRC_CONVERT(rgba[i][BCOMP]); 93d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*4+1] = SRC_CONVERT(rgba[i][GCOMP]); 94d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*4+2] = SRC_CONVERT(rgba[i][RCOMP]); 95d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*4+3] = SRC_CONVERT(rgba[i][ACOMP]); 96d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt } 97d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt break; 98d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt 99d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt case GL_LUMINANCE_INTEGER_EXT: 100d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt for (i=0;i<n;i++) { 101d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i] = SRC_CONVERT(rgba[i][RCOMP] + 102d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt rgba[i][GCOMP] + 103d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt rgba[i][BCOMP]); 104d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt } 105d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt break; 106d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt 107d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt case GL_LUMINANCE_ALPHA_INTEGER_EXT: 108d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt for (i=0;i<n;i++) { 109d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*2+0] = SRC_CONVERT(rgba[i][RCOMP] + 110d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt rgba[i][GCOMP] + 111d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt rgba[i][BCOMP]); 112d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt dst[i*2+1] = SRC_CONVERT(rgba[i][ACOMP]); 113d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt } 114d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt break; 1158c265cf5ef47ac8ae8565456d8ac023d6c847d57Jordan Justen 1168c265cf5ef47ac8ae8565456d8ac023d6c847d57Jordan Justen default: 1178c265cf5ef47ac8ae8565456d8ac023d6c847d57Jordan Justen _mesa_problem(ctx, 1188c265cf5ef47ac8ae8565456d8ac023d6c847d57Jordan Justen "Unsupported format (%s)", 1198c265cf5ef47ac8ae8565456d8ac023d6c847d57Jordan Justen _mesa_lookup_enum_by_nr(dstFormat)); 1208c265cf5ef47ac8ae8565456d8ac023d6c847d57Jordan Justen break; 121d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt } 122d6c58545a1da8c83f0aad296a5e9e31a7c77cfe4Eric Anholt} 123