2 #include "intel_context.h"
3 #include "intel_mipmap_tree.h"
6 #define FILE_DEBUG_FLAG DEBUG_TEXTURE
9 intelIsTextureResident(GLcontext
* ctx
, struct gl_texture_object
*texObj
)
12 struct intel_context
*intel
= intel_context(ctx
);
13 struct intel_texture_object
*intelObj
= intel_texture_object(texObj
);
17 intelObj
->mt
->region
&&
18 intel_is_region_resident(intel
, intelObj
->mt
->region
);
25 static struct gl_texture_image
*
26 intelNewTextureImage(GLcontext
* ctx
)
28 DBG("%s\n", __FUNCTION__
);
30 return (struct gl_texture_image
*) CALLOC_STRUCT(intel_texture_image
);
34 static struct gl_texture_object
*
35 intelNewTextureObject(GLcontext
* ctx
, GLuint name
, GLenum target
)
37 struct intel_texture_object
*obj
= CALLOC_STRUCT(intel_texture_object
);
39 DBG("%s\n", __FUNCTION__
);
40 _mesa_initialize_texture_object(&obj
->base
, name
, target
);
46 intelDeleteTextureObject(GLcontext
*ctx
,
47 struct gl_texture_object
*texObj
)
49 struct intel_context
*intel
= intel_context(ctx
);
50 struct intel_texture_object
*intelObj
= intel_texture_object(texObj
);
53 intel_miptree_release(intel
, &intelObj
->mt
);
55 _mesa_delete_texture_object(ctx
, texObj
);
60 intelFreeTextureImageData(GLcontext
* ctx
, struct gl_texture_image
*texImage
)
62 struct intel_context
*intel
= intel_context(ctx
);
63 struct intel_texture_image
*intelImage
= intel_texture_image(texImage
);
65 DBG("%s\n", __FUNCTION__
);
68 intel_miptree_release(intel
, &intelImage
->mt
);
73 texImage
->Data
= NULL
;
78 /* The system memcpy (at least on ubuntu 5.10) has problems copying
79 * to agp (writecombined) memory from a source which isn't 64-byte
80 * aligned - there is a 4x performance falloff.
82 * The x86 __memcpy is immune to this but is slightly slower
83 * (10%-ish) than the system memcpy.
85 * The sse_memcpy seems to have a slight cliff at 64/32 bytes, but
86 * isn't much faster than x86_memcpy for agp copies.
88 * TODO: switch dynamically.
91 do_memcpy(void *dest
, const void *src
, size_t n
)
93 if ((((unsigned) src
) & 63) || (((unsigned) dest
) & 63)) {
94 return __memcpy(dest
, src
, n
);
97 return memcpy(dest
, src
, n
);
108 __asm__
volatile ("\t"
110 "cpuid\n\t" ".byte 0x0f, 0x31\n\t"
111 "popl %%ebx\n":"=a" (eax
)
113 :"ecx", "edx", "cc");
122 __asm__
volatile ("\t" "cpuid\n\t" ".byte 0x0f, 0x31\n\t":"=a" (eax
)
124 :"ecx", "edx", "ebx", "cc");
131 time_diff(unsigned t
, unsigned t2
)
133 return ((t
< t2
) ? t2
- t
: 0xFFFFFFFFU
- (t
- t2
- 1));
138 timed_memcpy(void *dest
, const void *src
, size_t n
)
144 if ((((unsigned) src
) & 63) || (((unsigned) dest
) & 63))
145 _mesa_printf("Warning - non-aligned texture copy!\n");
148 ret
= do_memcpy(dest
, src
, n
);
151 rate
= time_diff(t1
, t2
);
153 _mesa_printf("timed_memcpy: %u %u --> %f clocks/byte\n", t1
, t2
, rate
);
156 #endif /* DO_DEBUG */
160 intelInitTextureFuncs(struct dd_function_table
*functions
)
162 functions
->ChooseTextureFormat
= intelChooseTextureFormat
;
163 functions
->TexImage1D
= intelTexImage1D
;
164 functions
->TexImage2D
= intelTexImage2D
;
165 functions
->TexImage3D
= intelTexImage3D
;
166 functions
->TexSubImage1D
= intelTexSubImage1D
;
167 functions
->TexSubImage2D
= intelTexSubImage2D
;
168 functions
->TexSubImage3D
= intelTexSubImage3D
;
169 functions
->CopyTexImage1D
= intelCopyTexImage1D
;
170 functions
->CopyTexImage2D
= intelCopyTexImage2D
;
171 functions
->CopyTexSubImage1D
= intelCopyTexSubImage1D
;
172 functions
->CopyTexSubImage2D
= intelCopyTexSubImage2D
;
173 functions
->GetTexImage
= intelGetTexImage
;
175 /* compressed texture functions */
176 functions
->CompressedTexImage2D
= intelCompressedTexImage2D
;
177 functions
->GetCompressedTexImage
= intelGetCompressedTexImage
;
179 functions
->NewTextureObject
= intelNewTextureObject
;
180 functions
->NewTextureImage
= intelNewTextureImage
;
181 functions
->DeleteTexture
= intelDeleteTextureObject
;
182 functions
->FreeTexImageData
= intelFreeTextureImageData
;
183 functions
->UpdateTexturePalette
= 0;
184 functions
->IsTextureResident
= intelIsTextureResident
;
187 if (INTEL_DEBUG
& DEBUG_BUFMGR
)
188 functions
->TextureMemCpy
= timed_memcpy
;
191 functions
->TextureMemCpy
= do_memcpy
;