<commit_before>/* $Id: t_imm_dlist.c,v 1.48 2003/03/31 18:19:56 brianp Exp $ */

/*
 * Mesa 3-D graphics library
 * Version:  5.1
 *
 * Copyright (C) 1999-2003  <NAME>   All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Authors:
 *    <NAME> <<EMAIL>>
 */


#include "glheader.h"
#include "context.h"
#include "dlist.h"
#include "debug.h"
#include "macros.h"
#include "imports.h"
#include "state.h"

#include "t_context.h"
#include "t_imm_api.h"
#include "t_imm_elt.h"
#include "t_imm_alloc.h"
#include "t_imm_dlist.h"
#include "t_imm_debug.h"
#include "t_imm_exec.h"
#include "t_imm_fixup.h"
#include "t_pipeline.h"

typedef struct {
   struct immediate *IM;
   GLuint Start;
   GLuint Count;
   GLuint BeginState;
   GLuint SavedBeginState;
   GLuint OrFlag;
   GLuint AndFlag;
   GLuint TexSize;
   GLuint LastData;
   GLuint LastPrimitive;
   GLuint LastMaterial;
   GLuint MaterialOrMask;
   GLuint MaterialAndMask;
} TNLvertexcassette;

static void execute_compiled_cassette( GLcontext *ctx, void *data );
static void loopback_compiled_cassette( GLcontext *ctx, struct immediate *IM );


static void
build_normal_lengths( struct immediate *IM )
{
   GLuint i;
   GLfloat len;
   GLfloat (*data)[4] = IM->Attrib[VERT_ATTRIB_NORMAL] + IM->Start;
   GLfloat *dest = IM->NormalLengthPtr;
   GLuint *flags = IM->Flag + IM->Start;
   GLuint count = IM->Count - IM->Start;

#if 0
   if (!IM->Attrib[VERT_ATTRIB_NORMAL])
      return;
#endif

   if (!dest) {
      dest = IM->NormalLengthPtr = (GLfloat *) ALIGN_MALLOC( IMM_SIZE*sizeof(GLfloat), 32 );
      if (!dest) return;
   }
   dest += IM->Start;

   len = (GLfloat) LEN_3FV( data[0] );
   if (len > 0.0F) len = 1.0F / len;
   
   for (i = 0 ; i < count ; ) {
      dest[i] = len;
      if (flags[++i] & VERT_BIT_NORMAL) {
	 len = (GLfloat) LEN_3FV( data[i] );
	 if (len > 0.0F) len = 1.0F / len;
      }
   } 
}


static void
fixup_normal_lengths( struct immediate *IM ) 
{
   GLuint i;
   GLfloat len = 1.0F;  /* just to silence warnings */
   GLfloat (*data)[4] = IM->Attrib[VERT_ATTRIB_NORMAL];
   GLfloat *dest = IM->NormalLengthPtr;
   GLuint *flags = IM->Flag;

   for (i = IM->CopyStart ; i <= IM->Start ; i++) {
      len = (GLfloat) LEN_3FV( data[i] );
      if (len > 0.0F) len = 1.0F / len;
      dest[i] = len;
   } 
<commit_msg>minor clean-ups, const qualifiers<commit_after>/* $Id: t_imm_dlist.c,v 1.49 2003/03/31 23:06:50 brianp Exp $ */

/*
 * Mesa 3-D graphics library
 * Version:  5.1
 *
 * Copyright (C) 1999-2003  <NAME>   All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Authors:
 *    <NAME> <<EMAIL>>
 */


#include "glheader.h"
#include "context.h"
#include "dlist.h"
#include "debug.h"
#include "macros.h"
#include "imports.h"
#include "state.h"

#include "t_context.h"
#include "t_imm_api.h"
#include "t_imm_elt.h"
#include "t_imm_alloc.h"
#include "t_imm_dlist.h"
#include "t_imm_debug.h"
#include "t_imm_exec.h"
#include "t_imm_fixup.h"
#include "t_pipeline.h"

typedef struct {
   struct immediate *IM;
   GLuint Start;
   GLuint Count;
   GLuint BeginState;
   GLuint SavedBeginState;
   GLuint OrFlag;
   GLuint AndFlag;
   GLuint TexSize;
   GLuint LastData;
   GLuint LastPrimitive;
   GLuint LastMaterial;
   GLuint MaterialOrMask;
   GLuint MaterialAndMask;
} TNLvertexcassette;

static void execute_compiled_cassette( GLcontext *ctx, void *data );
static void loopback_compiled_cassette( GLcontext *ctx, struct immediate *IM );


static void
build_normal_lengths( struct immediate *IM )
{
   GLuint i;
   GLfloat len;
   GLfloat (*data)[4] = IM->Attrib[VERT_ATTRIB_NORMAL] + IM->Start;
   GLfloat *dest = IM->NormalLengthPtr;
   const GLuint *flags = IM->Flag + IM->Start;
   const GLuint count = IM->Count - IM->Start;

   if (!dest) {
      dest = IM->NormalLengthPtr = (GLfloat *) ALIGN_MALLOC( IMM_SIZE*sizeof(GLfloat), 32 );
      if (!dest) return;
   }
   dest += IM->Start;

   len = (GLfloat) LEN_3FV( data[0] );
   if (len > 0.0F) len = 1.0F / len;
   
   for (i = 0 ; i < count ; ) {
      dest[i] = len;
      if (flags[++i] & VERT_BIT_NORMAL) {
	 len = (GLfloat) LEN_3FV( data[i] );
	 if (len > 0.0F) len = 1.0F / len;
      }
   } 
}


static void
fixup_normal_lengths( struct immediate *IM ) 
{
   GLuint i;
   GLfloat len = 1.0F;  /* just to silence warnings */
   GLfloat (*data)[4] = IM->Attrib[VERT_ATTRIB_NORMAL];
   GLfloat *dest = IM->NormalLengthPtr;
   const GLuint *flags = IM->Flag;

   for (i = IM->CopyStart ; i <= IM->Start ; i++) {
      len = (GLfloat) LEN_3FV( data[i] );
      if (len > 0.0F)
         len = 1.0F / len;
      dest[i] = len;
   } 

{'fraction_non_alphanumeric': 0.11555287373661186, 'fraction_numerical': 0.015537788505053553, 'mean_word_length': 3.473684210526316, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4771916', 'n_tokens_mistral': 2355, 'n_tokens_neox': 2254, 'n_words': 752}