Compare commits

...

257 Commits

Author SHA1 Message Date
Brian Paul
418987ff05 docs: detect when too many varying vars are used 2009-06-26 16:54:44 -06:00
Brian Paul
21320b24c5 glsl: check number of varying variables against the limit
Link fails if too many varying vars.

(cherry picked from master, commit cc58fbcf2c)
2009-06-26 16:53:46 -06:00
Brian Paul
4181a107cb docs: fix typos, remove old text from relnotes file 2009-06-26 16:47:57 -06:00
Brian Paul
2a41df86a3 docs: bring over news updates from 7.4 branch 2009-06-26 16:46:21 -06:00
Brian Paul
318122b60a docs: bring in 7.4.3 and 7.4.4 release notes, news 2009-06-26 16:45:54 -06:00
Brian Paul
dd585db687 docs: increase max varying vars to 16 2009-06-26 16:41:54 -06:00
Brian Paul
f08bebfe24 mesa: raise MAX_VARYING (number of shader varying vars) to 16
16 is the limit for now because of various 32-bit bitfields.

(cherry picked from master, commit 4e762395ef)
2009-06-26 16:41:04 -06:00
Ian Romanick
2d86503471 intel / DRI2: Additional flush of fake front-buffer to real front-buffer
To maintain correctness, the server will copy the real front-buffer to
a newly allocated fake front-buffer in DRI2GetBuffersWithFormat.
However, if the DRI2GetBuffersWithFormat is triggered by glViewport,
this will copy stale data into the new buffer.  Fix this by flushing
the current fake front-buffer to the real front-buffer in
intel_viewport.

Fixes bug #22288.
2009-06-26 13:32:26 -07:00
Brian Paul
077a06c140 mesa: bump version to 7.5-rc4 2009-06-26 13:16:34 -06:00
Brian Paul
62ad606065 docs: document for/continue bug fix 2009-06-26 13:16:34 -06:00
Brian Paul
928e1ce47f cell: PIPE_CAP_TGSI_CONT_SUPPORTED query 2009-06-26 13:16:34 -06:00
Brian Paul
af7fb892d8 softpipe: PIPE_CAP_TGSI_CONT_SUPPORTED query 2009-06-26 13:16:34 -06:00
Brian Paul
f5dc352e5f gallium: added PIPE_CAP_TGSI_CONT_SUPPORTED 2009-06-26 13:16:34 -06:00
Brian Paul
e80ecdf659 glsl: move/simplify error checking for 'return' statements 2009-06-26 13:16:34 -06:00
Brian Paul
8e6dd8bf79 glsl: overhaul 'return' statement handling
A new node type (SLANG_OPER_RETURN_INLINED) is used to denote 'return'
statements inside inlined functions which need special handling.

All glean glsl1 tests pass for EmitContReturn=FALSE and TRUE.
2009-06-26 13:16:34 -06:00
Brian Paul
aa48becb82 glsl: predicate assignments according to __returnFlag
Fixes glean "function with early return (3)" case (when EmitContReturn=FALSE).
2009-06-26 13:16:34 -06:00
Brian Paul
16787c513b glsl: added slang_variable::is_global field 2009-06-26 13:16:34 -06:00
Brian Paul
ac05996b81 glsl: silence a problem warning 2009-06-26 13:16:34 -06:00
Brian Paul
0efd25b502 glsl: code refactoring for return statements 2009-06-26 13:16:34 -06:00
Brian Paul
2ae297c318 glsl: fix assorted regressions related to early-return-removal 2009-06-26 13:16:34 -06:00
Brian Paul
ddf64be258 glsl: comments, field reordering 2009-06-26 13:16:34 -06:00
Brian Paul
f652f15e6d glsl: rework loop nesting code 2009-06-26 13:16:34 -06:00
Brian Paul
dd453fa37c glsl: remove test for loop unrolling when we hit conditional cont/break
This is no longer needed since we added the new
_slang_loop_contains_continue_or_break() function/test.
2009-06-26 13:16:34 -06:00
Brian Paul
2f1c5c58b3 glsl: checkpoint: predicate __retVal = expr with __returnFlag
The glean "function with early return (1)" test passes now.
2009-06-26 13:16:34 -06:00
Brian Paul
65eaafee25 glsl: use new helper functions in _slang_gen_logical_and/or() 2009-06-26 13:16:33 -06:00
Brian Paul
e139434d44 glsl: add comments 2009-06-26 13:16:33 -06:00
Brian Paul
b04605d544 glsl: checkpoint: replace 'return' with __returnFlag=true;
Needed for "remove early returns" transformation.
2009-06-26 13:16:33 -06:00
Brian Paul
515513b409 glsl: fix up scoping for parent/children in slang_operation_copy()
This will need more testing, but no regressions seen so far.
2009-06-26 13:16:33 -06:00
Brian Paul
09313043e7 glsl: fix uninitialized var in _slang_gen_for_without_continue() 2009-06-26 13:16:33 -06:00
Brian Paul
5951ab311d glsl: added slang_operation_free_children() 2009-06-26 13:16:33 -06:00
Brian Paul
e5b53c071b glsl: added slang_oper_num_children() helper 2009-06-26 13:16:33 -06:00
Brian Paul
3c6480ea42 glsl: check-point: declare _returnFlag 2009-06-26 13:16:33 -06:00
Brian Paul
fc0896b50b glsl: added slang_operation_insert_child() 2009-06-26 13:16:33 -06:00
Brian Paul
f4b1a69b7d glsl: use slang_generate_declaration() to consolidate some code 2009-06-26 13:16:33 -06:00
Brian Paul
454a717d94 glsl: remove obsolete comment 2009-06-26 13:16:33 -06:00
Brian Paul
02edc8da36 st/mesa: query PIPE_CAP_TGSI_CONT_SUPPORTED 2009-06-26 13:16:33 -06:00
Brian Paul
08025cd4a5 glsl: implement _slang_gen_while_without_continue() 2009-06-26 13:16:33 -06:00
Brian Paul
2102e301a7 glsl: fix a bug involving 'continue' in 'for' loops
Need to execute the for loop's increment code before we continue.
Add a slang_assemble_ctx::CurLoopOper field to keep track of the containing
loop and avoid the "cont if true" path in this situation.

Plus, assorted clean-ups.
2009-06-26 13:16:33 -06:00
Brian Paul
541594b044 glsl: added slang_oper_child_const() 2009-06-26 13:16:32 -06:00
Brian Paul
38ddbc5588 glsl: use _slang_loop_contains_continue_or_break() to check for unrolling
The previous test failed for nested loops.
2009-06-26 13:16:32 -06:00
Brian Paul
4dafac2b2f glsl: use new _slang_loop_contains_continue() helper function 2009-06-26 13:16:32 -06:00
Brian Paul
aba93643be glsl: implement continue->break translation for do-while loops 2009-06-26 13:16:32 -06:00
Brian Paul
7e0eaca201 glsl: added slang_operation_literal_int/bool() helper functions 2009-06-26 13:16:32 -06:00
Brian Paul
c1f74a6734 glsl: don't allocate 0-length children array in slang_operation_copy() 2009-06-26 13:16:32 -06:00
Brian Paul
f38872473c glsl: remove debug code, misc clean-up 2009-06-26 13:16:32 -06:00
Brian Paul
f66733bbee glsl: implement continue->break transformation for for-loops 2009-06-26 13:16:32 -06:00
Brian Paul
c4fd947bee glsl: added slang_operation_add_children() and slang_oper_child() helpers 2009-06-26 13:16:32 -06:00
Brian Paul
c20bb48d3a glsl: added slang_assemble_ctx::EmitContReturn field, init 2009-06-26 13:16:32 -06:00
Brian Paul
eb1eee03a6 demos: improve argv parsing in fslight.c 2009-06-26 13:16:32 -06:00
Brian Paul
4bc74a0756 glsl: don't unroll loops containing continue/break
Just search the AST in _slang_can_unroll_for_loop().
2009-06-26 13:16:32 -06:00
Brian Paul
625b0fe268 Revert "slang: if/else/break & if/else/continue work for unrolled loops"
We should just check if the loop contains a continue/break in the
_slang_can_unroll_for_loop() test function...

This reverts commit 989856bde4.

Conflicts:

	src/mesa/shader/slang/slang_codegen.h
2009-06-26 13:16:32 -06:00
Brian Paul
4031ea1520 glsl: Added gl_shader_state::EmitContReturn field
This is the start of a glsl-continue-return feature branch to support
a GLSL code generator option for 'continue' and 'return' statements.
Some targets don't support CONT or RET statements so we'll need to
try to generate code that does not use them...
2009-06-26 13:16:32 -06:00
Brian Paul
84c5e4805b docs: updated Mesa release instructions 2009-06-26 13:16:32 -06:00
José Fonseca
72aed16aee scons: Tool to build with DirectX SDK.
Also works with MinGW, as long as the path to the DirectX SDK top
directory is set in the DXSDK_DIR environment variable.
2009-06-26 19:57:47 +01:00
José Fonseca
25f6c936fe scons: Don't use C specific options with g++ 2009-06-26 19:57:46 +01:00
Keith Whitwell
3e94521912 tgsi: correct handling of return value from util_vsnprintf
We were failing to deal with:
  - vsnprintf returns negative value on error.
  - vsnprintf returns the number of chars that *would* have been
    written on truncation.
2009-06-26 13:45:34 +01:00
Keith Whitwell
c9f8c400ab aux/indices: don't use 'prim' value once it is known to be bad
Theoretical bugfix only - no known case where this might happen.
2009-06-26 13:44:20 +01:00
José Fonseca
c25534f30d wgl: Handle flush after a window is destroyed.
Fixes assertion failure with conform.
2009-06-24 15:23:44 +01:00
Brian Paul
b79e6a59d8 demos: fix issues in glxcontexts.c
The reshape() function was called when there was no GLX context so
the viewport/modelview/projection setup wasn't doing anything.  Move
the call to reshape() into draw().

Also, remove -stereo, -fullscreen options and do some general clean-up.
2009-06-23 09:31:27 -06:00
Roland Scheidegger
2f184d0d9f i965: handle OPCODE_SWZ in the glsl path
glsl compiler will not generate OPCODE_SWZ, and as a first step it would
be translated away to a MOV anyway (why?), but later internally this opcode is
generated (for EXT_texture_swizzling).
(cherry picked from commit 4ef1f8e3b5)
2009-06-22 15:15:20 -07:00
Owen W. Taylor
9d367d43b2 Disable SGI_swap_control extension for DRI2
We currently don't have support for SGI_swap_control for direct
contexts with DRI2, so disable reporting the extension. Reporting
the extension, and then having glXSwapIntervalSGI() "succeed"
but do nothing can confuse applications.

https://bugs.freedesktop.org/show_bug.cgi?id=22123
(cherry picked from commit 279143c6e8)
2009-06-22 15:15:20 -07:00
Michel Dänzer
0584b6e433 intel: intel_texture_drawpixels() can't handle GL_DEPTH_STENCIL.
Fixes glean depthStencil test.
(cherry picked from commit 3885b708fd)
2009-06-22 15:15:20 -07:00
Brian Paul
19218fe712 i965: added intelFlush() call in intel_get_tex_image()
Fixes the render-to-texture test in progs/tests/getteximage.c
(cherry picked from commit a03b349153)
2009-06-22 15:15:20 -07:00
Brian Paul
a5b7e0c7d7 mesa: s/MAX_VERTEX_PROGRAM_ATTRIBS/MAX_NV_VERTEX_PROGRAM_INPUTS/ in NV funcs
(cherry picked from commit 4dc426c016)
2009-06-22 15:15:20 -07:00
Brian Paul
54f425b5ce mesa: rename MAX_VERTEX_ATTRIBS to MAX_VERTEX_GENERIC_ATTRIBS
Be clearer that this is the number of generic vertex program/shader
attributes, not counting the legacy attributes (pos, normal, color, etc).
(cherry picked from commit 4a95185c9f)
2009-06-22 15:15:19 -07:00
Brian Paul
810df8317d mesa: s/MAX_VERTEX_PROGRAM_ATTRIBS/MAX_NV_VERTEX_PROGRAM_INPUTS
(cherry picked from commit d2a74d76c9)
2009-06-22 15:15:19 -07:00
Brian Paul
19ca5ee1db mesa: fix some potential state-restore issues in pop_texture_group()
Call the _mesa_set_enable() functions instead of driver functions, etc.

Also, add missing code for 1D/2D texture arrays.
(cherry picked from commit aac19609bf)
2009-06-22 15:15:19 -07:00
Brian Paul
ad0514b24d vbo: return VP_NONE from get_program_mode() if running fixed-func vertex program
If we're running a vertex program to emulated fixed-function, we still need
to treat vertex arrays/attributes as if we're in fixed-function mode.

This should probably be back-ported to Mesa 7.5 after a bit more testing.
(cherry picked from commit dda82137d2)
2009-06-22 15:15:19 -07:00
Brian Paul
00e203fe17 mesa: create/use a fallback texture when bound texture is incomplete
When a GLSL sampler reads from an incomplete texture it should
return (0,0,0,1).  Instead of jumping through hoops in all the drivers
to make this happen, just create/install a fallback texture with those
texel values.

Fixes piglit/fp-incomplete-tex on i965 and more importantly, fixes some
GPU lockups when trying to sample from missing surfaces.  If a binding
table entry is NULL, it seems that sampling sometimes works, but not
always (lockup).

Todo: create a fallback texture for each type of texture target?
(cherry picked from commit 3f25219c7b)
2009-06-22 15:15:19 -07:00
Eric Anholt
abfd56c24c intel: Fix other metaops versus GL_COMPILE_AND_EXECUTE dlists.
Fixes oglconform zbfunc.c and pxtrans-cidraw.c, at least.

(cherry picked from commit 405300bb19)
2009-06-19 16:57:06 -07:00
Eric Anholt
daacac1c24 intel: Fix glClear behavior versus display lists.
The CALL_DrawArrays was leaking the clear's primitives into the display
list with GL_COMPILE_AND_EXECUTE.  Use _mesa_DrawArrays instead, which
doesn't appear to leak.  Fixes piglit dlist-clear test.
(cherry picked from commit 64edde1004)
2009-06-19 16:54:59 -07:00
Roland Scheidegger
43bb78f2bb radeons: use dp4 for position invariant vertex programs
Fixes #22181. R200 requires this since DP4 is used in hw tnl mode.
R300 prefers it (should be faster due to no instruction dependencies), but
both methods should be correct (when sw tcl is used though, MUL/MAD might
be faster). Probably doesn't make much difference for R100 since vertex progs
are executed in software anyway, but let's just keep it the same there too.
2009-06-19 20:00:55 +02:00
Michel Dänzer
9dfce365c7 Also release direct rendering resources in glXDestroyGLXPixmap.
Fixes leak running compiz with direct rendering.
2009-06-19 18:00:49 +02:00
Michel Dänzer
a120778c72 Always free image offsets memory when re-initializing texture image fields.
Fixes leak running compiz with direct rendering.
2009-06-19 18:00:33 +02:00
José Fonseca
3cf92e936a scons: Output the friendly "Linking ..." message when creating DLLs with MinGW. 2009-06-19 16:08:38 +01:00
Brian Paul
0487656245 softpipe: return alpha=1 in shadow_compare() function
The alpha value wasn't set at all before so we got unpredictable results.

Note that we don't currently obey GL_DEPTH_TEXTURE_MODE in the state
tracker.  For now, we return the result in the default mode (r,r,r,1).
2009-06-19 08:53:15 -06:00
José Fonseca
8f382fd3f3 util: Add cast.
It is expected to loose precision here.
2009-06-18 14:54:09 +01:00
José Fonseca
21bfd0f4bd draw: Replace pointer arithmetic with cast.
Using uintptr_t as intermediate type for pointer -> integer conversions is
easier to understand and does not cause any size mismatch warnings.
uintptr_t is part of C99, and we already provide a suitable replacement
definition for all platforms we care about.
2009-06-18 14:54:09 +01:00
José Fonseca
d609df1dae trace: Use size_t consistently. 2009-06-18 14:54:09 +01:00
José Fonseca
2af0173e9e pipebuffer: Use a type consistently for sizes/offsets.
Avoids warnings on 64bit builds.

Use regular unsigned since that's what gallium expects, but use a
typedef to facilitate possible changes in the future.
2009-06-18 14:54:08 +01:00
José Fonseca
42882897c6 wgl: Fix window resizing in multithread applications.
In multithreading stw_call_window_proc can be called by a thread other
than the thread where the context is bound.
2009-06-18 14:54:07 +01:00
José Fonseca
4b4855c717 wgl: Move all thread related code together.
Not only for cosmetic reasons, but also because we need to set the
SetWindowsHookEx hook for threads created before the DllMain is called
(threads for each we don't get the DLL_THREAD_ATTACH notification).
2009-06-18 14:54:07 +01:00
Keith Whitwell
1b05b5b4fe glew: correct misspelling of glFramebufferTextureLayer
This was misspelt as glFramebufferTexturLayer (missing e), causing
conflicts with the correctly spelt version in glext.h and extfuncs.h.
2009-06-18 10:13:55 +01:00
Keith Whitwell
0491142152 mesa: protect Elements against multiple definitions
Mesa and gallium both have a definition of this macro
2009-06-18 09:53:45 +01:00
Brian Paul
39366ed995 intel: remove extra \n from warning string
(cherry picked from commit 42e9bde0fa)
2009-06-17 12:55:26 -07:00
Robert Ellison
d446d3acac i965: fix 1D texture borders with GL_CLAMP_TO_BORDER
With 1D textures, GL_TEXTURE_WRAP_T should be ignored (only
GL_TEXTURE_WRAP_S should be respected).  But the i965 hardware
seems to follow the value of GL_TEXTURE_WRAP_T even when sampling
1D textures.

This fix forces GL_TEXTURE_WRAP_T to be GL_REPEAT whenever 1D
textures are used; this allows the texture to be sampled
correctly, avoiding "imaginary" border elements in the T direction.

This bug was demonstrated in the Piglit tex1d-2dborder test.
With this fix, that test passes.
(cherry picked from commit ab6c4fa582)
2009-06-17 12:55:26 -07:00
Robert Ellison
56235ae504 i965: send all warnings through _mesa_warning()
One warning message:
   drm_i915_getparam: -22

was still being sent to fprintf().  This causes all Piglit tests to fail,
even with MESA_DEBUG=0.

Using _mesa_warning() to emit the message allows the general Mesa controls
for messages like this to be applied.
(cherry picked from commit bc3270e99f)
2009-06-17 12:55:26 -07:00
Robert Ellison
e15aebe10e i965: fix segfault on low memory conditions
When out of memory (in at least one case, triggered by a longrunning
memory leak), this code will segfault and crash.  By checking for the
out-of-memory condition, the system can continue, and will report
the out-of-memory error later, a much preferable outcome.
(cherry picked from commit 44a4abfd4f)
2009-06-17 12:55:26 -07:00
Ian Romanick
a70c45bdab Fast path when rebinding the same texture in single context environment
If there is no shared context, there is no purpose in rebinding the same
texture.  In some artificial tests this improves performance 10% - 30%.
(cherry picked from commit 7f8000db8b)
2009-06-17 12:55:26 -07:00
Eric Anholt
ff3da0966f i915: Don't put VBOs in graphics memory unless required for an operation.
This saves doing swtnl from uncached memory, which is painful.  Improves
clutter test-text performance by 10% since it started using VBOs.
(cherry picked from commit a945e203d4)
2009-06-17 11:08:36 -07:00
Eric Anholt
1b8e4dd2c8 i915: Fall back on NPOT textured metaops on 830-class.
(cherry picked from commit 8ec6e03679)
2009-06-17 11:08:28 -07:00
Eric Anholt
cee73ffdaf i915: Restore the Viewport and DepthRange functions on 8xx.
Fixes failed viewport updates on glxgears (and other apps) resize since
e41780fedc.

Bug #20473.
(cherry picked from commit 0e83e8f51a)
2009-06-17 11:08:13 -07:00
Eric Anholt
7805c3b57b i956: Make state dependency of SF on drawbuffer bounds match Mesa's.
Noticed while debugging a weird 1D FBO testcase that left its existing
viewport and projection matrix in place when switching drawbuffers.  Didn't
fix the testcase, though.
(cherry picked from commit 3a521d84ec)
2009-06-17 11:07:03 -07:00
Eric Anholt
97974b7e51 intel: Don't complain on falling back from PBO fastpaths.
Instead, stash the debug info under the handy debug flag.

Bug #20053
(cherry picked from commit 22690482e6)
2009-06-17 11:06:52 -07:00
Eric Anholt
957f3c8c3d mesa: Mark FBOs with compressed color attachments as FBO-incomplete.
Both EXT_fbo and ARB_fbo agree on this.  Fixes a segfault in the metaops
mipmap generation in Intel for SGIS_generate_mipmap of S3TC textures in
Regnum Online.

Bug #21654.
(cherry picked from commit 0307e609aa)
2009-06-17 11:06:46 -07:00
Eric Anholt
66bfd025c8 i915: Use Stencil.Enabled instead of Stencil._Enabled in DrawBuffers.
The _Enabled field isn't updated at the point that DrawBuffers is called,
and the Driver.Enable() function does the testing for stencil buffer
presence anyway.

bug #21608 for Radeon
(cherry picked from commit 4c6f829899)
2009-06-17 11:06:38 -07:00
Eric Anholt
fbd554d074 i915: Only use the new 945 cube layout for compressed textures.
The docs actually explain this, but not in a terribly clear manner.
This nearly fixes the piglit cubemap testcase, except that something's
going wrong with the nearest filtering at 2x2 sizes in the testcase.
Looks good by visual inspection, though.

Bug #21692
(cherry picked from commit 5c5a468848)
2009-06-17 11:06:25 -07:00
Eric Anholt
6e0df938d4 i965: Fix varying payload reg assignment for the non-GLSL-instructions path.
I don't have a testcase for this, but it seems clearly wrong.
(cherry picked from commit dc657f3929)
2009-06-17 11:05:55 -07:00
Eric Anholt
988b61be27 i965: Fix register allocation of GLSL fp inputs.
Before, if the VP output something that is in the attributes coming into
the WM but which isn't used by the WM, then WM would end up reading subsequent
varyings from the wrong places.  This was visible with a GLSL demo
using gl_PointSize in the VS and a varying in the WM, as point size is in
the VUE but not used by the WM.  There is now a regression test in piglit,
glsl-unused-varying.

(cherry picked from commit 0f5113deed)
2009-06-17 11:04:31 -07:00
Eric Anholt
320a303be0 intel: Use FRONT_AND_BACK for StencilOp as well.
(cherry picked from commit 64980125c7)
2009-06-17 10:52:56 -07:00
Eric Anholt
d9e35d51fd intel: Use GL_FRONT_AND_BACK for stencil clearing.
This comes from a radeon-rewrite fallback fix, but may also fix stencil
clear failure when the polygon winding mode is flipped.
(cherry picked from commit d866abeffc)
2009-06-17 10:52:54 -07:00
Eric Anholt
61a2c9668f intel: Skip the DRI2 renderbuffer update when doing Viewport on an FBO.
(cherry picked from commit d4a42b0ce6)
2009-06-17 10:52:49 -07:00
Eric Anholt
2770107d87 intel: Map write-only buffer objects through the GTT when possible.
This looks to be a win of a few percent in cairogears with new vbo code,
thanks to not polluting caches.
(cherry picked from commit aa422b2625)
2009-06-17 10:52:30 -07:00
Brian Paul
3f856c6b6b mesa: rework viewport/scissor initialization code
The first time a context is bound to a drawable, the viewport and scissor
bounds are initialized to the buffer's size.  This is actually a bit tricky.

A new _mesa_check_init_viewport() function is called in several places
to check if the viewport has been initialized.  We also use a new
ctx->ViewportInitialized flag instead of the overloaded
ctx->FirstTimeCurrent flag.
2009-06-17 08:38:38 -06:00
Brian Paul
d18c57aaea mesa: added null ptr check in Fake_glXCreatePixmap()
Fixes segfault in progs/xdemos/glxgears_pixmap.c
2009-06-17 08:38:38 -06:00
Brian Paul
3705f48688 st/glx: added null ptr check in Fake_glXCreatePixmap()
Fixes segfault in progs/xdemos/glxgears_pixmap.c
2009-06-17 08:38:38 -06:00
José Fonseca
c6f71eabd8 Revert "scons: Debug build by default."
Per Brian's request.

This reverts commit 25f0c33bb3.
2009-06-17 15:24:06 +01:00
José Fonseca
1bee650ef3 progs/wgl: Fix shreadtex_mt too. 2009-06-17 15:23:25 +01:00
José Fonseca
6e24fdeae5 progs/wgl: Tweak the initialization wait in wglthreads.
There was still a non-zero probability for wglShareLists of failing.
2009-06-17 15:23:25 +01:00
José Fonseca
557421b6de progs/wgl: Get wglShareLists working in wglthreads.
wglShareLists is a little picky -- it seems to check if it has exclusive
access to a lock, and fails if it doesn't.

This allows the texture to be shared with all windows.
2009-06-17 15:23:25 +01:00
José Fonseca
25f0c33bb3 scons: Debug build by default.
Match what autotools and other build systems do by default.
2009-06-17 15:23:24 +01:00
Brian Paul
c53705ed7b GLX: attempt to fix glean makeCurrent test cases.
Two parts to this:

One we don't keep pointers to possibly freed memory anymore once we unbind the
drawables from the context. Brian I need to figure out what the comment
you made there, can we get a glean/piglit test so we can fix it properly?

If the new gc is the same as the oldGC, we call the unbind even though
we just bound it in that function. doh.

(cherry picked from master, commit 77506dac8e)
2009-06-17 08:03:19 -06:00
José Fonseca
ebe0796ba2 docs: Document building with SCons. 2009-06-17 10:12:11 +01:00
José Fonseca
d22828f716 wgl: Factor out some repetitive code into inline functions. 2009-06-17 10:08:25 +01:00
José Fonseca
992000cce7 progs/wgl: Allow resizing wglthreads' windows. 2009-06-17 10:08:24 +01:00
Brian Paul
6b917d0b17 i965: fix bugs in projective texture coordinates
For the TXP instruction we check if the texcoord is really a 4-component
atttibute which requires the divide by W step.  This check involved the
projtex_mask field.  However, the projtex_mask field was being miscalculated
because of some confusion between vertex program outputs and fragment
program inputs.

1. Rework the size_masks calculation so we correctly set bits corresponding
to fragment program input attributes.

2. Rename projtex_mask to proj_attrib_mask since we're interested in more
than just texcoords (generic varying vars too).

3. Simply the indexing of the size_masks and proj_attrib_mask fields.

4. The tracker::active[] array was mis-dimensioned.  Use MAX_PROGRAM_TEMPS
instead of a magic number.

5. Update comments, add new assertions.

With these changes the Lightsmark demo/benchmark renders correctly, until
we eventually hit a GPU lockup...
2009-06-16 18:21:26 -06:00
Brian Paul
742ba08406 softpipe: fix out of bounds quad rasterization bug
For some triangles we can generate quads which lie just outside the
surface bounds.  Just check the quad's mask before trying to emit/process
the quad.

Fixes failed assertion in Lightsmark.
2009-06-16 15:41:49 -06:00
Brian Paul
3e48dd0445 mesa: fix incorrect viewport clamping in _mesa_set_viewport()
A 0 by 0 viewport size is legal.  Don't clamp against lower bound of one.
The error checking earlier in the function prevents negative values.
2009-06-16 09:34:35 -06:00
Brian Paul
ed7f4b4230 mesa: fix REMAINDER() macro
The results were incorrect for some negative values of A.
See bug 21872.
2009-06-16 08:45:56 -06:00
José Fonseca
3463b1479d gallium: Avoid atomic ops / locking when src is dst. 2009-06-16 13:05:25 +01:00
José Fonseca
077c5e62d8 progs/wgl: Quit after displaying usage for -h option. 2009-06-16 12:34:29 +01:00
José Fonseca
06075711af progs/wgl: Use appropriate types to silence msvc warnings. 2009-06-16 12:29:58 +01:00
José Fonseca
566bdbe67d progs/wgl: Fix assertion failure in wglthreads' texture creation. 2009-06-16 12:29:58 +01:00
Shuang He
d027e8feff intel: Release fb backing regions in intelDestroyBuffer()
Fixes memory leak when destroying framebuffers.
2009-06-15 16:19:30 -06:00
José Fonseca
227d233cff python/tests: Add is_depth_stencil_format utility function. 2009-06-15 19:22:35 +01:00
José Fonseca
7585cbffe0 python/tests: Cleanup texture_sample. 2009-06-15 19:21:58 +01:00
José Fonseca
c6af9b2947 mesa: Always return a value. 2009-06-15 19:20:25 +01:00
José Fonseca
053d8eb891 mesa: Use appropriate float/integer types. 2009-06-15 19:20:05 +01:00
José Fonseca
6214c7262f mesa: Use type modifier for float constants. 2009-06-15 19:19:29 +01:00
José Fonseca
37f2117cd1 mesa: Use integer type with appropriate sign. 2009-06-15 19:17:07 +01:00
José Fonseca
c33ef1f7c6 rtasm: Use 32bit constant.
As we're only using 32bit bitmasks.
2009-06-15 19:04:04 +01:00
José Fonseca
940cb7ce16 gallium: Ensure assert macro is defined before being used in p_thread.h 2009-06-15 18:57:45 +01:00
José Fonseca
5d0cf9ebb4 softpipe: Fix softpipe_is_texture_referenced.
Render results are only visible when the render cache is flushed.
softpipe_is_texture_referenced must reflect that or transfers to/from the
textures bound in the framebuffer won't be proceeded of the necessary
flush, causing transfer data to be outdated/clobbered.

This fixes conform drawpix test with softpipe.
2009-06-15 18:42:13 +01:00
José Fonseca
0e1abced56 progs/tests: Use opaque colors.
Transparency is not relevant for this example, and leads to distraction
due to different results in alpha visuals, when capturing images to disk.
2009-06-15 15:40:10 +01:00
Thomas Hellstrom
db22b35d21 dri st: Don't require the PIPE_TEXTURE_USAGE_RENDER_TARGET property for depth- and stencil renderbuffers.
Signed-off-by: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
2009-06-15 11:48:57 +02:00
Thomas Hellstrom
cbe5af766e gallium: Fix segfault and valgrind error introduced with commit 3f2e006b75
Signed-off-by: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
2009-06-15 11:22:06 +02:00
Brian Paul
fb64365642 demos: update fbotexture.c to use EXT or ARB functions exclusively
When the -arb option is specified we use GL_ARB_framebuffer_object intead
of GL_EXT_framebuffer_object.

For some vendors' OpenGL it's important to call the ARB entrypoints
instead of the EXT entrypoints to get correct behaviour.  Use some
function pointer tricks to do this (instead of GLEW).
2009-06-12 08:15:33 -06:00
Brian Paul
476685c63c util: additional function pointers 2009-06-12 08:15:33 -06:00
Jakob Bornecrantz
c6de08fff4 mesa: Enable uploads of only depth to z24s8 textures 2009-06-12 12:29:02 +01:00
Brian Paul
3754c4135c mesa: rework vertex shader output / fragment shader input attribute matching
Before, if a vertex shader's outputs didn't exactly match a fragment
shader's inputs we could wind up with invalid TGSI shader declarations.
For example:

Before patch:
DCL OUT[0], POSITION
DCL OUT[1], COLOR[1]
DCL OUT[2], GENERIC[0]
DCL OUT[3], GENERIC[0] <- note duplicate [0]
DCL OUT[4], GENERIC[2]

After patch:
DCL OUT[0], POSITION
DCL OUT[1], COLOR[1]
DCL OUT[2], GENERIC[0]
DCL OUT[3], GENERIC[1]
DCL OUT[4], GENERIC[2]
2009-06-11 14:58:25 -06:00
Brian Paul
322e8556b9 mesa: add default function for ctx->Driver.CheckQuery() hook 2009-06-11 14:58:25 -06:00
José Fonseca
0ddc38309a python/retrace: Show the contents of the depth/stencil and surfaces before/after transfers. 2009-06-11 20:46:07 +01:00
José Fonseca
e1700009b7 python/retrace: Interpret is_texture_referenced/is_buffer_referenced. 2009-06-11 19:24:48 +01:00
José Fonseca
d5ba39ad08 wgl: Fix prototype. 2009-06-11 19:05:46 +01:00
José Fonseca
de413b1ba9 mesa: Use new pf_is_depth_and_stencil inline. 2009-06-11 19:02:59 +01:00
José Fonseca
3f2e006b75 gallium: New pf_is_depth_and_stencil / pf_is_depth_or_stencil inlines. 2009-06-11 19:02:59 +01:00
José Fonseca
7cafd49c93 mesa: Use PIPE_TEXTURE_USAGE_DEPTH_STENCIL for any depth or stencil format. 2009-06-11 19:02:59 +01:00
José Fonseca
862c7b8cd3 mesa: Remove dead code. 2009-06-11 19:02:59 +01:00
Brian Paul
bb0b954f12 st/mesa: fix typo s/BFC0/BFC1/ 2009-06-11 10:40:19 -06:00
Brian Paul
9d5479eeeb vbo: fix assertion, #define IMM_BUFFER_NAME
This was sometimes seen when Glean exited upon test failure when using
Gallium.
2009-06-11 09:46:02 -06:00
José Fonseca
cc09724a50 python/tests: Test sampling from a depth texture. 2009-06-11 16:22:17 +01:00
Jakob Bornecrantz
41cf681535 mesa: Only do read write when we don't have a depth value to write 2009-06-11 15:37:53 +01:00
José Fonseca
e3f14f2f3b progs: Port fp programs to GLEW. 2009-06-11 13:19:34 +01:00
José Fonseca
48d816b8ff mesa: Take the format from the right structure. 2009-06-11 12:23:09 +01:00
José Fonseca
96aca15c9d meas: Use a read/write transfer when writing stencil component, but not touching the depth component. 2009-06-11 11:47:20 +01:00
José Fonseca
337f559cd2 mesa: Reverse s8z24 into z24s8 as required by EXT_packed_depth_stencil.
Actually, after spotting this problem, I realized this is unreachable
code. However don't bother to enable this fast path now, given the normal
path is working just fine.
2009-06-10 21:29:25 +01:00
José Fonseca
8fa8669aeb mesa: Fix typo in bitmask. 2009-06-10 21:25:54 +01:00
José Fonseca
0a4fcabe44 mesa: Fix draw_stencil_pixels for PIPE_FORMAT_Z24S8_UNORM.
Reversed component order.

This fixes glean depthStencil test failures for PIPE_FORMAT_Z24S8_UNORM
visuals.
2009-06-10 20:05:00 +01:00
Brian Paul
dbab657fe7 glsl: fix warnings, update comments, s/TRUE/GL_TRUE/
(cherry picked from master, commit 7fdd64ab29)
2009-06-10 12:22:36 -06:00
Brian Paul
9225b67383 glsl: Handle continuation characters in preprocessor.
(cherry picked from master, commit cc22620e4b)
2009-06-10 12:21:56 -06:00
Brian Paul
88527220e4 swrast: fix state validation bug for changing program constants
Add _NEW_PROGRAM_CONSTANTS to _SWRAST_NEW_DERIVED.
This makes sure that we update the fragment shader's constants when state
vars (such as point size) changes.
Fixes the progs/glsl/points.c demo.
2009-06-10 09:31:01 -06:00
Brian Paul
506989b20e glsl: Fix symbol replacement handling in preprocessor.
(cherry picked from master, commit d9617deb00)
2009-06-10 09:31:01 -06:00
Brian Paul
6f50c9865d mesa: disable texture unit error check in _mesa_MatrixMode()
See comments for details.
2009-06-10 09:31:01 -06:00
Brian Paul
5450281ff7 docs: document GLSL preprocessor fixes 2009-06-10 09:31:01 -06:00
José Fonseca
4d16eb5e18 util: Single precision constants. 2009-06-10 15:39:47 +01:00
José Fonseca
978bca8b2a mesa: Single precision constants. 2009-06-10 15:39:34 +01:00
José Fonseca
52411a1951 mesa: Pure software accum buffer.
The existing implementation was already implemented on software, but relied
on the pipe driver to always support the R16G16B16A16_SNORM format. This
patch eliminates that, without prejudice against a future hardware-only
implementation.

It also avoids some of the short <-> float conversions, and only does a read
transfer of the color buffer on GL_RETURN if absolutely necessary.
2009-06-10 15:39:02 +01:00
José Fonseca
8bfbb7ec8b gallium: Shorthand functions for computing stride and sizes for a rect. 2009-06-10 15:31:12 +01:00
Keith Whitwell
76a1017e97 mesa/st: fix tracking of mapped buffer ranges
In st_bufferobj_map_range(), set obj->Offset consistently with its
usage elsewhere.
2009-06-09 18:32:18 +01:00
Keith Whitwell
9192347443 stw: ignore swapbuffer requests on singlebuffer
Return TRUE in this case.  Returning FALSE seems to result in
mis-rendering -- possibly opengl32.dll is trying to compensate by
doing a software blit??
2009-06-09 16:37:38 +01:00
Brian Paul
cb549775a5 glsl: Expand nested preprocessor macros.
(cherry picked from master, commit ef8caec29a)
2009-06-09 09:14:38 -06:00
Brian Paul
34bb024cf2 st/mesa: fix incorrect bufObj Length assignment, remove unneeded assertion 2009-06-08 16:11:17 -06:00
Jon TURNEY
7eed6ab5b5 Cygwin build fixes
Fix mklib to deal with NOPREFIX and use --enable-auto-image-base for cygwin
Teach configure.ac some basic facts about cygwin

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2009-06-08 14:30:46 -06:00
Brian Paul
304ba4bba4 glsl: Fix preprocessor define argument parsing for dead sections.
(cherry picked from master, commit 19a54d9f10)
2009-06-08 13:53:33 -06:00
Jakob Bornecrantz
77c329a277 pipebuffer: Silence out of heap space debug print 2009-06-08 19:54:55 +02:00
Brian Paul
b6753adbc7 st/mesa: remove invalid assertion
It's legal for ARB_vertex_program programs to not write to result.position.
The results are undefined in that case.  This assertion was causing us to
abort/exit though.
2009-06-08 10:46:46 -06:00
José Fonseca
e09f78d8dc mesa: Use matching signedness for the counter as upper bound. 2009-06-08 16:56:41 +01:00
José Fonseca
42678dba94 mesa: Allocate tokens from the heap.
The recent increase ST_MAX_SHADER_TOKENS to 8K causes stack overflows on
windows.

Failure to allocate is not being propagated to the caller. This is not
a regression since the previous _mesa_malloc result wasn't being
checked as well. Unfortunately it is not easy to fix, as the callers of
these functions do not have failure propagation mechanism either, and
so on. So leaving a just fixme note for now.
2009-06-08 16:56:41 +01:00
Brian Paul
33d6327770 mesa: better error message for invalid texture unit index 2009-06-08 09:53:00 -06:00
Brian Paul
0bced6a326 mesa: bump MAX_PROGRAM_ENV_PARAMS from 128 to 256
Also, MAX_NV_VERTEX_PROGRAM_PARAMS should be 96, not 128 (or 256).
2009-06-08 09:53:00 -06:00
Keith Whitwell
0d3c8fbf12 mesa/vbo: drop all references to vbo on destroy
We were adding references to the input arrays, but failing to drop
them on destruction.  This could lead to a 64kb buffer being leaked
each context destruction.
2009-06-08 16:27:43 +01:00
Brian Paul
fce4ee12a6 mesa: EXT_vertex_array_bgra fixes
1) Pass the correct format when calling update_array in
   _mesa_VertexAttribPointerARB.
2) glVertexAttribPointerNV accepts GL_BGRA format too.
3) raise INVALID_VALUE error when format is BGRA and normalized is
   false in glVertexAttribPointerARB

(cherry picked from commit 4adb190a16)
2009-06-08 07:25:24 -06:00
Jakob Bornecrantz
4d9d0e6230 stw: If stfb not set don't call into mesa 2009-06-08 14:45:56 +02:00
Jakob Bornecrantz
283e84bfb3 progs/tests: Add some scissor tests 2009-06-08 14:45:40 +02:00
José Fonseca
78dad27564 Revert "scons: Less aggressive optimizations for MSVC 64bit compiler."
This reverts commit fc7f924782.
2009-06-08 11:13:41 +01:00
Brian Paul
cfff2a6189 mesa: bump version to 7.5-rc3 2009-06-05 17:16:47 -06:00
Dan Nicholson
6453605785 osmesa: Link with -ldl for dlopen code
Now that the dlopen wrappers are built into libmesa.a, we need to link
standalone libOSMesa with libdl to resolve dlopen and friends on
platforms that need it.
(cherry picked from commit 4795dd5950)
2009-06-04 19:47:41 -07:00
Dan Nicholson
5df6468589 osmesa: Allow building standalone in all three channel widths
autoconf had been designating the 8 bit libOSMesa as the default
standalone osmesa, but the Makefile expected it to be linked to libGL.
Fix up the osmesa Makefile so that it allows any of the combinations of
standalone and channel width to be built.

Fixes bug #21980.
(cherry picked from commit 7441dcd90b)
2009-06-04 19:47:32 -07:00
Brian Paul
9424d81d18 softpipe: separate case for PIPE_PRIM_POLYGON in sp_vbuf_draw()
Because of flat shading, we can't use same code as PIPE_PRIM_TRIANGLE_FAN.
This is a follow-on to commit a59575d8fb.

(cherry picked from commit 086ecea179)
2009-06-04 13:13:14 -06:00
Brian Paul
6907650211 softpipe: fix incorrect tri vertex order for PIPE_PRIM_POLYGON rendering
This fixes incorrect front/back-face orientation.

(cherry picked from commit a64bbdaa3e)
2009-06-04 13:12:13 -06:00
Brian Paul
d37795c453 st/mesa: increase ST_MAX_SHADER_TOKENS to 8k 2009-06-04 13:10:31 -06:00
Brian Paul
45e744dddc tgsi: increase MAX_LABELS to 4096 2009-06-04 13:10:31 -06:00
José Fonseca
fc7f924782 scons: Less aggressive optimizations for MSVC 64bit compiler.
MSVC 64bit compiler takes forever on some of the files.

Might want to revisit this again later.
2009-06-02 18:41:12 -07:00
José Fonseca
0f50c4fab8 scons: Output nice summary messages instead of long command lines.
You can still get the old behavior by passing the option quiet=no to scons.
2009-06-02 18:23:12 -07:00
José Fonseca
273117ceed util: Unsaved change missing from last commit. 2009-06-02 16:41:45 -07:00
José Fonseca
840af5fd62 util: Support Z24S8/Z24X8 -> unsigned conversion. 2009-06-02 11:46:53 -07:00
José Fonseca
c91df4c153 util: Fix 24 to 32 bit expansion binary arithmetic expression.
When approaching y = x * 0xffffffff / 0xffffff with bit arithmetic, the
8 least significant bits of y should come from the
8 most significant bits of x.
2009-06-02 11:46:06 -07:00
Brian Paul
12e94d892e mesa: release VBO and PBO references upon context destruction 2009-06-02 10:29:39 -06:00
Brian Paul
cb3a9f984d mesa: add #define FEATURE_ARB_pixel_buffer_object 2009-06-02 10:29:38 -06:00
Ian Romanick
16fbd39129 intel: Clip to window after calling Driver.TexImage2D
This prevents the width / height from being clipped to the window size before
the texture is allocated.  This matches intelCopyTexImage1D.

This should fix bug #21227

Signed-off-by: Ian Romanick <ian.romanick@intel.com>
(cherry picked from commit 129f311673)
2009-06-02 16:52:03 +01:00
Keith Whitwell
1aef032d43 gallium/draw: Free specialized versions of driver shaders
The pstipple, aaline and aapoint code would create specialized versions
of shaders and upload them to the driver -- but never free them.
2009-06-01 20:35:38 -07:00
Keith Whitwell
003cfd4dd2 draw: free more token arrays
The AA line and point code also needs to free token arrays after
building driver shaders.
2009-06-01 20:35:38 -07:00
Keith Whitwell
69a765df1c draw: avoid leaking tokens when building pstipple fragment shader
Add missing FREE() after MALLOC().
2009-06-01 20:35:38 -07:00
Keith Whitwell
503632557e mesa/st: restore flush to copy_texsubimage (was previously finish)
Need a flush here even though the original finish was overkill.
2009-06-01 20:34:44 -07:00
José Fonseca
557d2bb423 wgl: Destroy the framebuffer when the window is destroyed. 2009-06-01 20:20:48 -07:00
Keith Whitwell
97f5953ced progs/vpglsl: add similar support for point rendering as progs/vp 2009-06-01 18:40:21 -07:00
Jakob Bornecrantz
f989390af6 st/gl: Fix mip gen for compressed textures 2009-06-01 18:40:12 -07:00
Keith Whitwell
00e7a60077 trivial/tri-z: add controls for depthrange min/max
Also add key to set up quake-1 style ztrick rendering with clear depth
1.0, deptrange(1.0, 0.0) and depthfunc GL_GREATER.
2009-06-01 18:39:58 -07:00
José Fonseca
3c756ed39f progs/wgl: Small cleanup to wglinfo. 2009-06-01 18:23:20 -07:00
José Fonseca
76ad2b4a5a progs/wgl: Use an invisible window in wglinfo. 2009-06-01 18:23:20 -07:00
Brian Paul
0e8a5a8474 st/mesa: fix incorrect sprite origin when drawing to FBO/texture
Need to take the draw buffer's up/down orientation into consideration
when setting the sprite_coord_mode field.

Fixes inverted sprites when drawing into an FBO.
2009-06-01 14:59:11 -06:00
Brian Paul
427554211b draw: reset extra_vp_outputs.slot to zero in widepoint_flush()
Fixes a crash when clearing the window with a quad after drawing large
points.  We were asking the draw module how many vertex shader outputs
there were and got 3 instead of 2.  This led to creating vertices with
too many attributes and trying to read invalid memory.

We reset extra_vp_outputs.slot to zero in the aaline/aapoint stage's
flush functions already.
This omission was just an oversight in the wide_point stage.
2009-06-01 14:28:57 -06:00
Brian Paul
a5d033e89b demos: add missing dependencies for util files 2009-06-01 11:23:39 -06:00
José Fonseca
ea3ee4791e wgl: Cleanup framebuffer destruction logic. 2009-05-31 17:16:26 -07:00
José Fonseca
0ea519f931 wgl: Ensure we only create framebuffers for HDC associated with a window. 2009-05-31 11:10:22 -07:00
José Fonseca
fe69b6bdc7 wgl: Use the right pixel format.
There is no current pixel format. Each HDC has its pixelformat which is
kept by gdi and set/get via the SetPixelFormat/GetPixelFormat functions.

Now the HDC's pixelformat is kept in the stw_framebuffer, which is
created during the SetPixelFormat.
2009-05-30 20:29:03 -07:00
José Fonseca
be7c56be06 wgl: Fix debugging output. 2009-05-30 20:29:03 -07:00
José Fonseca
76f2bacb07 wgl: Rename function. 2009-05-30 20:29:03 -07:00
José Fonseca
1124f786c1 wgl: Remove unused field. 2009-05-30 20:29:03 -07:00
José Fonseca
5bb2074798 mesa: Output warnings to debugger on Windows.
Stderr of Windows applications without console is not usually
visible.
2009-05-30 20:29:02 -07:00
José Fonseca
8aef306c34 mesa: Check/propagate return value on st_make_current.
Prevents segmentation fault when trying to set the viewport/scissor
after a context/drawable visual mismatch.
2009-05-30 20:29:02 -07:00
José Fonseca
29c6c8eb18 mesa: Add success/failures return value to _mesa_make_current. 2009-05-30 20:29:02 -07:00
Brian Paul
a59575d8fb softpipe: fix incorrect provoking vertex color for PIPE_PRIM_POLYGON
This fixes the incorrect colors seen when rendering flat-shaded polygons.
Note that clipped polygons were correct, but unclipped polygons were wrong.

See the glean/clipFlat test for regression testing.
2009-05-30 20:07:18 -06:00
Brian Paul
1045481dd9 mesa: fix loop over generic attribs in update_arrays() 2009-05-22 13:50:31 -06:00
Brian Paul
c3538969e1 vbo: fix crash in vbo_exec_bind_arrays()
When a vertex shader uses generic vertex attribute 0, but not gl_Vertex,
we need to set attribute[16] to point to attribute[0].  We were setting the
attribute size, but not the pointer.

Fixes crash in glsl/multitex.c when using the VertCoord attribute instead
of gl_Vertex.
2009-05-22 13:15:41 -06:00
Brian Paul
58fadc6242 demos: fix multitex.c VertCoord attribute mapping
If the multitex.vert shader uses the VertCoord generic vertex attribute
instead of the pre-defined gl_Vertex attribute, we need to make sure that
VertCoord gets bound to generic vertex attribute zero.

That's because we need to call glVertexAttrib2fv(0, xy) after all the other
vertex attributes have been set since setting generic attribute 0 triggers
vertex submission.  Before, we wound up issuing the vertex attributes in
the order 0, 1, 2 which caused the first vertex to be submitted before all
the attributes were set.  Now, the attributes are set in 1, 2, 0 order.
2009-05-22 13:00:49 -06:00
Brian Paul
995456f930 mesa: allow GL_BITMAP type in _mesa_image_image_stride()
It's possible to hand a GL_COLOR_INDEX/GL_BITMAP image to glTexImage3D()
which gets converted to RGBA via the glPixelMap tables.

This fixes a failure with piglit/fdo10370 with Gallium.
2009-05-22 09:35:02 -06:00
Brian Paul
42b747e57d mesa: added comment 2009-05-22 07:14:16 -06:00
Brian Paul
70c4b81e88 mesa: add missing glGet*() case for GL_VERTEX_ARRAY_BINDING_APPLE 2009-05-21 21:49:57 -06:00
Brian Paul
8da09e6924 vbo: fix incorrect loop limit in bind_array_obj()
The generic_array[] is 16 elements in size, but the loop was doing 32
iterations.  The out of bounds array write was clobbering the following
inputs[] array but as luck would have it, that didn't matter.
2009-05-21 16:54:35 -06:00
Brian Paul
d4fb7615b5 mesa: use MAX_ values instead of literals 2009-05-21 16:52:45 -06:00
Carl Worth
d2f4c2b632 minstall: Don't copy over an identical file
The rationale here is to avoid updating a timestamp for a file that
hasn't changed. Needless updates of the timestamp can ripple into
other projects, (xserver, etc.), useless recompiling due to a
'make install' in mesa that didn't actually change anything.
2009-05-21 07:52:13 -06:00
Mathias Fröhlich
042d9a5132 mesa: allow depth/stencil textures to be attached to GL_STENCIL_ATTACHMENT
See sourceforge bug #2793846.
2009-05-19 09:59:01 -06:00
Brian Paul
c99a60c40d mesa: assign trb->Base.StencilBits in update_wrapper().
When we render to a depth/stencil texture there are stencil bits.
2009-05-19 09:57:01 -06:00
Brian Paul
7ce105d2e6 st/mesa: fix incorrect src/dst stride params to _mesa_generate_mipmap_level()
The stride needs to be in texels, not bytes.
2009-05-18 10:28:04 -06:00
Brian Paul
adabd0e81e mesa: comments for _mesa_generate_mipmap_level() 2009-05-18 10:27:31 -06:00
Brian Paul
30320f0afb softpipe: add texture target sanity check assertion 2009-05-18 10:13:44 -06:00
Brian Paul
14e5bff97b st: fix incorrect target parameter to screen->is_format_supported()
We were passing a GL texture target instead of a pipe_texture_target enum.
2009-05-18 10:12:40 -06:00
Brian Paul
df37cde309 mesa: added linux-osmesa-static config
Contributed by Nicolas Noble.  See SF bug #2792536
2009-05-18 08:47:22 -06:00
Brian Paul
6e61700541 docs: link to 7.5 relnotes 2009-05-18 07:17:46 -06:00
Brian Paul
da0d4e1db6 docs: emphasize the incomplete status of the nouveau/R300 gallium drivers 2009-05-18 07:17:36 -06:00
Aidan Thornton
f2445dfd85 Initialize psp->waitX/waitGL for swrast_dri.so.
Fixes http://bugs.freedesktop.org/show_bug.cgi?id=21053 .
2009-05-18 12:47:00 +02:00
Brian Paul
483e247804 mesa: bump version to 7.5-rc2 2009-05-15 08:03:56 -06:00
Brian Paul
65b9cd74e3 docs: updates from the 7.4 branch 2009-05-15 08:02:40 -06:00
Michel Dänzer
09c04db3c9 r300: Make sure to drop current hardware state reference to texture objects.
Fixes potential texture object leaks.
2009-05-14 11:13:06 +02:00
Brian Paul
99960393ed intel: added null ptr check
Fixes segfault in context tear-down when glClear was never called.
2009-05-13 11:33:16 -06:00
Brian Paul
2e4e346890 intel: create a private gl_array_object for intel_clear_tris(), fix bug 21638
gl_array_object encapsulates a set of vertex arrays (see the
GL_APPLE_vertex_array_object extension).
Create a private gl_array_object for drawing the quad for intel_clear_tris()
so we don't have to worry about the user's vertex array state.
This fixes the no-op glClear bug #21638 and removes the need to call
_mesa_PushClientAttrib() and _mesa_PopClientAttrib().
2009-05-13 10:28:00 -06:00
Brian Paul
3e74faa029 mesa: delete array objects before buffer objects during context tear-down
The former may point to the later.
2009-05-13 09:47:13 -06:00
Brian Paul
7ae4ce9e22 mesa: clean-up vertex array object VBO unbinding and delete/refcounting
Don't really delete vertex array objects until the refcount hits zero.
At that time, unbind any pointers to VBOs.
(cherry picked from commit 32b851c807)
2009-05-13 09:32:53 -06:00
Brian Paul
5568f2f601 mesa: reference counting for gl_array_object
Every kind of object that can be shared by multiple contexts should be
refcounted.
(cherry picked from commit 1030bf0ded)
2009-05-13 09:27:31 -06:00
Michel Dänzer
46b81b0cc8 glXChooseVisual: Only consider fbconfig if we can get the corresponding visual.
This can fail, e.g. when XLIB_SKIP_ARGB_VISUALS=1 is set.

See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=524794 and
http://bugs.freedesktop.org/show_bug.cgi?id=21600 .
2009-05-12 09:34:13 +02:00
Ian Romanick
64f36ff9fb Test either GL_FRONT_LEFT or GL_FRONT for front-buffer rendering
For non-stereo visuals, which is all we support, we treat
GL_FRONT_LEFT as GL_FRONT.  However, they are technically different,
and they have different enum values.  Test for either one to determine
if we're in front-buffer rendering mode.

This fix was suggested by Pierre Willenbrock.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
(cherry picked from commit 2085cf2462)
2009-05-11 17:16:11 -07:00
Brian Paul
f104e4d666 st: do proper refcounting for framebuffer surfaces 2009-05-11 16:09:39 -06:00
Brian Paul
f5cf181c65 trivial: destroy window upon exit 2009-05-11 16:08:01 -06:00
Brian Paul
2223615e0a mesa: Fixed a texture memory leak
The current texture for any particular texture unit is given an additional
reference in update_texture_state(); but if the context is closed before
that texture can be released (which is quite frequent in normal use, unless
a program unbinds and deletes the texture and renders without it to force
a call to update_texture_state(), the memory is lost.

This affects general Mesa; but the i965 is particularly affected because
it allocates a considerable amount of additional memory for each allocated
texture.

(cherry picked from master, commit c230767d69)
2009-05-11 09:46:56 -06:00
Brian Paul
31865904d8 mesa: added more gallium Makefiles to tarball list 2009-05-09 16:21:16 -06:00
Hanno Böck
c8c0953294 gallium: replace lib with $(LIB_DIR) 2009-05-09 16:17:37 -06:00
216 changed files with 5028 additions and 1853 deletions

View File

@@ -127,6 +127,7 @@ linux-icc \
linux-icc-static \
linux-llvm \
linux-osmesa \
linux-osmesa-static \
linux-osmesa16 \
linux-osmesa16-static \
linux-osmesa32 \
@@ -181,7 +182,7 @@ ultrix-gcc:
# Rules for making release tarballs
VERSION=7.5-rc1
VERSION=7.5-rc4
DIRECTORY = Mesa-$(VERSION)
LIB_NAME = MesaLib-$(VERSION)
DEMO_NAME = MesaDemos-$(VERSION)
@@ -327,6 +328,7 @@ GALLIUM_FILES = \
$(DIRECTORY)/src/gallium/*/*/*/SConscript \
$(DIRECTORY)/src/gallium/*/*/*/*.[ch] \
$(DIRECTORY)/src/gallium/*/*/*/*.py \
$(DIRECTORY)/src/gallium/*/*/*/*/Makefile \
$(DIRECTORY)/src/gallium/*/*/*/*/*.[ch] \

View File

@@ -66,8 +66,11 @@ if [ $# -ge 2 ] ; then
elif [ -f "$FILE" ] ; then
#echo "$FILE" is a regular file
$RM "$DEST/`basename $FILE`"
cp "$FILE" "$DEST"
# Only copy if the files differ
if ! cmp -s $FILE $DEST/`basename $FILE`; then
$RM "$DEST/`basename $FILE`"
cp "$FILE" "$DEST"
fi
if [ $MODE ] ; then
FILE=`basename "$FILE"`
chmod $MODE "$DEST/$FILE"

View File

@@ -885,6 +885,17 @@ case $ARCH in
CYGWIN*)
# GCC-based environment
if [ $NOPREFIX = 1 ] ; then
# No "lib" or ".so" part
echo "mklib: Making CYGWIN shared library: " ${LIBNAME}
OPTS="-shared -Wl,--enable-auto-image-base"
if [ "${ALTOPTS}" ] ; then
OPTS=${ALTOPTS}
fi
rm -f ${LIBNAME}
${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
FINAL_LIBS=${LIBNAME}
else
CYGNAME="cyg${LIBNAME}" # prefix with "cyg"
LIBNAME="lib${LIBNAME}" # prefix with "lib"
@@ -901,11 +912,11 @@ case $ARCH in
# finish up
FINAL_LIBS=${LIBNAME}.a
else
OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
OPTS="-shared -Wl,--enable-auto-image-base -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
if [ "${ALTOPTS}" ] ; then
OPTS=${ALTOPTS}
fi
echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll
echo "mklib: Making" $ARCH "shared library: " ${CYGNAME}-${MAJOR}.dll
if [ $CPLUSPLUS = 1 ] ; then
LINK="g++"
@@ -914,7 +925,8 @@ case $ARCH in
fi
# rm any old libs
rm -f ${LIBNAME}-${MAJOR}.dll
rm -f ${CYGNAME}-${MAJOR}.dll
rm -f ${LIBNAME}-${MAJOR}.dll.a
rm -f ${LIBNAME}.dll.a
rm -f ${LIBNAME}.a
@@ -927,6 +939,7 @@ case $ARCH in
# special case for installing in bin
FINAL_BINS="${CYGNAME}-${MAJOR}.dll"
fi
fi
;;
'example')

View File

@@ -55,7 +55,7 @@ def AddOptions(opts):
from SCons.Options.EnumOption import EnumOption
opts.Add(BoolOption('debug', 'debug build', 'no'))
opts.Add(BoolOption('profile', 'profile build', 'no'))
#opts.Add(BoolOption('quiet', 'quiet command lines', 'no'))
opts.Add(BoolOption('quiet', 'quiet command lines', 'yes'))
opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine,
allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
opts.Add(EnumOption('platform', 'target platform', default_platform,

View File

@@ -0,0 +1,37 @@
# Configuration for building static libOSMesa.a on Linux, no Xlib driver
# This doesn't really have any Linux dependencies, so it should be usable
# on other (gcc-based) systems.
include $(TOP)/configs/default
CONFIG_NAME = linux-osmesa
# Compiler and flags
CC = gcc -m32
CXX = g++ -m32
CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DPTHREADS
CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
MKLIB_OPTIONS = -static
# Library names (actual file names)
GL_LIB_NAME = libGL.a
GLU_LIB_NAME = libGLU.a
GLUT_LIB_NAME = libglut.a
GLW_LIB_NAME = libGLw.a
OSMESA_LIB_NAME = libOSMesa.a
# Directories
SRC_DIRS = mesa glu
DRIVER_DIRS = osmesa
PROGRAM_DIRS = osdemos
# Dependencies
GL_LIB_DEPS =
OSMESA_LIB_DEPS =
GLU_LIB_DEPS =
GLUT_LIB_DEPS =
GLW_LIB_DEPS =
APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
$(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lpthread -lstdc++ -lm

View File

@@ -222,6 +222,8 @@ else
case "$host_os" in
darwin* )
LIB_EXTENSION='dylib' ;;
cygwin* )
LIB_EXTENSION='dll' ;;
* )
LIB_EXTENSION='so' ;;
esac
@@ -826,12 +828,12 @@ case "$mesa_driver" in
osmesa)
# only link libraries with osmesa if shared
if test "$enable_static" = no; then
OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS"
else
OSMESA_LIB_DEPS=""
fi
OSMESA_MESA_DEPS=""
OSMESA_PC_LIB_PRIV="-lm -lpthread $SELINUX_LIBS"
OSMESA_PC_LIB_PRIV="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS"
;;
*)
# Link OSMesa to libGL otherwise
@@ -845,9 +847,6 @@ osmesa)
OSMESA_PC_REQ="gl"
;;
esac
if test "$enable_static" = no; then
OSMESA_LIB_DEPS="$OSMESA_LIB_DEPS"
fi
OSMESA_PC_LIB_PRIV="$OSMESA_PC_LIB_PRIV"
AC_SUBST([OSMESA_LIB_DEPS])
AC_SUBST([OSMESA_MESA_DEPS])
@@ -1076,6 +1075,9 @@ if test "x$APP_LIB_DEPS" = x; then
solaris*)
APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
;;
cygwin*)
APP_LIB_DEPS="-lX11"
;;
*)
APP_LIB_DEPS="-lm"
;;

View File

@@ -123,48 +123,46 @@ These are the instructions for making a new Mesa release.
<H3>Get latest source files</H3>
<p>
Use "cvs update -dAP " to get the latest Mesa files from CVS.
Use git to get the latest Mesa files from the git repository, from whatever
branch is relevant.
</p>
<H3>Verify and update version info</H3>
<p>
Create/edit the docs/RELNOTES-X.Y file to document what's new in the release.
Add the new RELNOTES-X.Y file to <a href="relnotes.html">relnotes.html</a>.
Update the docs/VERSIONS file too.
Create/edit the docs/relnotes-x.y.html file to document what's new in the release.
Add the new relnotes-x.y.html file to <a href="relnotes.html">relnotes.html</a>.
</p>
<p>
Edit the MESA_MAJOR, MESA_MINOR and MESA_TINY version numbers in
Update the MESA_MAJOR, MESA_MINOR and MESA_TINY version numbers in
configs/default.
Also update the VERSION line in the top-level Makefile.
</p>
<p>
Make sure the values in src/mesa/main/version.h are correct.
</p>
<p>
Edit the top-level Makefile and verify that DIRECTORY, LIB_NAME and
DEMO_NAME are correct.
</p>
<p>
Update the docs/news.html file and docs/download.html files.
</p>
<p>
Check in all updates to CVS.
Check in all updates to git.
</p>
<p>
Tag the CVS files with the release name (in the form <b>mesa_X_Y</b>).
Tag the files with the release name (in the form <b>mesa_X_Y</b>)
with: <code>git tag -a mesa_X_Y</code>
Then: <code>git push origin mesa_X_Y</code>
</p>
<H3>Make the tarballs</H3>
<p>
Make a symbolic link from $(DIRECTORY) to 'Mesa'. For example,
ln -s Mesa Mesa-6.3
<code>ln -s Mesa Mesa-7.5</code>
This is needed in order to make a correct tar file in the next step.
</p>
@@ -177,7 +175,7 @@ Make the distribution files. From inside the Mesa directory:
<p>
After the tarballs are created, the md5 checksums for the files will
be computed.
Add them to the docs/news.html file.
Add them to the docs/relnotes-X.Y.html file.
</p>
<p>
@@ -191,9 +189,21 @@ Follow the directions on SourceForge for creating a new "release" and
uploading the tarballs.
</p>
<p>
Basically, to upload the tarball files with:
<br>
<code>
rsync -avP ssh Mesa*-X.Y.* USERNAME@frs.sourceforge.net:uploads/
</code>
</p>
<p>
Update the web site by copying the docs/ directory's files to
/home/users/b/br/brianp/mesa-www/htdocs/
/home/users/b/br/brianp/mesa-www/htdocs/ with:
<br>
<code>
sftp USERNAME,mesa3d@web.sourceforge.net
</code>
</p>
<p>

View File

@@ -21,6 +21,7 @@
<li><a href="#pkg-config">Building OpenGL programs with pkg-config
</ul>
<li><a href="#windows">Windows</a>
<li><a href="#scons">SCons</a>
<li><a href="#other">Other</a>
</ol>
<br>
@@ -328,13 +329,60 @@ For example, compiling and linking a GLUT application can be done with:
<H2>2. Windows Compilation and Installation</H1>
<p>
Please see the <a href="README.WIN32">README.WIN32</a> file.
Please see the <a href="#scons">instructions on building with SCons</a>.
Alternatively see <a href="README.WIN32">README.WIN32</a> file.
</p>
<a name="scons">
<H2>3. Building with SCons</H1>
<p>
To build Mesa with SCons on Linux or Windows do
</p>
<pre>
scons
</pre>
<p>
The build output will be placed in
build/<i>platform</i>-<i>machine</i>-<i>debug</i>/..., where <i>platform</i> is for
example linux or windows, <i>machine</i> is x86 or x86_64, optionally followed
by -debug for debug builds.
</p>
<p>
The sample programs are built seperately. To build them do
<pre>
scons -C progs
</pre>
And the build output will be placed in progs/build/...
</p>
<p>
To build Mesa with SCons for Windows on Linux using the MinGW crosscompiler toolchain do
</p>
<pre>
scons platform=windows toolchain=crossmingw machine=x86 statetrackers=mesa drivers=softpipe,trace winsys=gdi
scons -C progs platform=windows toolchain=crossmingw machine=x86 -k
</pre>
<p>
This will create:
</p>
<ul>
<li>build/windows-x86-debug/gallium/winsys/gdi/opengl32.dll &mdash; Mesa + Gallium + softpipe, binary compatible with Windows's opengl32.dll
<li>build/windows-x86-debug/glut/glx/glut32.dll
<li>progs/build/windows-x86-debug/wgl/wglinfo.exe
<li>progs/build/windows-x86-debug/trivial/tri.exe
<li>and many other samples in progs/build/windows-x86-debug/...
</ul>
<p>
Put them all in the same directory to test them.
</p>
<a name="other">
<H2>3. Other systems</H1>
<H2>4. Other systems</H1>
<p>
Documentation for other environments (some may be very out of date):

View File

@@ -11,9 +11,25 @@
<H1>News</H1>
<h2>May tbd, 2009</h2>
<h2>June 23, 2009</h2>
<p>
<a href="relnotes-7.5.html">Mesa 7.5</a> is released.
<a href="relnotes-7.4.4.html">Mesa 7.4.4</a> is released.
This is a stable release that fixes a regression in the i915/i965 drivers
that slipped into the 7.4.3 release.
</p>
<h2>June 19, 2009</h2>
<p>
<a href="relnotes-7.4.3.html">Mesa 7.4.3</a> is released.
This is a stable release fixing bugs since the 7.4.2 release.
</p>
<h2>May 15, 2009</h2>
<p>
<a href="relnotes-7.4.2.html">Mesa 7.4.2</a> is released.
This is a stable release fixing bugs since the 7.4.1 release.
</p>

74
docs/relnotes-7.4.2.html Normal file
View File

@@ -0,0 +1,74 @@
<HTML>
<TITLE>Mesa Release Notes</TITLE>
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
<BODY>
<body bgcolor="#eeeeee">
<H1>Mesa 7.4.2 Release Notes / May 15, 2009</H1>
<p>
Mesa 7.4.2 is a stable development release fixing bugs since the 7.4.1 release.
</p>
<p>
Mesa 7.4.2 implements the OpenGL 2.1 API, but the version reported by
glGetString(GL_VERSION) depends on the particular driver being used.
Some drivers don't support all the features required in OpenGL 2.1.
</p>
<p>
See the <a href="install.html">Compiling/Installing page</a> for prerequisites
for DRI hardware acceleration.
</p>
<h2>MD5 checksums</h2>
<pre>
172f5193154dad731387f97bd44ab68f MesaLib-7.4.2.tar.gz
b10a76e32bde4645cfc34ea0416d7d8b MesaLib-7.4.2.tar.bz2
cc6dfc2efd424cc342b84e6bcd78ce5d MesaLib-7.4.2.zip
182a7e78aa7a480b3650a5c956dbddd1 MesaDemos-7.4.2.tar.gz
bf559a0485667a3bfa4513a23501579b MesaDemos-7.4.2.tar.bz2
5379e622b65e8c22022dba34aeb6f4f9 MesaDemos-7.4.2.zip
7cc43c1c35bf6a279a16e063dea3b8c5 MesaGLUT-7.4.2.tar.gz
e0dfc44d537904a030861e5b3c760c11 MesaGLUT-7.4.2.tar.bz2
4a6cf5bbbac190d6ba97448b3098b7f4 MesaGLUT-7.4.2.zip
</pre>
<h2>Bug fixes</h2>
<ul>
<li>Fixed segfault when rendering to front buffer with DRI 1.
<li>Fixed swrast texture rectangle bug when wrap mode = GL_CLAMP_TO_BORDER and
filter mode = GL_LINEAR. (bug 21461)
<li>Fixed texture object mem leak during context destruction.
<li>Fixed a state validation bug in glCopyTex[Sub]Image()
<li>Fixed some i965 GLSL bugs.
<li>Fixed an R300 driver texture object bad memory reference.
</ul>
<h2>Driver Status</h2>
<pre>
Driver Status
---------------------- ----------------------
DRI drivers varies with the driver
XMesa/GLX (on Xlib) implements OpenGL 2.1
OSMesa (off-screen) implements OpenGL 2.1
Windows/Win32 implements OpenGL 2.1
Glide (3dfx Voodoo1/2) implements OpenGL 1.3
SVGA unsupported
Wind River UGL unsupported
DJGPP unsupported
GGI unsupported
BeOS unsupported
Allegro unsupported
D3D unsupported
</pre>
</body>
</html>

79
docs/relnotes-7.4.3.html Normal file
View File

@@ -0,0 +1,79 @@
<HTML>
<TITLE>Mesa Release Notes</TITLE>
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
<BODY>
<body bgcolor="#eeeeee">
<H1>Mesa 7.4.3 Release Notes / 19 June 2009</H1>
<p>
Mesa 7.4.3 is a stable development release fixing bugs since the 7.4.2 release.
</p>
<p>
Mesa 7.4.3 implements the OpenGL 2.1 API, but the version reported by
glGetString(GL_VERSION) depends on the particular driver being used.
Some drivers don't support all the features required in OpenGL 2.1.
</p>
<p>
See the <a href="install.html">Compiling/Installing page</a> for prerequisites
for DRI hardware acceleration.
</p>
<h2>MD5 checksums</h2>
<pre>
34c5a6c47ed51f31c4fa36e269831352 MesaLib-7.4.3.tar.gz
70a983ba3deaa8bd63b18bbab283f698 MesaLib-7.4.3.tar.bz2
34f21b3205b271d575030aa98a2dda51 MesaLib-7.4.3.zip
56752b7adede212e6097afb10d0c0d59 MesaDemos-7.4.3.tar.gz
8ffa51c4833b1e298300a005e2d7ca2a MesaDemos-7.4.3.tar.bz2
0037d24d41400d6fb9800ae55b8c863f MesaDemos-7.4.3.zip
20e24f6692c0c90e7e3b220f79c4108d MesaGLUT-7.4.3.tar.gz
03a4beeef74fc5ef0b1d6d04710e5a8a MesaGLUT-7.4.3.tar.bz2
273788230adbdb9d57371309adedcf5f MesaGLUT-7.4.3.zip
</pre>
<h2>Bug fixes</h2>
<ul>
<li>Fixed texture object reference counting bug (bug 21756)
<li>Allow depth/stencil textures to be attached to GL_STENCIL_ATTACHMENT point
(SF bug 2793846)
<li>Added missing glGet case for GL_VERTEX_ARRAY_BINDING_APPLE
<li>Fixed some OSMesa build issues
<li>Fixed a vertex buffer object crash
<li>Fixed broken glTexImage3D() when image type = GL_BITMAP
<li>Fixed some GLSL preprocessor bugs
<li>Fixed framebuffer mem leak in i945/i965 DRI drivers
<li>Fixed texture coordinate repeat bug in swrast (bug 21872)
<li>Fixed incorrect viewport clamping (lower bound is zero, not one)
<li>GLX fix for glean's makeCurrent test case
</ul>
<h2>Driver Status</h2>
<pre>
Driver Status
---------------------- ----------------------
DRI drivers varies with the driver
XMesa/GLX (on Xlib) implements OpenGL 2.1
OSMesa (off-screen) implements OpenGL 2.1
Windows/Win32 implements OpenGL 2.1
Glide (3dfx Voodoo1/2) implements OpenGL 1.3
SVGA unsupported
Wind River UGL unsupported
DJGPP unsupported
GGI unsupported
BeOS unsupported
Allegro unsupported
D3D unsupported
</pre>
</body>
</html>

68
docs/relnotes-7.4.4.html Normal file
View File

@@ -0,0 +1,68 @@
<HTML>
<TITLE>Mesa Release Notes</TITLE>
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
<BODY>
<body bgcolor="#eeeeee">
<H1>Mesa 7.4.4 Release Notes / 23 June 2009</H1>
<p>
Mesa 7.4.4 is a stable development release fixing bugs since the 7.4.3 release.
</p>
<p>
Mesa 7.4.4 implements the OpenGL 2.1 API, but the version reported by
glGetString(GL_VERSION) depends on the particular driver being used.
Some drivers don't support all the features required in OpenGL 2.1.
</p>
<p>
See the <a href="install.html">Compiling/Installing page</a> for prerequisites
for DRI hardware acceleration.
</p>
<h2>MD5 checksums</h2>
<pre>
0b56fe5a88ab0c3c5b2da5068f63f416 MesaLib-7.4.4.tar.gz
b66528d314c574dccbe0ed963cac5e93 MesaLib-7.4.4.tar.bz2
2818076f3ba23fa87fdfe4602a637a18 MesaLib-7.4.4.zip
3e77b208386c47b18165bce5ae317e2c MesaDemos-7.4.4.tar.gz
628142ec9a54cd28cc027e6ce26cff47 MesaDemos-7.4.4.tar.bz2
d08a30d30ab7174859aa709cba6c726d MesaDemos-7.4.4.zip
e6e91ba16e274d40cf3a97ad3218af01 MesaGLUT-7.4.4.tar.gz
e14bbb52517e8121b31f1387515365ab MesaGLUT-7.4.4.tar.bz2
f10ed20469753c2b3d68c99854f80fd4 MesaGLUT-7.4.4.zip
</pre>
<h2>Bug fixes</h2>
<ul>
<li>Fixed i965/i915 segfault in screen destruction (bug 22408)
</ul>
<h2>Driver Status</h2>
<pre>
Driver Status
---------------------- ----------------------
DRI drivers varies with the driver
XMesa/GLX (on Xlib) implements OpenGL 2.1
OSMesa (off-screen) implements OpenGL 2.1
Windows/Win32 implements OpenGL 2.1
Glide (3dfx Voodoo1/2) implements OpenGL 1.3
SVGA unsupported
Wind River UGL unsupported
DJGPP unsupported
GGI unsupported
BeOS unsupported
Allegro unsupported
D3D unsupported
</pre>
</body>
</html>

View File

@@ -46,7 +46,7 @@ tbd
<h2>New features</h2>
<ul>
<li>Gallium - this is the new architecture for OS-independent and
<li>Gallium3D - this is the new architecture for OS-independent and
API-independent 3D drivers.
Gallium3D is intended for GPUs that fully support vertex/fragment shaders.
The Gallium3D drivers currently included are:
@@ -54,8 +54,10 @@ tbd
<li>softpipe - a software/reference driver
<li>i915 - Intel 915/945 driver
<li><a href="cell.html">Cell</a> - IBM/Sony/Toshiba Cell processor driver
<li>nouveau - preliminary driver for NVIDIA GPUs (still under development)
<li>r300 - preliminary driver for R300 (still under development)
<li>nouveau (for NVIDIA GPUs) and R300 for (AMD/ATI R300).
<b>PLEASE NOTE: these drivers are incomplete and still under development.
It's probably NOT worthwhile to report any bugs unless you have patches.
</b>
</ul>
<li>GL_ARB_framebuffer_object extension (software drivers, i965 driver)
<li>Reworked two-sided stencil support.
@@ -66,12 +68,16 @@ including GL_ATI_separate_stencil, GL_EXT_stencil_two_side and OpenGL 2.0
<li>GL_EXT_texture_swizzle extension (software drivers, i965 driver)
<li>Updated SPARC assembly optimizations (David S. Miller)
<li>Initial support for separate compilation units in GLSL compiler.
<li>Increased max number of generic GLSL varying variables to 16 (formerly 8).
<li>GLSL linker now detects when too many varying variables are used.
</ul>
<h2>Bug fixes</h2>
<ul>
<li>Lots of i965 driver bug fixes
<li>Fixed some GLSL preprocessor bugs
<li>GLSL: continue inside of a for-loop didn't work
</ul>

View File

@@ -8,19 +8,15 @@
<H1>Release Notes</H1>
<p>
Mesa uses an even/odd version number scheme like the Linux kernel.
Odd numbered versions (such as 7.5) designate new developmental releases.
Even numbered versions (such as 7.4) designate stable releases.
</p>
<p>
The release notes summarize what's new or changed in each Mesa release.
</p>
<UL>
<LI><A HREF="relnotes-7.5.html">7.5 release notes</A>
<LI><A HREF="relnotes-7.4.4.html">7.4.4 release notes</A>
<LI><A HREF="relnotes-7.4.3.html">7.4.3 release notes</A>
<LI><A HREF="relnotes-7.4.2.html">7.4.2 release notes</A>
<LI><A HREF="relnotes-7.4.1.html">7.4.1 release notes</A>
<LI><A HREF="relnotes-7.4.html">7.4 release notes</A>
<LI><A HREF="relnotes-7.3.html">7.3 release notes</A>

View File

@@ -2702,7 +2702,7 @@ typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target);
typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint* framebuffers);
typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint* renderbuffers);
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURLAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer);
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer);
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer);
@@ -2723,7 +2723,7 @@ typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum targ
#define glDeleteFramebuffers GLEW_GET_FUN(__glewDeleteFramebuffers)
#define glDeleteRenderbuffers GLEW_GET_FUN(__glewDeleteRenderbuffers)
#define glFramebufferRenderbuffer GLEW_GET_FUN(__glewFramebufferRenderbuffer)
#define glFramebufferTexturLayer GLEW_GET_FUN(__glewFramebufferTexturLayer)
#define glFramebufferTextureLayer GLEW_GET_FUN(__glewFramebufferTextureLayer)
#define glFramebufferTexture1D GLEW_GET_FUN(__glewFramebufferTexture1D)
#define glFramebufferTexture2D GLEW_GET_FUN(__glewFramebufferTexture2D)
#define glFramebufferTexture3D GLEW_GET_FUN(__glewFramebufferTexture3D)
@@ -10563,7 +10563,7 @@ GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus;
GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers;
GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers;
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer;
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURLAYERPROC __glewFramebufferTexturLayer;
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer;
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D;
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D;
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D;

View File

@@ -145,6 +145,13 @@ engine.o: engine.c trackball.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) engine.c
fbotexture: fbotexture.o
$(APP_CC) $(CFLAGS) $(LDFLAGS) fbotexture.o $(LIBS) -o $@
fbotexture.o: fbotexture.c extfuncs.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) fbotexture.c
fslight: fslight.o
$(APP_CC) $(CFLAGS) $(LDFLAGS) fslight.o $(LIBS) -o $@

View File

@@ -9,13 +9,13 @@
*/
#include <GL/glew.h>
#include <GL/glut.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "extfuncs.h"
/* For debug */
#define DEPTH 1
@@ -80,9 +80,9 @@ RenderTexture(void)
glTranslatef(0.0, 0.0, -15.0);
/* draw to texture image */
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, MyFB);
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
status = glCheckFramebufferStatus_func(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
printf("Framebuffer incomplete!!!\n");
}
@@ -171,7 +171,7 @@ RenderTexture(void)
#if DRAW
/* Bind normal framebuffer */
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, 0);
#endif
CheckError(__LINE__);
@@ -252,12 +252,12 @@ static void
CleanUp(void)
{
#if DEPTH
glDeleteRenderbuffersEXT(1, &DepthRB);
glDeleteRenderbuffers_func(1, &DepthRB);
#endif
#if STENCIL
glDeleteRenderbuffersEXT(1, &StencilRB);
glDeleteRenderbuffers_func(1, &StencilRB);
#endif
glDeleteFramebuffersEXT(1, &MyFB);
glDeleteFramebuffers_func(1, &MyFB);
glDeleteTextures(1, &TexObj);
@@ -318,14 +318,14 @@ AttachDepthAndStencilBuffers(GLuint fbo,
*depthRbOut = *stencilRbOut = 0;
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, fbo);
if (tryDepthStencil) {
GLuint rb;
glGenRenderbuffersEXT(1, &rb);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
glGenRenderbuffers_func(1, &rb);
glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, rb);
glRenderbufferStorage_func(GL_RENDERBUFFER_EXT,
GL_DEPTH24_STENCIL8_EXT,
width, height);
if (glGetError())
@@ -333,7 +333,7 @@ AttachDepthAndStencilBuffers(GLuint fbo,
if (bindDepthStencil) {
/* attach to both depth and stencil at once */
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
GL_DEPTH_STENCIL_ATTACHMENT,
GL_RENDERBUFFER_EXT, rb);
if (glGetError())
@@ -341,21 +341,21 @@ AttachDepthAndStencilBuffers(GLuint fbo,
}
else {
/* attach to depth attachment point */
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
GL_DEPTH_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, rb);
if (glGetError())
return GL_FALSE;
/* and attach to stencil attachment point */
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
GL_STENCIL_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, rb);
if (glGetError())
return GL_FALSE;
}
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
status = glCheckFramebufferStatus_func(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
return GL_FALSE;
@@ -367,22 +367,22 @@ AttachDepthAndStencilBuffers(GLuint fbo,
{
GLuint rb;
glGenRenderbuffersEXT(1, &rb);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
glGenRenderbuffers_func(1, &rb);
glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, rb);
glRenderbufferStorage_func(GL_RENDERBUFFER_EXT,
GL_DEPTH_COMPONENT,
width, height);
if (glGetError())
return GL_FALSE;
/* attach to depth attachment point */
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
GL_DEPTH_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, rb);
if (glGetError())
return GL_FALSE;
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
status = glCheckFramebufferStatus_func(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
return GL_FALSE;
@@ -393,26 +393,26 @@ AttachDepthAndStencilBuffers(GLuint fbo,
{
GLuint rb;
glGenRenderbuffersEXT(1, &rb);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
glGenRenderbuffers_func(1, &rb);
glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, rb);
glRenderbufferStorage_func(GL_RENDERBUFFER_EXT,
GL_STENCIL_INDEX,
width, height);
if (glGetError())
return GL_FALSE;
/* attach to depth attachment point */
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
GL_STENCIL_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, rb);
if (glGetError())
return GL_FALSE;
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
status = glCheckFramebufferStatus_func(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
glDeleteRenderbuffersEXT(1, depthRbOut);
glDeleteRenderbuffers_func(1, depthRbOut);
*depthRbOut = 0;
glDeleteRenderbuffersEXT(1, &rb);
glDeleteRenderbuffers_func(1, &rb);
return GL_FALSE;
}
@@ -463,6 +463,37 @@ ParseArgs(int argc, char *argv[])
}
static void
SetupFunctionPointers(void)
{
GetExtensionFuncs();
if (Use_ARB_fbo) {
/* no-op: use the ARB functions as-is */
}
else {
/* set the ARB-flavor function pointers to point to the EXT functions */
glIsRenderbuffer_func = glIsRenderbufferEXT_func;
glBindRenderbuffer_func = glBindRenderbufferEXT_func;
glDeleteRenderbuffers_func = glDeleteRenderbuffersEXT_func;
glGenRenderbuffers_func = glGenRenderbuffersEXT_func;
glRenderbufferStorage_func = glRenderbufferStorageEXT_func;
glGetRenderbufferParameteriv_func = glGetRenderbufferParameterivEXT_func;
glIsFramebuffer_func = glIsFramebufferEXT_func;
glBindFramebuffer_func = glBindFramebufferEXT_func;
glDeleteFramebuffers_func = glDeleteFramebuffersEXT_func;
glGenFramebuffers_func = glGenFramebuffersEXT_func;
glCheckFramebufferStatus_func = glCheckFramebufferStatusEXT_func;
glFramebufferTexture1D_func = glFramebufferTexture1DEXT_func;
glFramebufferTexture2D_func = glFramebufferTexture2DEXT_func;
glFramebufferTexture3D_func = glFramebufferTexture3DEXT_func;
glFramebufferRenderbuffer_func = glFramebufferRenderbufferEXT_func;
glGetFramebufferAttachmentParameteriv_func = glGetFramebufferAttachmentParameterivEXT_func;
glGenerateMipmap_func = glGenerateMipmapEXT_func;
}
}
/*
* Make FBO to render into given texture.
*/
@@ -472,10 +503,10 @@ MakeFBO_RenderTexture(GLuint TexObj)
GLuint fb;
GLint sizeFudge = 0;
glGenFramebuffersEXT(1, &fb);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
glGenFramebuffers_func(1, &fb);
glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, fb);
/* Render color to texture */
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
glFramebufferTexture2D_func(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
TexTarget, TexObj, TextureLevel);
if (Use_ARB_fbo) {
@@ -512,26 +543,26 @@ MakeFBO_RenderTexture(GLuint TexObj)
{
GLint bits, w, h;
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRB);
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, DepthRB);
glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT,
GL_RENDERBUFFER_WIDTH_EXT, &w);
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT,
GL_RENDERBUFFER_HEIGHT_EXT, &h);
printf("Color/Texture size: %d x %d\n", TexWidth, TexHeight);
printf("Depth buffer size: %d x %d\n", w, h);
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT,
GL_RENDERBUFFER_DEPTH_SIZE_EXT, &bits);
printf("Depth renderbuffer size = %d bits\n", bits);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, StencilRB);
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, StencilRB);
glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT,
GL_RENDERBUFFER_STENCIL_SIZE_EXT, &bits);
printf("Stencil renderbuffer size = %d bits\n", bits);
}
/* bind the regular framebuffer */
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, 0);
return fb;
}
@@ -547,6 +578,8 @@ Init(void)
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
SetupFunctionPointers();
/* lighting */
{
static const GLfloat mat[4] = { 1.0, 0.5, 0.5, 1.0 };
@@ -605,7 +638,6 @@ main(int argc, char *argv[])
glutInitWindowSize(Width, Height);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
Win = glutCreateWindow(argv[0]);
glewInit();
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutDisplayFunc(Display);

View File

@@ -583,10 +583,14 @@ ParseOptions(int argc, char *argv[])
int i;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-fs") == 0) {
FragProgFile = argv[i+1];
FragProgFile = argv[++i];
}
else if (strcmp(argv[i], "-vs") == 0) {
VertProgFile = argv[i+1];
VertProgFile = argv[++i];
}
else {
fprintf(stderr, "unknown option %s\n", argv[i]);
break;
}
}
}

View File

@@ -11,7 +11,20 @@ env.Prepend(CPPPATH = [
env.Prepend(LIBS = ['$GLUT_LIB'])
env.Program(
target = 'fp-tri',
source = ['fp-tri.c'],
progs = [
'fp-tri',
'tri-depth',
'tri-depth2',
'tri-depthwrite',
'tri-depthwrite2',
'tri-inv',
'tri-param',
'tri-tex',
'point-position',
]
for prog in progs:
env.Program(
target = prog,
source = [prog + '.c'],
)

View File

@@ -89,7 +89,7 @@ static void Init( void )
}
fprintf(stderr, "%.*s\n", sz, buf);
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
if (!GLEW_ARB_fragment_program) {
printf("Error: GL_ARB_fragment_program not supported!\n");
exit(1);
}

View File

@@ -2,9 +2,8 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define GL_GLEXT_PROTOTYPES
#include <GL/glew.h>
#include <GL/glut.h>
#include "GL/gl.h"
@@ -17,7 +16,7 @@ static void Init( void )
;
GLuint modulateProg;
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
if (!GLEW_ARB_fragment_program) {
printf("Error: GL_ARB_fragment_program not supported!\n");
exit(1);
}
@@ -109,6 +108,8 @@ int main(int argc, char **argv)
exit(1);
}
glewInit();
Init();
glutReshapeFunc(Reshape);

View File

@@ -2,9 +2,8 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define GL_GLEXT_PROTOTYPES
#include <GL/glew.h>
#include <GL/glut.h>
#include "GL/gl.h"
@@ -19,7 +18,7 @@ static void Init( void )
;
GLuint modulateProg;
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
if (!GLEW_ARB_fragment_program) {
printf("Error: GL_ARB_fragment_program not supported!\n");
exit(1);
}
@@ -89,8 +88,6 @@ int main(int argc, char **argv)
glutInit(&argc, argv);
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
type = GLUT_RGB;
@@ -101,6 +98,8 @@ int main(int argc, char **argv)
exit(1);
}
glewInit();
Init();
glutReshapeFunc(Reshape);

View File

@@ -2,9 +2,8 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define GL_GLEXT_PROTOTYPES
#include <GL/glew.h>
#include <GL/glut.h>
#include "GL/gl.h"
@@ -21,7 +20,7 @@ static void Init( void )
;
GLuint modulateProg;
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
if (!GLEW_ARB_fragment_program) {
printf("Error: GL_ARB_fragment_program not supported!\n");
exit(1);
}
@@ -106,6 +105,8 @@ int main(int argc, char **argv)
exit(1);
}
glewInit();
Init();
glutReshapeFunc(Reshape);

View File

@@ -2,7 +2,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define GL_GLEXT_PROTOTYPES
#include <GL/glew.h>
#include <GL/glut.h>
@@ -16,7 +16,7 @@ static void Init(void)
;
GLuint modulateProg;
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
if (!GLEW_ARB_fragment_program) {
printf("Error: GL_ARB_fragment_program not supported!\n");
exit(1);
}
@@ -97,6 +97,8 @@ int main(int argc, char **argv)
exit(1);
}
glewInit();
Init();
glutReshapeFunc(Reshape);

View File

@@ -2,7 +2,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define GL_GLEXT_PROTOTYPES
#include <GL/glew.h>
#include <GL/glut.h>
@@ -16,7 +16,7 @@ static void Init(void)
;
GLuint modulateProg;
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
if (!GLEW_ARB_fragment_program) {
printf("Error: GL_ARB_fragment_program not supported!\n");
exit(1);
}
@@ -97,6 +97,8 @@ int main(int argc, char **argv)
exit(1);
}
glewInit();
Init();
glutReshapeFunc(Reshape);

View File

@@ -2,7 +2,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define GL_GLEXT_PROTOTYPES
#include <GL/glew.h>
#include <GL/glut.h>
@@ -17,7 +17,7 @@ static void Init( void )
;
GLuint modulateProg;
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
if (!GLEW_ARB_fragment_program) {
printf("Error: GL_ARB_fragment_program not supported!\n");
exit(1);
}
@@ -99,6 +99,8 @@ int main(int argc, char **argv)
exit(1);
}
glewInit();
Init();
glutReshapeFunc(Reshape);

View File

@@ -2,9 +2,9 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define GL_GLEXT_PROTOTYPES
#include <GL/glew.h>
#include <GL/glut.h>
#include "GL/gl.h"
static void Init( void )
{
@@ -15,7 +15,7 @@ static void Init( void )
;
GLuint modulateProg;
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
if (!GLEW_ARB_fragment_program) {
printf("Error: GL_ARB_fragment_program not supported!\n");
exit(1);
}
@@ -104,6 +104,8 @@ int main(int argc, char **argv)
exit(1);
}
glewInit();
Init();
glutReshapeFunc(Reshape);

View File

@@ -3,7 +3,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define GL_GLEXT_PROTOTYPES
#include <GL/glew.h>
#include <GL/glut.h>
#include "readtex.c"
@@ -23,7 +23,7 @@ static void Init( void )
GLuint modulateProg;
GLuint Texture;
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
if (!GLEW_ARB_fragment_program) {
printf("Error: GL_ARB_fragment_program not supported!\n");
exit(1);
}
@@ -120,6 +120,8 @@ int main(int argc, char **argv)
exit(1);
}
glewInit();
Init();
glutReshapeFunc(Reshape);

View File

@@ -80,25 +80,26 @@ clean:
-rm -f *.o *~
-rm -f extfuncs.h
-rm -f shaderutil.*
-rm -f readtex.*
##### Extra dependencies
extfuncs.h:
cp $(TOP)/progs/util/extfuncs.h .
extfuncs.h: $(TOP)/progs/util/extfuncs.h
cp $< .
readtex.c:
cp $(TOP)/progs/util/readtex.c .
readtex.c: $(TOP)/progs/util/readtex.c
cp $< .
readtex.h:
cp $(TOP)/progs/util/readtex.h .
readtex.h: $(TOP)/progs/util/readtex.h
cp $< .
shaderutil.c:
cp $(TOP)/progs/util/shaderutil.c .
shaderutil.c: $(TOP)/progs/util/shaderutil.c
cp $< .
shaderutil.h:
cp $(TOP)/progs/util/shaderutil.h .
shaderutil.h: $(TOP)/progs/util/shaderutil.h
cp $< .

View File

@@ -271,9 +271,24 @@ CreateProgram(const char *vertProgFile, const char *fragProgFile,
InitUniforms(program, uniforms);
VertCoord_attr = glGetAttribLocation_func(program, "VertCoord");
if (VertCoord_attr > 0) {
/* We want the VertCoord attrib to have position zero so that
* the call to glVertexAttrib(0, xyz) triggers vertex processing.
* Otherwise, if TexCoord0 or TexCoord1 gets position 0 we'd have
* to set that attribute last (which is a PITA to manage).
*/
glBindAttribLocation_func(program, 0, "VertCoord");
/* re-link */
glLinkProgram_func(program);
/* VertCoord_attr should be zero now */
VertCoord_attr = glGetAttribLocation_func(program, "VertCoord");
assert(VertCoord_attr == 0);
}
TexCoord0_attr = glGetAttribLocation_func(program, "TexCoord0");
TexCoord1_attr = glGetAttribLocation_func(program, "TexCoord1");
VertCoord_attr = glGetAttribLocation_func(program, "VertCoord");
printf("TexCoord0_attr = %d\n", TexCoord0_attr);
printf("TexCoord1_attr = %d\n", TexCoord1_attr);
printf("VertCoord_attr = %d\n", VertCoord_attr);

View File

@@ -62,6 +62,8 @@ readrate
readtex.c
readtex.h
rubberband
scissor
scissor-viewport
seccolor
shader_api
shaderutil.c

View File

@@ -70,6 +70,8 @@ SOURCES = \
random.c \
readrate.c \
rubberband.c \
scissor.c \
scissor-viewport.c \
seccolor.c \
shader_api.c \
sharedtex.c \

View File

@@ -95,6 +95,8 @@ progs = [
'random',
'readrate',
'rubberband',
'scissor',
'scissor-viewport',
'seccolor',
'shader_api',
'stencil_twoside',

View File

@@ -0,0 +1,138 @@
/*
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
* Copyright (c) 2009 VMware, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that (i) the above copyright notices and this permission notice appear in
* all copies of the software and related documentation, and (ii) the name of
* Silicon Graphics may not be used in any advertising or
* publicity relating to the software without the specific, prior written
* permission of Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
* ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <GL/glut.h>
struct program
{
unsigned width;
unsigned height;
int i;
};
struct program prog;
static void init(void)
{
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
fflush(stderr);
prog.i = 0;
}
static void reshape(int width, int height)
{
glViewport(0, 0, 100, 100);
prog.width = width;
prog.height = height;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
glMatrixMode(GL_MODELVIEW);
}
static void key(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(1);
default:
glutPostRedisplay();
return;
}
}
static void drawQuad(void)
{
glBegin(GL_QUADS);
glVertex2d(-1.0, -1.0);
glVertex2d( 1.0, -1.0);
glVertex2d( 1.0, 1.0);
glVertex2d(-1.0, 1.0);
glEnd();
}
static void draw(void)
{
int i;
glClearColor(0.0, 0.0, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
i = prog.i++;
if (prog.i >= 3)
prog.i = 0;
glEnable(GL_SCISSOR_TEST);
{
glColor4d(1.0, 0.0, 0.0, 1.0);
glScissor(i, i, 10 - 2*i, 10 - 2*i);
drawQuad();
}
glDisable(GL_SCISSOR_TEST);
//glutSwapBuffers();
glFlush();
}
int main(int argc, char **argv)
{
GLenum type;
glutInit(&argc, argv);
prog.width = 200;
prog.height = 200;
glutInitWindowPosition(100, 0);
glutInitWindowSize(prog.width, prog.height);
//type = GLUT_RGB | GLUT_DOUBLE;
type = GLUT_RGB | GLUT_SINGLE;
glutInitDisplayMode(type);
if (glutCreateWindow(*argv) == GL_FALSE) {
exit(1);
}
init();
glutReshapeFunc(reshape);
glutKeyboardFunc(key);
glutDisplayFunc(draw);
glutMainLoop();
return 0;
}

168
progs/tests/scissor.c Normal file
View File

@@ -0,0 +1,168 @@
/*
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
* Copyright (c) 2009 VMware, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that (i) the above copyright notices and this permission notice appear in
* all copies of the software and related documentation, and (ii) the name of
* Silicon Graphics may not be used in any advertising or
* publicity relating to the software without the specific, prior written
* permission of Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
* ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <GL/glut.h>
struct program
{
unsigned width;
unsigned height;
unsigned quads;
};
struct program prog;
static void init(void)
{
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
fflush(stderr);
}
static void reshape(int width, int height)
{
glViewport(0, 0, (GLint)width, (GLint)height);
prog.width = width;
prog.height = height;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
glMatrixMode(GL_MODELVIEW);
}
static void key(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(1);
default:
prog.quads = !prog.quads;
glutPostRedisplay();
return;
}
}
static void drawQuad(void)
{
if (prog.quads) {
glBegin(GL_QUADS);
glVertex2d(-1.0, -1.0);
glVertex2d( 1.0, -1.0);
glVertex2d( 1.0, 1.0);
glVertex2d(-1.0, 1.0);
glEnd();
} else {
glClear(GL_COLOR_BUFFER_BIT);
}
}
static void draw(void)
{
glClearColor(0.0, 0.0, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
printf("drawing with %s\n", prog.quads ? "quads" : "clears");
glEnable(GL_SCISSOR_TEST);
{
glClearColor(1.0, 0.0, 0.0, 1.0);
glColor4d(1.0, 0.0, 0.0, 1.0);
glScissor(1, 1, 10, 10);
drawQuad();
glScissor(1, prog.height - 11, 10, 10);
drawQuad();
glScissor(prog.width - 11, prog.height - 11, 10, 10);
drawQuad();
}
{
glClearColor(0.0, 1.0, 0.0, 1.0);
glColor4d(0.0, 1.0, 0.0, 1.0);
glScissor(12, 1, 10, 10);
drawQuad();
glScissor(12, prog.height - 11, 10, 10);
drawQuad();
glScissor(prog.width - 22, prog.height - 11, 10, 10);
drawQuad();
}
{
glClearColor(1.0, 1.0, 0.0, 1.0);
glColor4d(1.0, 1.0, 0.0, 1.0);
glScissor(1, 12, 10, 10);
drawQuad();
glScissor(1, prog.height - 22, 10, 10);
drawQuad();
glScissor(prog.width - 11, prog.height - 22, 10, 10);
drawQuad();
}
glDisable(GL_SCISSOR_TEST);
//glutSwapBuffers();
glFlush();
}
int main(int argc, char **argv)
{
GLenum type;
glutInit(&argc, argv);
prog.width = 200;
prog.height = 200;
glutInitWindowPosition(100, 0);
glutInitWindowSize(prog.width, prog.height);
//type = GLUT_RGB | GLUT_DOUBLE;
type = GLUT_RGB | GLUT_SINGLE;
glutInitDisplayMode(type);
if (glutCreateWindow(*argv) == GL_FALSE) {
exit(1);
}
init();
glutReshapeFunc(reshape);
glutKeyboardFunc(key);
glutDisplayFunc(draw);
glutMainLoop();
return 0;
}

View File

@@ -21,7 +21,7 @@ static void Display(void)
GLfloat min, max;
int i;
glClearColor(0.5, 0.5, 0.5, 0);
glClearColor(0.5, 0.5, 0.5, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* draw a sphere */
@@ -82,7 +82,7 @@ static void Key(unsigned char key, int x, int y)
static void Init(void)
{
const GLfloat blue[4] = {.1, .1, 1.0, 0.0};
const GLfloat blue[4] = {.1, .1, 1.0, 1.0};
const GLfloat gray[4] = {0.2, 0.2, 0.2, 1.0};
const GLfloat white[4] = {1.0, 1.0, 1.0, 1.0};
const GLfloat pos[4] = {0, 0, 10, 0};

View File

@@ -57,13 +57,19 @@ static struct { GLenum func; const char *str; } funcs[] =
static int curFunc = 0;
static double clearVal = 1.0;
static float minZ = 0.0;
static float maxZ = 1.0;
static void usage(void)
{
printf("t - toggle rendering order of triangles\n");
printf("c - toggle Z clear value between 0, 1\n");
printf("f - cycle through depth test functions\n");
printf("t - toggle rendering order of triangles\n");
printf("c - toggle Z clear value between 0, 1\n");
printf("f - cycle through depth test functions\n");
printf("n/N - decrease/increase depthrange minZ\n");
printf("x/X - decrease/increase depthrange maxZ\n");
printf("spc - reset\n");
printf("z - set to reverse-direction (ztrick) mode\n");
fflush(stdout);
}
@@ -97,9 +103,11 @@ static void drawRightTriangle(void)
void display(void)
{
printf("GL_CLEAR_DEPTH = %f GL_DEPTH_FUNC = %s\n",
clearVal, funcs[curFunc].str);
printf("GL_CLEAR_DEPTH = %.2f, GL_DEPTH_FUNC = %s, DepthRange(%.1f, %.1f)\n",
clearVal, funcs[curFunc].str, minZ, maxZ);
fflush(stdout);
glClearDepth(clearVal);
glDepthRange(minZ, maxZ);
glDepthFunc(funcs[curFunc].func);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -131,27 +139,49 @@ void reshape(int w, int h)
void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 'n':
minZ -= .1;
break;
case 'N':
minZ += .1;
break;
case 'x':
maxZ -= .1;
break;
case 'X':
maxZ += .1;
break;
case 'c':
case 'C':
clearVal = 1.0 - clearVal;
glutPostRedisplay();
break;
case 'f':
case 'F':
curFunc = (curFunc + 1) % NUM_FUNCS;
glutPostRedisplay();
break;
case 't':
case 'T':
leftFirst = !leftFirst;
glutPostRedisplay();
break;
case ' ':
curFunc = 0;
clearVal = 1.0;
minZ = 0.0;
maxZ = 1.0;
break;
case 'z':
curFunc = 2;
clearVal = 0.0;
minZ = 1.0;
maxZ = 0.0;
break;
case 27: /* Escape key */
exit(0);
break;
default:
break;
return;
}
glutPostRedisplay();
}
/* Main Loop

View File

@@ -60,6 +60,7 @@ static void Key(unsigned char key, int x, int y)
{
switch (key) {
case 27:
glutDestroyWindow(win);
exit(0);
default:
glutPostRedisplay();

View File

@@ -86,6 +86,57 @@ static PFNGLISVERTEXARRAYAPPLEPROC glIsVertexArrayAPPLE_func = NULL;
/* GL_EXT_stencil_two_side */
static PFNGLACTIVESTENCILFACEEXTPROC glActiveStencilFaceEXT_func = NULL;
/* GL_ARB_buffer_object */
static PFNGLGENBUFFERSARBPROC glGenBuffersARB_func = NULL;
static PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB_func = NULL;
static PFNGLBINDBUFFERARBPROC glBindBufferARB_func = NULL;
static PFNGLBUFFERDATAARBPROC glBufferDataARB_func = NULL;
static PFNGLBUFFERSUBDATAARBPROC glBufferSubDataARB_func = NULL;
static PFNGLMAPBUFFERARBPROC glMapBufferARB_func = NULL;
static PFNGLUNMAPBUFFERARBPROC glUnmapBufferARB_func = NULL;
/* GL_EXT_framebuffer_object */
static PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT_func = NULL;
static PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT_func = NULL;
static PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT_func = NULL;
static PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT_func = NULL;
static PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT_func = NULL;
static PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glGetRenderbufferParameterivEXT_func = NULL;
static PFNGLISFRAMEBUFFEREXTPROC glIsFramebufferEXT_func = NULL;
static PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT_func = NULL;
static PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT_func = NULL;
static PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT_func = NULL;
static PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT_func = NULL;
static PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glFramebufferTexture1DEXT_func = NULL;
static PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT_func = NULL;
static PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT_func = NULL;
static PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT_func = NULL;
static PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT_func = NULL;
static PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT_func = NULL;
/* GL_ARB_framebuffer_object */
static PFNGLISRENDERBUFFERPROC glIsRenderbuffer_func = NULL;
static PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer_func = NULL;
static PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers_func = NULL;
static PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers_func = NULL;
static PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage_func = NULL;
static PFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv_func = NULL;
static PFNGLISFRAMEBUFFERPROC glIsFramebuffer_func = NULL;
static PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer_func = NULL;
static PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers_func = NULL;
static PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers_func = NULL;
static PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus_func = NULL;
static PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D_func = NULL;
static PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D_func = NULL;
static PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D_func = NULL;
static PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer_func = NULL;
static PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv_func = NULL;
static PFNGLGENERATEMIPMAPPROC glGenerateMipmap_func = NULL;
static PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer_func = NULL;
static PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample_func = NULL;
static PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer_func = NULL;
static void
GetExtensionFuncs(void)
@@ -173,5 +224,55 @@ GetExtensionFuncs(void)
/* GL_EXT_stencil_two_side */
glActiveStencilFaceEXT_func = (PFNGLACTIVESTENCILFACEEXTPROC) glutGetProcAddress("glActiveStencilFaceEXT");
/* GL_ARB_vertex_buffer_object */
glGenBuffersARB_func = (PFNGLGENBUFFERSARBPROC) glutGetProcAddress("glGenBuffersARB");
glDeleteBuffersARB_func = (PFNGLDELETEBUFFERSARBPROC) glutGetProcAddress("glDeleteBuffersARB");
glBindBufferARB_func = (PFNGLBINDBUFFERARBPROC) glutGetProcAddress("glBindBufferARB");
glBufferDataARB_func = (PFNGLBUFFERDATAARBPROC) glutGetProcAddress("glBufferDataARB");
glBufferSubDataARB_func = (PFNGLBUFFERSUBDATAARBPROC) glutGetProcAddress("glBufferSubDataARB");
glMapBufferARB_func = (PFNGLMAPBUFFERARBPROC) glutGetProcAddress("glMapBufferARB");
glUnmapBufferARB_func = (PFNGLUNMAPBUFFERARBPROC) glutGetProcAddress("glUnmapBufferARB");
/* GL_EXT_framebuffer_object */
glIsRenderbufferEXT_func = (PFNGLISRENDERBUFFEREXTPROC) glutGetProcAddress("glIsRenderbufferEXT");
glBindRenderbufferEXT_func = (PFNGLBINDRENDERBUFFEREXTPROC) glutGetProcAddress("glBindRenderbufferEXT");
glDeleteRenderbuffersEXT_func = (PFNGLDELETERENDERBUFFERSEXTPROC) glutGetProcAddress("glDeleteRenderbuffersEXT");
glGenRenderbuffersEXT_func = (PFNGLGENRENDERBUFFERSEXTPROC) glutGetProcAddress("glGenRenderbuffersEXT");
glRenderbufferStorageEXT_func = (PFNGLRENDERBUFFERSTORAGEEXTPROC) glutGetProcAddress("glRenderbufferStorageEXT");
glGetRenderbufferParameterivEXT_func = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) glutGetProcAddress("glGetRenderbufferParameterivEXT");
glIsFramebufferEXT_func = (PFNGLISFRAMEBUFFEREXTPROC) glutGetProcAddress("glIsFramebufferEXT");
glBindFramebufferEXT_func = (PFNGLBINDFRAMEBUFFEREXTPROC) glutGetProcAddress("glBindFramebufferEXT");
glDeleteFramebuffersEXT_func = (PFNGLDELETEFRAMEBUFFERSEXTPROC) glutGetProcAddress("glDeleteFramebuffersEXT");
glGenFramebuffersEXT_func = (PFNGLGENFRAMEBUFFERSEXTPROC) glutGetProcAddress("glGenFramebuffersEXT");
glCheckFramebufferStatusEXT_func = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) glutGetProcAddress("glCheckFramebufferStatusEXT");
glFramebufferTexture1DEXT_func = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) glutGetProcAddress("glFramebufferTexture1DEXT");
glFramebufferTexture2DEXT_func = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) glutGetProcAddress("glFramebufferTexture2DEXT");
glFramebufferTexture3DEXT_func = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) glutGetProcAddress("glFramebufferTexture3DEXT");
glFramebufferRenderbufferEXT_func = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) glutGetProcAddress("glFramebufferRenderbufferEXT");
glGetFramebufferAttachmentParameterivEXT_func = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) glutGetProcAddress("glGetFramebufferAttachmentParameterivEXT");
glGenerateMipmapEXT_func = (PFNGLGENERATEMIPMAPEXTPROC) glutGetProcAddress("glGenerateMipmapEXT");
/* GL_ARB_framebuffer_object */
glIsRenderbuffer_func = (PFNGLISRENDERBUFFERPROC) glutGetProcAddress("glIsRenderbuffer");
glBindRenderbuffer_func = (PFNGLBINDRENDERBUFFERPROC) glutGetProcAddress("glBindRenderbuffer");
glDeleteRenderbuffers_func = (PFNGLDELETERENDERBUFFERSPROC) glutGetProcAddress("glDeleteRenderbuffers");
glGenRenderbuffers_func = (PFNGLGENRENDERBUFFERSPROC) glutGetProcAddress("glGenRenderbuffers");
glRenderbufferStorage_func = (PFNGLRENDERBUFFERSTORAGEPROC) glutGetProcAddress("glRenderbufferStorage");
glGetRenderbufferParameteriv_func = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) glutGetProcAddress("glGetRenderbufferParameteriv");
glIsFramebuffer_func = (PFNGLISFRAMEBUFFERPROC) glutGetProcAddress("glIsFramebuffer");
glBindFramebuffer_func = (PFNGLBINDFRAMEBUFFERPROC) glutGetProcAddress("glBindFramebuffer");
glDeleteFramebuffers_func = (PFNGLDELETEFRAMEBUFFERSPROC) glutGetProcAddress("glDeleteFramebuffers");
glGenFramebuffers_func = (PFNGLGENFRAMEBUFFERSPROC) glutGetProcAddress("glGenFramebuffers");
glCheckFramebufferStatus_func = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) glutGetProcAddress("glCheckFramebufferStatus");
glFramebufferTexture1D_func = (PFNGLFRAMEBUFFERTEXTURE1DPROC) glutGetProcAddress("glFramebufferTexture1D");
glFramebufferTexture2D_func = (PFNGLFRAMEBUFFERTEXTURE2DPROC) glutGetProcAddress("glFramebufferTexture2D");
glFramebufferTexture3D_func = (PFNGLFRAMEBUFFERTEXTURE3DPROC) glutGetProcAddress("glFramebufferTexture3D");
glFramebufferRenderbuffer_func = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) glutGetProcAddress("glFramebufferRenderbuffer");
glGetFramebufferAttachmentParameteriv_func = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) glutGetProcAddress("glGetFramebufferAttachmentParameteriv");
glGenerateMipmap_func = (PFNGLGENERATEMIPMAPPROC) glutGetProcAddress("glGenerateMipmap");
glBlitFramebuffer_func = (PFNGLBLITFRAMEBUFFERPROC) glutGetProcAddress("glBlitFramebuffer");
glRenderbufferStorageMultisample_func = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) glutGetProcAddress("glRenderbufferStorageMultisample");
glFramebufferTextureLayer_func = (PFNGLFRAMEBUFFERTEXTURELAYERPROC) glutGetProcAddress("glFramebufferTextureLayer");
}

View File

@@ -0,0 +1,6 @@
void main() {
gl_FrontColor = gl_Color;
gl_PointSize = 2.0;
gl_Position = gl_Vertex;
}

View File

@@ -0,0 +1,6 @@
void main() {
gl_FrontColor = gl_Color;
gl_PointSize = 10 * gl_Color.x;
gl_Position = gl_Vertex;
}

View File

@@ -10,6 +10,10 @@
static const char *filename = NULL;
static GLuint nr_steps = 4;
static GLuint prim = GL_TRIANGLES;
static GLfloat psz = 1.0;
static GLboolean pointsmooth = 0;
static GLboolean program_point_size = 0;
static GLuint fragShader;
static GLuint vertShader;
@@ -229,6 +233,14 @@ static void subdiv( union vert *v0,
}
}
static void enable( GLenum value, GLboolean flag )
{
if (flag)
glEnable(value);
else
glDisable(value);
}
/** Assignment */
#define ASSIGN_3V( V, V0, V1, V2 ) \
do { \
@@ -241,10 +253,13 @@ static void Display( void )
{
glClearColor(0.3, 0.3, 0.3, 1);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glPointSize(psz);
glUseProgram(program);
enable( GL_POINT_SMOOTH, pointsmooth );
enable( GL_VERTEX_PROGRAM_POINT_SIZE_ARB, program_point_size );
glBegin(GL_TRIANGLES);
glBegin(prim);
{
@@ -291,10 +306,41 @@ static void Key( unsigned char key, int x, int y )
(void) x;
(void) y;
switch (key) {
case 27:
CleanUp();
exit(0);
break;
case 'p':
prim = GL_POINTS;
break;
case 't':
prim = GL_TRIANGLES;
break;
case 's':
psz += .5;
break;
case 'S':
if (psz > .5)
psz -= .5;
break;
case 'm':
pointsmooth = !pointsmooth;
break;
case 'z':
program_point_size = !program_point_size;
break;
case '+':
nr_steps++;
break;
case '-':
if (nr_steps)
nr_steps--;
break;
case ' ':
psz = 1.0;
prim = GL_TRIANGLES;
nr_steps = 4;
break;
case 27:
CleanUp();
exit(0);
break;
}
glutPostRedisplay();
}
@@ -305,7 +351,7 @@ int main( int argc, char *argv[] )
glutInitWindowPosition( 0, 0 );
glutInitWindowSize( 250, 250 );
glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH );
glutCreateWindow(argv[0]);
glutCreateWindow(argv[argc-1]);
glewInit();
glutReshapeFunc( Reshape );
glutKeyboardFunc( Key );

View File

@@ -50,6 +50,7 @@ struct window {
float Angle;
int Id;
HGLRC sharedContext;
HANDLE hEventInitialised;
};
@@ -414,6 +415,10 @@ threadRunner (void *arg)
Error("Couldn't obtain HDC");
}
/* Wait for the previous thread */
if(tia->id > 0)
WaitForSingleObject(Windows[tia->id - 1].hEventInitialised, INFINITE);
pfd.cColorBits = 24;
pfd.cDepthBits = 24;
pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
@@ -434,9 +439,16 @@ threadRunner (void *arg)
}
if (win->sharedContext) {
wglShareLists(win->sharedContext, win->Context);
if(!wglShareLists(win->sharedContext, win->Context))
Error("Couldn't share WGL context lists");
}
SetEvent(win->hEventInitialised);
/* Wait for all threads to initialize otherwise wglShareLists will fail */
if(tia->id < NumWindows - 1)
WaitForSingleObject(Windows[NumWindows - 1].hEventInitialised, INFINITE);
SendMessage(win->Win, WM_SIZE, 0, 0);
while (1) {
@@ -511,20 +523,26 @@ main(int argc, char *argv[])
h[2] = AddWindow( 10, 350, gCtx);
h[3] = AddWindow(330, 350, gCtx);
if (!wglMakeCurrent(gHDC, gCtx)) {
Error("wglMakeCurrent failed for init thread.");
return -1;
for (i = 0; i < NumWindows; i++) {
Windows[i].hEventInitialised = CreateEvent(NULL, TRUE, FALSE, NULL);
}
InitGLstuff();
for (i = 0; i < NumWindows; i++) {
DWORD id;
tia[i].id = i;
threads[i] = CreateThread(NULL, 0, threadRunner, &tia[i], 0, &id);
WaitForSingleObject(Windows[i].hEventInitialised, INFINITE);
}
if (!wglMakeCurrent(gHDC, gCtx)) {
Error("wglMakeCurrent failed for init thread.");
return -1;
}
InitGLstuff();
while (1) {
MSG msg;

View File

@@ -348,7 +348,6 @@ print_screen_info(HDC _hdc, GLboolean limits)
HWND win;
HGLRC ctx;
int visinfo;
int width = 100, height = 100;
HDC hdc;
PIXELFORMATDESCRIPTOR pfd;
@@ -364,18 +363,18 @@ print_screen_info(HDC _hdc, GLboolean limits)
win = CreateWindowEx(0,
wc.lpszClassName,
"wglinfo",
WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
width,
height,
NULL,
NULL,
wc.hInstance,
NULL);
if (!win) {
fprintf(stderr, "Couldn't create window");
exit(1);
return;
}
hdc = GetDC(win);
@@ -476,7 +475,7 @@ print_visual_attribs_verbose(int iPixelFormat, LPPIXELFORMATDESCRIPTOR ppfd)
ppfd->dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0);
printf(" bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n",
0 /* ppfd->bufferSize */, 0 /* ppfd->level */,
visual_render_type_name(ppfd->dwFlags),
visual_render_type_name(ppfd->iPixelType),
ppfd->dwFlags & PFD_DOUBLEBUFFER ? 1 : 0,
ppfd->dwFlags & PFD_STEREO ? 1 : 0);
printf(" rgba: cRedBits=%d cGreenBits=%d cBlueBits=%d cAlphaBits=%d\n",

View File

@@ -72,6 +72,7 @@ struct winthread {
int WinWidth, WinHeight;
GLboolean NewSize;
HANDLE hEventInitialised;
GLboolean Initialized;
GLboolean MakeNewTexture;
HANDLE hEventRedraw;
};
@@ -114,20 +115,20 @@ static void
MakeNewTexture(struct winthread *wt)
{
#define TEX_SIZE 128
static float step = 0.0;
static float step = 0.0f;
GLfloat image[TEX_SIZE][TEX_SIZE][4];
GLint width;
int i, j;
for (j = 0; j < TEX_SIZE; j++) {
for (i = 0; i < TEX_SIZE; i++) {
float dt = 5.0 * (j - 0.5 * TEX_SIZE) / TEX_SIZE;
float ds = 5.0 * (i - 0.5 * TEX_SIZE) / TEX_SIZE;
float dt = 5.0f * (j - 0.5f * TEX_SIZE) / TEX_SIZE;
float ds = 5.0f * (i - 0.5f * TEX_SIZE) / TEX_SIZE;
float r = dt * dt + ds * ds + step;
image[j][i][0] =
image[j][i][1] =
image[j][i][2] = 0.75 + 0.25 * cos(r);
image[j][i][3] = 1.0;
image[j][i][2] = 0.75f + 0.25f * (float) cos(r);
image[j][i][3] = 1.0f;
}
}
@@ -159,7 +160,7 @@ static void
draw_object(void)
{
glPushMatrix();
glScalef(0.75, 0.75, 0.75);
glScalef(0.75f, 0.75f, 0.75f);
glColor3f(1, 0, 0);
@@ -288,6 +289,15 @@ draw_loop(struct winthread *wt)
wglMakeCurrent(wt->hDC, wt->Context);
if (!wt->Initialized) {
printf("wglthreads: %d: GL_RENDERER = %s\n", wt->Index,
(char *) glGetString(GL_RENDERER));
if (Texture /*&& wt->Index == 0*/) {
MakeNewTexture(wt);
}
wt->Initialized = GL_TRUE;
}
if (Locking)
LeaveCriticalSection(&Mutex);
@@ -315,13 +325,15 @@ draw_loop(struct winthread *wt)
glPushMatrix();
glRotatef(wt->Angle, 0, 1, 0);
glRotatef(wt->Angle, 1, 0, 0);
glScalef(0.7, 0.7, 0.7);
glScalef(0.7f, 0.7f, 0.7f);
draw_object();
glPopMatrix();
if (Locking)
EnterCriticalSection(&Mutex);
SwapBuffers(wt->hDC);
if (Locking)
LeaveCriticalSection(&Mutex);
@@ -433,7 +445,7 @@ create_window(struct winthread *wt, HGLRC shareCtx)
win = CreateWindowEx(0,
wc.lpszClassName,
"wglthreads",
WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TILEDWINDOW,
xpos,
ypos,
width,
@@ -471,7 +483,8 @@ create_window(struct winthread *wt, HGLRC shareCtx)
}
if (shareCtx) {
wglShareLists(shareCtx, ctx);
if(!wglShareLists(shareCtx, ctx))
Error("Couldn't share WGL context lists");
}
/* save the info for this window/context */
@@ -482,14 +495,6 @@ create_window(struct winthread *wt, HGLRC shareCtx)
wt->WinWidth = width;
wt->WinHeight = height;
wt->NewSize = GL_TRUE;
wglMakeCurrent(hdc, ctx);
printf("wglthreads: %d: GL_RENDERER = %s\n", wt->Index, (char *) glGetString(GL_RENDERER));
wglMakeCurrent(NULL, NULL);
if (Texture/* && wt->Index == 0*/) {
MakeNewTexture(wt);
}
}
@@ -502,10 +507,22 @@ ThreadProc(void *p)
struct winthread *wt = (struct winthread *) p;
HGLRC share;
/* Wait for the previous thread */
if(Texture && wt->Index > 0) {
WaitForSingleObject(WinThreads[wt->Index - 1].hEventInitialised, INFINITE);
share = WinThreads[0].Context;
}
else
share = 0;
share = (Texture && wt->Index > 0) ? WinThreads[0].Context : 0;
create_window(wt, share);
SetEvent(wt->hEventInitialised);
/* Wait for all threads to initialize otherwise wglShareLists will fail */
if(wt->Index < NumWinThreads - 1)
WaitForSingleObject(WinThreads[NumWinThreads - 1].hEventInitialised, INFINITE);
draw_loop(wt);
return 0;
}
@@ -539,6 +556,7 @@ main(int argc, char *argv[])
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-h") == 0) {
usage();
exit(0);
}
else if (strcmp(argv[i], "-l") == 0) {
Locking = 1;
@@ -588,13 +606,17 @@ main(int argc, char *argv[])
printf("wglthreads: creating threads\n");
/* Create the events */
for (i = 0; i < NumWinThreads; i++) {
WinThreads[i].Index = i;
WinThreads[i].hEventInitialised = CreateEvent(NULL, TRUE, FALSE, NULL);
WinThreads[i].hEventRedraw = CreateEvent(NULL, FALSE, FALSE, NULL);
}
/* Create the threads */
for (i = 0; i < NumWinThreads; i++) {
DWORD id;
WinThreads[i].Index = i;
WinThreads[i].hEventInitialised = CreateEvent(NULL, TRUE, FALSE, NULL);
WinThreads[i].hEventRedraw = CreateEvent(NULL, FALSE, FALSE, NULL);
WinThreads[i].Thread = CreateThread(NULL,
0,
ThreadProc,
@@ -603,8 +625,6 @@ main(int argc, char *argv[])
&id);
printf("wglthreads: Created thread %p\n", (void *) WinThreads[i].Thread);
WaitForSingleObject(WinThreads[i].hEventInitialised, INFINITE);
threads[i] = WinThreads[i].Thread;
}

View File

@@ -20,16 +20,17 @@
*/
/*
* This is a port of the infamous "gears" demo to straight GLX (i.e. no GLUT)
* Port by Brian Paul 23 March 2001
* Version of glxgears that creates/destroys the rendering context for each
* frame. Also periodically destroy/recreate the window.
* Good for finding memory leaks, etc.
*
* Command line options:
* -info print GL implementation information
* -stereo use stereo enabled GLX visual
*
*/
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
@@ -92,13 +93,8 @@ static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
static GLint gear1, gear2, gear3;
static GLfloat angle = 0.0;
static GLboolean fullscreen = GL_FALSE; /* Create a single fullscreen window */
static GLboolean stereo = GL_FALSE; /* Enable stereo. */
static GLfloat eyesep = 5.0; /* Eye separation. */
static GLfloat fix_point = 40.0; /* Fixation point distance. */
static GLfloat left, right, asp; /* Stereo frustum params. */
XVisualInfo *visinfo;
static XVisualInfo *visinfo = NULL;
static int WinWidth = 300, WinHeight = 300;
/*
@@ -272,22 +268,13 @@ do_draw(void)
}
/* new window size or exposure */
static void
reshape(int width, int height)
{
glViewport(0, 0, (GLint) width, (GLint) height);
if (stereo) {
GLfloat w;
asp = (GLfloat) height / (GLfloat) width;
w = fix_point * (1.0 / 5.0);
left = -5.0 * ((w - 0.5 * eyesep) / fix_point);
right = 5.0 * ((w + 0.5 * eyesep) / fix_point);
} else {
{
GLfloat h = (GLfloat) height / (GLfloat) width;
glMatrixMode(GL_PROJECTION);
@@ -299,7 +286,6 @@ reshape(int width, int height)
glLoadIdentity();
glTranslatef(0.0, 0.0, -40.0);
}
static void
@@ -337,7 +323,7 @@ init(void)
glEnable(GL_NORMALIZE);
}
static void
draw( Display *dpy, Window win )
@@ -354,36 +340,9 @@ draw( Display *dpy, Window win )
init();
if (stereo) {
/* First left eye. */
glDrawBuffer(GL_BACK_LEFT);
reshape(WinWidth, WinHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(left, right, -asp, asp, 5.0, 60.0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslated(+0.5 * eyesep, 0.0, 0.0);
do_draw();
glPopMatrix();
/* Then right eye. */
glDrawBuffer(GL_BACK_RIGHT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-right, -left, -asp, asp, 5.0, 60.0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslated(-0.5 * eyesep, 0.0, 0.0);
do_draw();
glPopMatrix();
} else
do_draw();
do_draw();
glDeleteLists(gear1, 1);
glDeleteLists(gear2, 1);
@@ -410,14 +369,6 @@ make_window( Display *dpy, const char *name,
GLX_DOUBLEBUFFER,
GLX_DEPTH_SIZE, 1,
None };
int stereoAttribs[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
GLX_DEPTH_SIZE, 1,
GLX_STEREO,
None };
int scrnum;
XSetWindowAttributes attr;
unsigned long mask;
@@ -427,22 +378,9 @@ make_window( Display *dpy, const char *name,
scrnum = DefaultScreen( dpy );
root = RootWindow( dpy, scrnum );
if (fullscreen) {
x = 0; y = 0;
width = DisplayWidth( dpy, scrnum );
height = DisplayHeight( dpy, scrnum );
}
if (stereo)
visinfo = glXChooseVisual( dpy, scrnum, stereoAttribs );
else
visinfo = glXChooseVisual( dpy, scrnum, attribs );
visinfo = glXChooseVisual( dpy, scrnum, attribs );
if (!visinfo) {
if (stereo) {
printf("Error: couldn't get an RGB, "
"Double-buffered, Stereo visual\n");
} else
printf("Error: couldn't get an RGB, Double-buffered visual\n");
printf("Error: couldn't get an RGB, Double-buffered visual\n");
exit(1);
}
@@ -451,7 +389,7 @@ make_window( Display *dpy, const char *name,
attr.border_pixel = 0;
attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
attr.override_redirect = fullscreen;
attr.override_redirect = 0;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;
win = XCreateWindow( dpy, root, x, y, width, height,
@@ -479,10 +417,9 @@ static void
event_loop(Display *dpy)
{
Window win;
make_window(dpy, "glxgears", 0, 0, 300, 300, &win);
make_window(dpy, "glxgears", 0, 0, WinWidth, WinHeight, &win);
XMapWindow(dpy, win);
while (1) {
while (XPending(dpy) > 0) {
XEvent event;
@@ -492,34 +429,35 @@ event_loop(Display *dpy)
/* we'll redraw below */
break;
case ConfigureNotify:
reshape(event.xconfigure.width, event.xconfigure.height);
WinWidth = event.xconfigure.width;
WinHeight = event.xconfigure.height;
break;
case KeyPress:
{
char buffer[10];
int r, code;
code = XLookupKeysym(&event.xkey, 0);
if (code == XK_Left) {
view_roty += 5.0;
}
else if (code == XK_Right) {
view_roty -= 5.0;
}
else if (code == XK_Up) {
view_rotx += 5.0;
}
else if (code == XK_Down) {
view_rotx -= 5.0;
}
else {
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
NULL, NULL);
if (buffer[0] == 27) {
/* escape */
return;
}
}
}
{
char buffer[10];
int r, code;
code = XLookupKeysym(&event.xkey, 0);
if (code == XK_Left) {
view_roty += 5.0;
}
else if (code == XK_Right) {
view_roty -= 5.0;
}
else if (code == XK_Up) {
view_rotx += 5.0;
}
else if (code == XK_Down) {
view_rotx -= 5.0;
}
else {
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
NULL, NULL);
if (buffer[0] == 27) {
/* escape */
return;
}
}
}
}
}
@@ -550,9 +488,12 @@ event_loop(Display *dpy)
printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds,
fps);
tRate0 = t;
/* Destroy window and create new one */
XDestroyWindow(dpy, win);
make_window(dpy, "glxgears", (int)(fps * 100) % 100, (int)(fps * 100) % 100, 300, 300, &win);
make_window(dpy, "glxgears",
(int)(fps * 100) % 100, (int)(fps * 100) % 100, /* x,y */
WinWidth, WinHeight, &win);
XMapWindow(dpy, win);
frames = 0;
@@ -562,7 +503,6 @@ event_loop(Display *dpy)
}
int
main(int argc, char *argv[])
{
@@ -579,12 +519,6 @@ main(int argc, char *argv[])
else if (strcmp(argv[i], "-info") == 0) {
printInfo = GL_TRUE;
}
else if (strcmp(argv[i], "-stereo") == 0) {
stereo = GL_TRUE;
}
else if (strcmp(argv[i], "-fullscreen") == 0) {
fullscreen = GL_TRUE;
}
else
printf("Warrning: unknown parameter: %s\n", argv[i]);
}
@@ -596,7 +530,6 @@ main(int argc, char *argv[])
return -1;
}
if (printInfo) {
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
@@ -604,7 +537,6 @@ main(int argc, char *argv[])
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
}
event_loop(dpy);
XCloseDisplay(dpy);

View File

@@ -108,7 +108,7 @@ def shlib_emitter(target, source, env):
return (target, source)
shlib_action = SCons.Action.Action(shlib_generator, generator=1)
shlib_action = SCons.Action.Action(shlib_generator, '$SHLINKCOMSTR', generator=1)
res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR')

66
scons/dxsdk.py Normal file
View File

@@ -0,0 +1,66 @@
"""dxsdk
Tool-specific initialization for Microsoft DirectX SDK
"""
#
# Copyright (c) 2009 VMware, Inc.
#
# 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 THE AUTHORS OR COPYRIGHT HOLDERS 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.
#
import os
import os.path
import SCons.Errors
import SCons.Util
def get_dxsdk_root(env):
try:
return os.environ['DXSDK_DIR']
except KeyError:
return None
def get_dxsdk_paths(env):
dxsdk_root = get_dxsdk_root(env)
if dxsdk_root is None:
raise SCons.Errors.InternalError, "DirectX SDK not found"
if env['machine'] in ('generic', 'x86'):
target_cpu = 'x86'
elif env['machine'] == 'x86_64':
target_cpu = 'x64'
else:
raise SCons.Errors.InternalError, "Unsupported target machine"
include_dir = 'Include'
env.Append(CPPDEFINES = [('HAVE_DXSDK', '1')])
env.Prepend(CPPPATH = [os.path.join(dxsdk_root, 'Include')])
env.Prepend(LIBPATH = [os.path.join(dxsdk_root, 'Lib', target_cpu)])
def generate(env):
get_dxsdk_paths(env)
def exists(env):
return get_dxsdk_root(env) is not None
# vim:set ts=4 sw=4 et:

View File

@@ -42,11 +42,17 @@ import SCons.Scanner
def quietCommandLines(env):
# Quiet command lines
# See also http://www.scons.org/wiki/HidingCommandLinesInOutput
env['ASCOMSTR'] = "Assembling $SOURCE ..."
env['CCCOMSTR'] = "Compiling $SOURCE ..."
env['SHCCCOMSTR'] = "Compiling $SOURCE ..."
env['CXXCOMSTR'] = "Compiling $SOURCE ..."
env['SHCXXCOMSTR'] = "Compiling $SOURCE ..."
env['ARCOMSTR'] = "Archiving $TARGET ..."
env['RANLIBCOMSTR'] = ""
env['RANLIBCOMSTR'] = "Indexing $TARGET ..."
env['LINKCOMSTR'] = "Linking $TARGET ..."
env['SHLINKCOMSTR'] = "Linking $TARGET ..."
env['LDMODULECOMSTR'] = "Linking $TARGET ..."
env['SWIGCOMSTR'] = "Generating $TARGET ..."
def createConvenienceLibBuilder(env):
@@ -185,9 +191,8 @@ def num_jobs():
def generate(env):
"""Common environment generation code"""
# FIXME: this is already too late
#if env.get('quiet', False):
# quietCommandLines(env)
if env.get('quiet', True):
quietCommandLines(env)
# Toolchain
platform = env['platform']
@@ -313,76 +318,78 @@ def generate(env):
env.Append(CPPDEFINES = cppdefines)
# C compiler options
cflags = []
cflags = [] # C
cxxflags = [] # C++
ccflags = [] # C & C++
if gcc:
if debug:
cflags += ['-O0', '-g3']
ccflags += ['-O0', '-g3']
elif env['toolchain'] == 'crossmingw':
cflags += ['-O0', '-g3'] # mingw 4.2.1 optimizer is broken
ccflags += ['-O0', '-g3'] # mingw 4.2.1 optimizer is broken
else:
cflags += ['-O3', '-g3']
ccflags += ['-O3', '-g3']
if env['profile']:
cflags += ['-pg']
ccflags += ['-pg']
if env['machine'] == 'x86':
cflags += [
ccflags += [
'-m32',
#'-march=pentium4',
'-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
#'-mfpmath=sse',
]
if env['machine'] == 'x86_64':
cflags += ['-m64']
ccflags += ['-m64']
# See also:
# - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
cflags += [
'-Werror=declaration-after-statement',
ccflags += [
'-Wall',
'-Wmissing-prototypes',
'-Wmissing-field-initializers',
'-Wpointer-arith',
'-Wno-long-long',
'-ffast-math',
'-std=gnu99',
'-fmessage-length=0', # be nice to Eclipse
]
cflags += [
'-Werror=declaration-after-statement',
'-Wmissing-prototypes',
'-std=gnu99',
]
if msvc:
# See also:
# - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
# - cl /?
if debug:
cflags += [
ccflags += [
'/Od', # disable optimizations
'/Oi', # enable intrinsic functions
'/Oy-', # disable frame pointer omission
'/GL-', # disable whole program optimization
]
else:
cflags += [
'/Ox', # maximum optimizations
'/Oi', # enable intrinsic functions
'/Ot', # favor code speed
#'/fp:fast', # fast floating point
ccflags += [
'/O2', # optimize for speed
#'/fp:fast', # fast floating point
]
if env['profile']:
cflags += [
ccflags += [
'/Gh', # enable _penter hook function
'/GH', # enable _pexit hook function
]
cflags += [
ccflags += [
'/W3', # warning level
#'/Wp64', # enable 64 bit porting warnings
]
if env['machine'] == 'x86':
cflags += [
ccflags += [
#'/QIfist', # Suppress _ftol
#'/arch:SSE2', # use the SSE2 instructions
]
if platform == 'windows':
cflags += [
ccflags += [
# TODO
]
if platform == 'winddk':
cflags += [
ccflags += [
'/Zl', # omit default library name in .OBJ
'/Zp8', # 8bytes struct member alignment
'/Gy', # separate functions for linker
@@ -401,7 +408,7 @@ def generate(env):
]
if platform == 'wince':
# See also C:\WINCE600\public\common\oak\misc\makefile.def
cflags += [
ccflags += [
'/Zl', # omit default library name in .OBJ
'/GF', # enable read-only string pooling
'/GR-', # disable C++ RTTI
@@ -418,8 +425,9 @@ def generate(env):
# See http://scons.tigris.org/issues/show_bug.cgi?id=1656
env.EnsureSConsVersion(0, 98, 0)
env['PDB'] = '${TARGET.base}.pdb'
env.Append(CCFLAGS = ccflags)
env.Append(CFLAGS = cflags)
env.Append(CXXFLAGS = cflags)
env.Append(CXXFLAGS = cxxflags)
if env['platform'] == 'windows' and msvc:
# Choose the appropriate MSVC CRT

View File

@@ -416,16 +416,18 @@ def generate(env):
# See also:
# - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
ccflags += [
'-Werror=declaration-after-statement',
'-Wall',
'-Wmissing-prototypes',
'-Wmissing-field-initializers',
'-Wpointer-arith',
'-Wno-long-long',
'-ffast-math',
'-std=gnu99',
'-fmessage-length=0', # be nice to Eclipse
]
cflags += [
'-Werror=declaration-after-statement',
'-Wmissing-prototypes',
'-std=gnu99',
]
if msvc:
# See also:
# - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx

View File

@@ -60,8 +60,6 @@ struct aaline_fragment_shader
struct pipe_shader_state state;
void *driver_fs;
void *aaline_fs;
void *aapoint_fs; /* not yet */
void *sprite_fs; /* not yet */
uint sampler_unit;
int generic_attrib; /**< texcoord/generic used for texture */
};
@@ -373,10 +371,15 @@ generate_aaline_fs(struct aaline_stage *aaline)
aaline->fs->aaline_fs
= aaline->driver_create_fs_state(aaline->pipe, &aaline_fs);
if (aaline->fs->aaline_fs == NULL)
return FALSE;
goto fail;
aaline->fs->generic_attrib = transform.maxGeneric + 1;
FREE((void *)aaline_fs.tokens);
return TRUE;
fail:
FREE((void *)aaline_fs.tokens);
return FALSE;
}
@@ -816,6 +819,10 @@ aaline_delete_fs_state(struct pipe_context *pipe, void *fs)
struct aaline_fragment_shader *aafs = (struct aaline_fragment_shader *) fs;
/* pass-through */
aaline->driver_delete_fs_state(aaline->pipe, aafs->driver_fs);
if (aafs->aaline_fs)
aaline->driver_delete_fs_state(aaline->pipe, aafs->aaline_fs);
FREE(aafs);
}

View File

@@ -523,11 +523,15 @@ generate_aapoint_fs(struct aapoint_stage *aapoint)
aapoint->fs->aapoint_fs
= aapoint->driver_create_fs_state(aapoint->pipe, &aapoint_fs);
if (aapoint->fs->aapoint_fs == NULL)
return FALSE;
goto fail;
aapoint->fs->generic_attrib = transform.maxGeneric + 1;
FREE((void *)aapoint_fs.tokens);
return TRUE;
fail:
FREE((void *)aapoint_fs.tokens);
return FALSE;
}
@@ -825,8 +829,13 @@ aapoint_delete_fs_state(struct pipe_context *pipe, void *fs)
{
struct aapoint_stage *aapoint = aapoint_stage_from_pipe(pipe);
struct aapoint_fragment_shader *aafs = (struct aapoint_fragment_shader *) fs;
/* pass-through */
aapoint->driver_delete_fs_state(aapoint->pipe, aafs->driver_fs);
if (aafs->aapoint_fs)
aapoint->driver_delete_fs_state(aapoint->pipe, aafs->aapoint_fs);
FREE(aafs);
}

View File

@@ -358,6 +358,7 @@ generate_pstip_fs(struct pstip_stage *pstip)
pstip->fs->pstip_fs = pstip->driver_create_fs_state(pstip->pipe, &pstip_fs);
FREE((void *)pstip_fs.tokens);
return TRUE;
}
@@ -649,6 +650,10 @@ pstip_delete_fs_state(struct pipe_context *pipe, void *fs)
struct pstip_fragment_shader *aafs = (struct pstip_fragment_shader *) fs;
/* pass-through */
pstip->driver_delete_fs_state(pstip->pipe, aafs->driver_fs);
if (aafs->pstip_fs)
pstip->driver_delete_fs_state(pstip->pipe, aafs->pstip_fs);
FREE(aafs);
}

View File

@@ -253,6 +253,7 @@ static void widepoint_flush( struct draw_stage *stage, unsigned flags )
{
stage->point = widepoint_first_point;
stage->next->flush( stage->next, flags );
stage->draw->extra_vp_outputs.slot = 0;
}

View File

@@ -54,7 +54,8 @@ static unsigned elt_ubyte( const void *elts, unsigned idx )
static unsigned elt_vert( const void *elts, unsigned idx )
{
return (const ubyte *)elts - (const ubyte *)NULL + idx;
/* unsigned index is packed in the pointer */
return (unsigned)(uintptr_t)elts + idx;
}
pt_elt_func draw_pt_elt_func( struct draw_context *draw )

View File

@@ -244,7 +244,7 @@ int u_index_generator( unsigned hw_mask,
default:
assert(0);
*out_generate = generate[out_idx][in_pv][out_pv][prim];
*out_generate = generate[out_idx][in_pv][out_pv][PIPE_PRIM_POINTS];
*out_prim = PIPE_PRIM_POINTS;
*out_nr = nr;
return U_TRANSLATE_ERROR;

View File

@@ -71,6 +71,12 @@ struct pb_desc
};
/**
* Size. Regular (32bit) unsigned for now.
*/
typedef unsigned pb_size;
/**
* Base class for all pb_* buffers.
*/
@@ -126,7 +132,7 @@ struct pb_vtbl
*/
void (*get_base_buffer)( struct pb_buffer *buf,
struct pb_buffer **base_buf,
unsigned *offset );
pb_size *offset );
};
@@ -177,7 +183,7 @@ pb_unmap(struct pb_buffer *buf)
static INLINE void
pb_get_base_buffer( struct pb_buffer *buf,
struct pb_buffer **base_buf,
unsigned *offset )
pb_size *offset )
{
assert(buf);
if(!buf) {
@@ -241,7 +247,7 @@ pb_reference(struct pb_buffer **dst,
* the requested or not.
*/
static INLINE boolean
pb_check_alignment(size_t requested, size_t provided)
pb_check_alignment(pb_size requested, pb_size provided)
{
if(!requested)
return TRUE;
@@ -269,7 +275,7 @@ pb_check_usage(unsigned requested, unsigned provided)
* hardware.
*/
struct pb_buffer *
pb_malloc_buffer_create(size_t size,
pb_malloc_buffer_create(pb_size size,
const struct pb_desc *desc);

View File

@@ -65,11 +65,11 @@ struct fenced_buffer_list
struct pb_fence_ops *ops;
size_t numDelayed;
pb_size numDelayed;
struct list_head delayed;
#ifdef DEBUG
size_t numUnfenced;
pb_size numUnfenced;
struct list_head unfenced;
#endif
};
@@ -433,7 +433,7 @@ fenced_buffer_fence(struct pb_buffer *buf,
static void
fenced_buffer_get_base_buffer(struct pb_buffer *buf,
struct pb_buffer **base_buf,
unsigned *offset)
pb_size *offset)
{
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
pb_get_base_buffer(fenced_buf->buffer, base_buf, offset);

View File

@@ -102,7 +102,7 @@ malloc_buffer_fence(struct pb_buffer *buf,
static void
malloc_buffer_get_base_buffer(struct pb_buffer *buf,
struct pb_buffer **base_buf,
unsigned *offset)
pb_size *offset)
{
*base_buf = buf;
*offset = 0;
@@ -121,7 +121,7 @@ malloc_buffer_vtbl = {
struct pb_buffer *
pb_malloc_buffer_create(size_t size,
pb_malloc_buffer_create(pb_size size,
const struct pb_desc *desc)
{
struct malloc_buffer *buf;
@@ -150,7 +150,7 @@ pb_malloc_buffer_create(size_t size,
static struct pb_buffer *
pb_malloc_bufmgr_create_buffer(struct pb_manager *mgr,
size_t size,
pb_size size,
const struct pb_desc *desc)
{
return pb_malloc_buffer_create(size, desc);

View File

@@ -73,7 +73,7 @@ struct pb_manager
struct pb_buffer *
(*create_buffer)( struct pb_manager *mgr,
size_t size,
pb_size size,
const struct pb_desc *desc);
/**
@@ -106,7 +106,7 @@ pb_malloc_bufmgr_create(void);
*/
struct pb_manager *
pool_bufmgr_create(struct pb_manager *provider,
size_t n, size_t size,
pb_size n, pb_size size,
const struct pb_desc *desc);
@@ -119,7 +119,7 @@ pool_bufmgr_create(struct pb_manager *provider,
*/
struct pb_manager *
mm_bufmgr_create(struct pb_manager *provider,
size_t size, size_t align2);
pb_size size, pb_size align2);
/**
* Same as mm_bufmgr_create.
@@ -128,7 +128,7 @@ mm_bufmgr_create(struct pb_manager *provider,
*/
struct pb_manager *
mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
size_t size, size_t align2);
pb_size size, pb_size align2);
/**
@@ -136,8 +136,8 @@ mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
*/
struct pb_manager *
pb_slab_manager_create(struct pb_manager *provider,
size_t bufSize,
size_t slabSize,
pb_size bufSize,
pb_size slabSize,
const struct pb_desc *desc);
/**
@@ -146,9 +146,9 @@ pb_slab_manager_create(struct pb_manager *provider,
*/
struct pb_manager *
pb_slab_range_manager_create(struct pb_manager *provider,
size_t minBufSize,
size_t maxBufSize,
size_t slabSize,
pb_size minBufSize,
pb_size maxBufSize,
pb_size slabSize,
const struct pb_desc *desc);
@@ -204,7 +204,7 @@ pb_ondemand_manager_create(struct pb_manager *provider);
*/
struct pb_manager *
pb_debug_manager_create(struct pb_manager *provider,
size_t underflow_size, size_t overflow_size);
pb_size underflow_size, pb_size overflow_size);
#ifdef __cplusplus

View File

@@ -60,7 +60,7 @@ pb_alt_manager(struct pb_manager *mgr)
static struct pb_buffer *
pb_alt_manager_create_buffer(struct pb_manager *_mgr,
size_t size,
pb_size size,
const struct pb_desc *desc)
{
struct pb_alt_manager *mgr = pb_alt_manager(_mgr);

View File

@@ -81,7 +81,7 @@ struct pb_cache_manager
pipe_mutex mutex;
struct list_head delayed;
size_t numDelayed;
pb_size numDelayed;
};
@@ -204,7 +204,7 @@ pb_cache_buffer_fence(struct pb_buffer *_buf,
static void
pb_cache_buffer_get_base_buffer(struct pb_buffer *_buf,
struct pb_buffer **base_buf,
unsigned *offset)
pb_size *offset)
{
struct pb_cache_buffer *buf = pb_cache_buffer(_buf);
pb_get_base_buffer(buf->buffer, base_buf, offset);
@@ -224,7 +224,7 @@ pb_cache_buffer_vtbl = {
static INLINE boolean
pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
size_t size,
pb_size size,
const struct pb_desc *desc)
{
if(buf->base.base.size < size)
@@ -246,7 +246,7 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
static struct pb_buffer *
pb_cache_manager_create_buffer(struct pb_manager *_mgr,
size_t size,
pb_size size,
const struct pb_desc *desc)
{
struct pb_cache_manager *mgr = pb_cache_manager(_mgr);

View File

@@ -72,8 +72,8 @@ struct pb_debug_buffer
struct pb_buffer *buffer;
struct pb_debug_manager *mgr;
size_t underflow_size;
size_t overflow_size;
pb_size underflow_size;
pb_size overflow_size;
struct debug_stack_frame create_backtrace[PB_DEBUG_CREATE_BACKTRACE];
@@ -91,8 +91,8 @@ struct pb_debug_manager
struct pb_manager *provider;
size_t underflow_size;
size_t overflow_size;
pb_size underflow_size;
pb_size overflow_size;
pipe_mutex mutex;
struct list_head list;
@@ -124,9 +124,9 @@ static const uint8_t random_pattern[32] = {
static INLINE void
fill_random_pattern(uint8_t *dst, size_t size)
fill_random_pattern(uint8_t *dst, pb_size size)
{
size_t i = 0;
pb_size i = 0;
while(size--) {
*dst++ = random_pattern[i++];
i &= sizeof(random_pattern) - 1;
@@ -135,11 +135,11 @@ fill_random_pattern(uint8_t *dst, size_t size)
static INLINE boolean
check_random_pattern(const uint8_t *dst, size_t size,
size_t *min_ofs, size_t *max_ofs)
check_random_pattern(const uint8_t *dst, pb_size size,
pb_size *min_ofs, pb_size *max_ofs)
{
boolean result = TRUE;
size_t i;
pb_size i;
*min_ofs = size;
*max_ofs = 0;
for(i = 0; i < size; ++i) {
@@ -183,7 +183,7 @@ pb_debug_buffer_check(struct pb_debug_buffer *buf)
assert(map);
if(map) {
boolean underflow, overflow;
size_t min_ofs, max_ofs;
pb_size min_ofs, max_ofs;
underflow = !check_random_pattern(map, buf->underflow_size,
&min_ofs, &max_ofs);
@@ -287,7 +287,7 @@ pb_debug_buffer_unmap(struct pb_buffer *_buf)
static void
pb_debug_buffer_get_base_buffer(struct pb_buffer *_buf,
struct pb_buffer **base_buf,
unsigned *offset)
pb_size *offset)
{
struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
pb_get_base_buffer(buf->buffer, base_buf, offset);
@@ -363,13 +363,13 @@ pb_debug_manager_dump(struct pb_debug_manager *mgr)
static struct pb_buffer *
pb_debug_manager_create_buffer(struct pb_manager *_mgr,
size_t size,
pb_size size,
const struct pb_desc *desc)
{
struct pb_debug_manager *mgr = pb_debug_manager(_mgr);
struct pb_debug_buffer *buf;
struct pb_desc real_desc;
size_t real_size;
pb_size real_size;
buf = CALLOC_STRUCT(pb_debug_buffer);
if(!buf)
@@ -455,7 +455,7 @@ pb_debug_manager_destroy(struct pb_manager *_mgr)
struct pb_manager *
pb_debug_manager_create(struct pb_manager *provider,
size_t underflow_size, size_t overflow_size)
pb_size underflow_size, pb_size overflow_size)
{
struct pb_debug_manager *mgr;
@@ -485,7 +485,7 @@ pb_debug_manager_create(struct pb_manager *provider,
struct pb_manager *
pb_debug_manager_create(struct pb_manager *provider,
size_t underflow_size, size_t overflow_size)
pb_size underflow_size, pb_size overflow_size)
{
return provider;
}

View File

@@ -62,7 +62,7 @@ fenced_pb_manager(struct pb_manager *mgr)
static struct pb_buffer *
fenced_bufmgr_create_buffer(struct pb_manager *mgr,
size_t size,
pb_size size,
const struct pb_desc *desc)
{
struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr);

View File

@@ -55,10 +55,10 @@ struct mm_pb_manager
pipe_mutex mutex;
size_t size;
pb_size size;
struct mem_block *heap;
size_t align2;
pb_size align2;
struct pb_buffer *buffer;
void *map;
@@ -148,7 +148,7 @@ mm_buffer_fence(struct pb_buffer *buf,
static void
mm_buffer_get_base_buffer(struct pb_buffer *buf,
struct pb_buffer **base_buf,
unsigned *offset)
pb_size *offset)
{
struct mm_buffer *mm_buf = mm_buffer(buf);
struct mm_pb_manager *mm = mm_buf->mgr;
@@ -170,15 +170,15 @@ mm_buffer_vtbl = {
static struct pb_buffer *
mm_bufmgr_create_buffer(struct pb_manager *mgr,
size_t size,
pb_size size,
const struct pb_desc *desc)
{
struct mm_pb_manager *mm = mm_pb_manager(mgr);
struct mm_buffer *mm_buf;
/* We don't handle alignments larger then the one initially setup */
assert(pb_check_alignment(desc->alignment, 1 << mm->align2));
if(!pb_check_alignment(desc->alignment, 1 << mm->align2))
assert(pb_check_alignment(desc->alignment, (pb_size)1 << mm->align2));
if(!pb_check_alignment(desc->alignment, (pb_size)1 << mm->align2))
return NULL;
pipe_mutex_lock(mm->mutex);
@@ -198,10 +198,10 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
mm_buf->mgr = mm;
mm_buf->block = u_mmAllocMem(mm->heap, size, mm->align2, 0);
mm_buf->block = u_mmAllocMem(mm->heap, (int)size, (int)mm->align2, 0);
if(!mm_buf->block) {
debug_printf("warning: heap full\n");
#if 0
debug_printf("warning: heap full\n");
mmDumpMemInfo(mm->heap);
#endif
FREE(mm_buf);
@@ -210,8 +210,8 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
}
/* Some sanity checks */
assert(0 <= (unsigned)mm_buf->block->ofs && (unsigned)mm_buf->block->ofs < mm->size);
assert(size <= (unsigned)mm_buf->block->size && (unsigned)mm_buf->block->ofs + (unsigned)mm_buf->block->size <= mm->size);
assert(0 <= (pb_size)mm_buf->block->ofs && (pb_size)mm_buf->block->ofs < mm->size);
assert(size <= (pb_size)mm_buf->block->size && (pb_size)mm_buf->block->ofs + (pb_size)mm_buf->block->size <= mm->size);
pipe_mutex_unlock(mm->mutex);
return SUPER(mm_buf);
@@ -245,7 +245,7 @@ mm_bufmgr_destroy(struct pb_manager *mgr)
struct pb_manager *
mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
size_t size, size_t align2)
pb_size size, pb_size align2)
{
struct mm_pb_manager *mm;
@@ -273,7 +273,7 @@ mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
if(!mm->map)
goto failure;
mm->heap = u_mmInit(0, size);
mm->heap = u_mmInit(0, (int)size);
if (!mm->heap)
goto failure;
@@ -292,7 +292,7 @@ if(mm->heap)
struct pb_manager *
mm_bufmgr_create(struct pb_manager *provider,
size_t size, size_t align2)
pb_size size, pb_size align2)
{
struct pb_buffer *buffer;
struct pb_manager *mgr;

View File

@@ -55,7 +55,7 @@ struct pb_ondemand_buffer
/** Real buffer */
struct pb_buffer *buffer;
size_t size;
pb_size size;
struct pb_desc desc;
};
@@ -204,7 +204,7 @@ pb_ondemand_buffer_fence(struct pb_buffer *_buf,
static void
pb_ondemand_buffer_get_base_buffer(struct pb_buffer *_buf,
struct pb_buffer **base_buf,
unsigned *offset)
pb_size *offset)
{
struct pb_ondemand_buffer *buf = pb_ondemand_buffer(_buf);
@@ -232,7 +232,7 @@ pb_ondemand_buffer_vtbl = {
static struct pb_buffer *
pb_ondemand_manager_create_buffer(struct pb_manager *_mgr,
size_t size,
pb_size size,
const struct pb_desc *desc)
{
struct pb_ondemand_manager *mgr = pb_ondemand_manager(_mgr);

View File

@@ -58,11 +58,11 @@ struct pool_pb_manager
pipe_mutex mutex;
size_t bufSize;
size_t bufAlign;
pb_size bufSize;
pb_size bufAlign;
size_t numFree;
size_t numTot;
pb_size numFree;
pb_size numTot;
struct list_head free;
@@ -89,7 +89,7 @@ struct pool_buffer
struct list_head head;
size_t start;
pb_size start;
};
@@ -162,7 +162,7 @@ pool_buffer_fence(struct pb_buffer *buf,
static void
pool_buffer_get_base_buffer(struct pb_buffer *buf,
struct pb_buffer **base_buf,
unsigned *offset)
pb_size *offset)
{
struct pool_buffer *pool_buf = pool_buffer(buf);
struct pool_pb_manager *pool = pool_buf->mgr;
@@ -184,7 +184,7 @@ pool_buffer_vtbl = {
static struct pb_buffer *
pool_bufmgr_create_buffer(struct pb_manager *mgr,
size_t size,
pb_size size,
const struct pb_desc *desc)
{
struct pool_pb_manager *pool = pool_pb_manager(mgr);
@@ -251,13 +251,13 @@ pool_bufmgr_destroy(struct pb_manager *mgr)
struct pb_manager *
pool_bufmgr_create(struct pb_manager *provider,
size_t numBufs,
size_t bufSize,
pb_size numBufs,
pb_size bufSize,
const struct pb_desc *desc)
{
struct pool_pb_manager *pool;
struct pool_buffer *pool_buf;
size_t i;
pb_size i;
if(!provider)
return NULL;

View File

@@ -68,7 +68,7 @@ struct pb_slab_buffer
unsigned mapCount;
/** Offset relative to the start of the slab buffer. */
size_t start;
pb_size start;
/** Use when validating, to signal that all mappings are finished */
/* TODO: Actually validation does not reach this stage yet */
@@ -83,8 +83,8 @@ struct pb_slab
{
struct list_head head;
struct list_head freeBuffers;
size_t numBuffers;
size_t numFree;
pb_size numBuffers;
pb_size numFree;
struct pb_slab_buffer *buffers;
struct pb_slab_manager *mgr;
@@ -108,10 +108,10 @@ struct pb_slab_manager
struct pb_manager *provider;
/** Size of the buffers we hand on downstream */
size_t bufSize;
pb_size bufSize;
/** Size of the buffers we request upstream */
size_t slabSize;
pb_size slabSize;
/**
* Alignment, usage to be used to allocate the slab buffers.
@@ -150,14 +150,14 @@ struct pb_slab_range_manager
struct pb_manager *provider;
size_t minBufSize;
size_t maxBufSize;
pb_size minBufSize;
pb_size maxBufSize;
/** @sa pb_slab_manager::desc */
struct pb_desc desc;
unsigned numBuckets;
size_t *bucketSizes;
pb_size *bucketSizes;
/** Array of pb_slab_manager, one for each bucket size */
struct pb_manager **buckets;
@@ -270,7 +270,7 @@ pb_slab_buffer_fence(struct pb_buffer *_buf,
static void
pb_slab_buffer_get_base_buffer(struct pb_buffer *_buf,
struct pb_buffer **base_buf,
unsigned *offset)
pb_size *offset)
{
struct pb_slab_buffer *buf = pb_slab_buffer(_buf);
pb_get_base_buffer(buf->slab->bo, base_buf, offset);
@@ -369,7 +369,7 @@ out_err0:
static struct pb_buffer *
pb_slab_manager_create_buffer(struct pb_manager *_mgr,
size_t size,
pb_size size,
const struct pb_desc *desc)
{
struct pb_slab_manager *mgr = pb_slab_manager(_mgr);
@@ -450,8 +450,8 @@ pb_slab_manager_destroy(struct pb_manager *_mgr)
struct pb_manager *
pb_slab_manager_create(struct pb_manager *provider,
size_t bufSize,
size_t slabSize,
pb_size bufSize,
pb_size slabSize,
const struct pb_desc *desc)
{
struct pb_slab_manager *mgr;
@@ -479,11 +479,11 @@ pb_slab_manager_create(struct pb_manager *provider,
static struct pb_buffer *
pb_slab_range_manager_create_buffer(struct pb_manager *_mgr,
size_t size,
pb_size size,
const struct pb_desc *desc)
{
struct pb_slab_range_manager *mgr = pb_slab_range_manager(_mgr);
size_t bufSize;
pb_size bufSize;
unsigned i;
bufSize = mgr->minBufSize;
@@ -527,13 +527,13 @@ pb_slab_range_manager_destroy(struct pb_manager *_mgr)
struct pb_manager *
pb_slab_range_manager_create(struct pb_manager *provider,
size_t minBufSize,
size_t maxBufSize,
size_t slabSize,
pb_size minBufSize,
pb_size maxBufSize,
pb_size slabSize,
const struct pb_desc *desc)
{
struct pb_slab_range_manager *mgr;
size_t bufSize;
pb_size bufSize;
unsigned i;
if(!provider)

View File

@@ -168,7 +168,7 @@ ppc_allocate_register(struct ppc_function *p)
{
unsigned i;
for (i = 0; i < PPC_NUM_REGS; i++) {
const uint64_t mask = 1 << i;
const uint32_t mask = 1 << i;
if ((p->reg_used & mask) == 0) {
p->reg_used |= mask;
return i;
@@ -200,7 +200,7 @@ ppc_allocate_fp_register(struct ppc_function *p)
{
unsigned i;
for (i = 0; i < PPC_NUM_FP_REGS; i++) {
const uint64_t mask = 1 << i;
const uint32_t mask = 1 << i;
if ((p->fp_used & mask) == 0) {
p->fp_used |= mask;
return i;
@@ -232,7 +232,7 @@ ppc_allocate_vec_register(struct ppc_function *p)
{
unsigned i;
for (i = 0; i < PPC_NUM_VEC_REGS; i++) {
const uint64_t mask = 1 << i;
const uint32_t mask = 1 << i;
if ((p->vec_used & mask) == 0) {
p->vec_used |= mask;
return i;

View File

@@ -27,6 +27,7 @@
#include "util/u_debug.h"
#include "util/u_string.h"
#include "util/u_math.h"
#include "tgsi_dump.h"
#include "tgsi_info.h"
#include "tgsi_iterate.h"
@@ -516,7 +517,7 @@ struct str_dump_ctx
struct dump_ctx base;
char *str;
char *ptr;
size_t left;
int left;
};
static void
@@ -525,13 +526,20 @@ str_dump_ctx_printf(struct dump_ctx *ctx, const char *format, ...)
struct str_dump_ctx *sctx = (struct str_dump_ctx *)ctx;
if(sctx->left > 1) {
size_t written;
int written;
va_list ap;
va_start(ap, format);
written = util_vsnprintf(sctx->ptr, sctx->left, format, ap);
va_end(ap);
sctx->ptr += written;
sctx->left -= written;
/* Some complicated logic needed to handle the return value of
* vsnprintf:
*/
if (written > 0) {
written = MIN2(sctx->left, written);
sctx->ptr += written;
sctx->left -= written;
}
}
}
@@ -556,7 +564,7 @@ tgsi_dump_str(
ctx.str = str;
ctx.str[0] = 0;
ctx.ptr = str;
ctx.left = size;
ctx.left = (int)size;
tgsi_iterate_shader( tokens, &ctx.base.iter );
}

View File

@@ -34,7 +34,7 @@
extern "C" {
#endif
#define MAX_LABELS 1024
#define MAX_LABELS (4 * 1024) /**< basically, max instructions */
#define NUM_CHANNELS 4 /* R,G,B,A */
#define QUAD_SIZE 4 /* 4 pixel/quad */

View File

@@ -1385,7 +1385,7 @@ set_vertex_data(struct gen_mipmap_state *ctx,
* Not +/-1 to avoid cube face selection ambiguity near the edges,
* though that can still sometimes happen with this scale factor...
*/
const float scale = 0.9999;
const float scale = 0.9999f;
const float sc = (2.0f * st[i][0] - 1.0f) * scale;
const float tc = (2.0f * st[i][1] - 1.0f) * scale;

View File

@@ -829,7 +829,7 @@ util_vsnprintf(char *str, size_t size, const char *format, va_list args)
break;
default:
intptr = va_arg(args, int *);
*intptr = len;
*intptr = (int)len;
break;
}
break;

View File

@@ -1126,7 +1126,22 @@ pipe_get_tile_z(struct pipe_transfer *pt,
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
/* convert 24-bit Z to 32-bit Z */
pDest[j] = (ptrc[j] << 8) | (ptrc[j] & 0xff);
pDest[j] = (ptrc[j] << 8) | ((ptrc[j] >> 16) & 0xff);
}
pDest += dstStride;
ptrc += pt->stride/4;
}
}
break;
case PIPE_FORMAT_Z24S8_UNORM:
case PIPE_FORMAT_Z24X8_UNORM:
{
const uint *ptrc
= (const uint *)(map + y * pt->stride + x*4);
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
/* convert 24-bit Z to 32-bit Z */
pDest[j] = (ptrc[j] & 0xffffff00) | ((ptrc[j] >> 24) & 0xff);
}
pDest += dstStride;
ptrc += pt->stride/4;

View File

@@ -86,6 +86,8 @@ cell_get_param(struct pipe_screen *screen, int param)
return 1; /* XXX not really true */
case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
return 0; /* XXX to do */
case PIPE_CAP_TGSI_CONT_SUPPORTED:
return 1;
default:
return 0;
}

View File

@@ -126,6 +126,22 @@ softpipe_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
struct softpipe_context *softpipe = softpipe_context( pipe );
unsigned i;
if(softpipe->dirty_render_cache) {
for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) {
if(softpipe->framebuffer.cbufs[i] &&
softpipe->framebuffer.cbufs[i]->texture == texture)
return PIPE_REFERENCED_FOR_WRITE;
}
if(softpipe->framebuffer.zsbuf &&
softpipe->framebuffer.zsbuf->texture == texture)
return PIPE_REFERENCED_FOR_WRITE;
}
/* FIXME: we also need to do the same for the texture cache */
return PIPE_UNREFERENCED;
}

View File

@@ -144,6 +144,8 @@ struct softpipe_context {
struct draw_stage *vbuf;
struct softpipe_vbuf_render *vbuf_render;
boolean dirty_render_cache;
struct softpipe_tile_cache *cbuf_cache[PIPE_MAX_COLOR_BUFS];
struct softpipe_tile_cache *zsbuf_cache;

View File

@@ -182,6 +182,8 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
/* Note: leave drawing surfaces mapped */
softpipe_unmap_constant_buffers(sp);
sp->dirty_render_cache = TRUE;
return TRUE;
}

View File

@@ -71,6 +71,8 @@ softpipe_flush( struct pipe_context *pipe,
* to unmap surfaces when flushing.
*/
softpipe_unmap_transfers(softpipe);
softpipe->dirty_render_cache = FALSE;
}
/* Enable to dump BMPs of the color/depth buffers each frame */

View File

@@ -236,7 +236,6 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr)
}
break;
case PIPE_PRIM_TRIANGLES:
for (i = 2; i < nr; i += 3) {
setup_tri( setup_ctx,
@@ -256,7 +255,6 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr)
break;
case PIPE_PRIM_TRIANGLE_FAN:
case PIPE_PRIM_POLYGON:
for (i = 2; i < nr; i += 1) {
setup_tri( setup_ctx,
get_vert(vertex_buffer, indices[0], stride),
@@ -264,6 +262,7 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr)
get_vert(vertex_buffer, indices[i-0], stride));
}
break;
case PIPE_PRIM_QUADS:
for (i = 3; i < nr; i += 4) {
setup_tri( setup_ctx,
@@ -277,6 +276,7 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr)
get_vert(vertex_buffer, indices[i-0], stride));
}
break;
case PIPE_PRIM_QUAD_STRIP:
for (i = 3; i < nr; i += 2) {
setup_tri( setup_ctx,
@@ -290,6 +290,16 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr)
get_vert(vertex_buffer, indices[i-0], stride));
}
break;
case PIPE_PRIM_POLYGON:
for (i = 2; i < nr; i += 1) {
setup_tri( setup_ctx,
get_vert(vertex_buffer, indices[0-1], stride),
get_vert(vertex_buffer, indices[i-0], stride),
get_vert(vertex_buffer, indices[0], stride));
}
break;
default:
assert(0);
}
@@ -378,7 +388,6 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
break;
case PIPE_PRIM_TRIANGLE_FAN:
case PIPE_PRIM_POLYGON:
for (i = 2; i < nr; i += 1) {
setup_tri( setup_ctx,
get_vert(vertex_buffer, 0, stride),
@@ -386,6 +395,7 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
get_vert(vertex_buffer, i-0, stride));
}
break;
case PIPE_PRIM_QUADS:
for (i = 3; i < nr; i += 4) {
setup_tri( setup_ctx,
@@ -412,6 +422,20 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
get_vert(vertex_buffer, i-0, stride));
}
break;
case PIPE_PRIM_POLYGON:
/* Almost same as tri fan but the _first_ vertex specifies the flat
* shading color. Note that the first polygon vertex is passed as
* the last triangle vertex here.
*/
for (i = 2; i < nr; i += 1) {
setup_tri( setup_ctx,
get_vert(vertex_buffer, i-1, stride),
get_vert(vertex_buffer, i-0, stride),
get_vert(vertex_buffer, 0, stride));
}
break;
default:
assert(0);
}

View File

@@ -87,6 +87,8 @@ softpipe_get_param(struct pipe_screen *screen, int param)
return 8; /* max 128x128x128 */
case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
return 12; /* max 2Kx2K */
case PIPE_CAP_TGSI_CONT_SUPPORTED:
return 1;
default:
return 0;
}
@@ -127,6 +129,11 @@ softpipe_is_format_supported( struct pipe_screen *screen,
unsigned tex_usage,
unsigned geom_flags )
{
assert(target == PIPE_TEXTURE_1D ||
target == PIPE_TEXTURE_2D ||
target == PIPE_TEXTURE_3D ||
target == PIPE_TEXTURE_CUBE);
switch(format) {
case PIPE_FORMAT_DXT1_RGB:
case PIPE_FORMAT_DXT1_RGBA:

View File

@@ -444,7 +444,8 @@ static void flush_spans( struct setup_context *setup )
mask |= MASK_TOP_RIGHT;
if (x+1 >= xleft1 && x+1 < xright1)
mask |= MASK_BOTTOM_RIGHT;
EMIT_QUAD( setup, x, setup->span.y, mask );
if (mask)
EMIT_QUAD( setup, x, setup->span.y, mask );
}
break;
@@ -458,7 +459,8 @@ static void flush_spans( struct setup_context *setup )
mask |= MASK_TOP_LEFT;
if (x+1 >= xleft0 && x+1 < xright0)
mask |= MASK_TOP_RIGHT;
EMIT_QUAD( setup, x, setup->span.y, mask );
if (mask)
EMIT_QUAD( setup, x, setup->span.y, mask );
}
break;
@@ -472,7 +474,8 @@ static void flush_spans( struct setup_context *setup )
mask |= MASK_BOTTOM_LEFT;
if (x+1 >= xleft1 && x+1 < xright1)
mask |= MASK_BOTTOM_RIGHT;
EMIT_QUAD( setup, x, setup->span.y, mask );
if (mask)
EMIT_QUAD( setup, x, setup->span.y, mask );
}
break;

View File

@@ -744,7 +744,9 @@ shadow_compare(uint compare_func,
break;
}
/* XXX returning result for default GL_DEPTH_TEXTURE_MODE = GL_LUMINANCE */
rgba[0][j] = rgba[1][j] = rgba[2][j] = (float) k;
rgba[3][j] = 1.0F;
}

View File

@@ -451,11 +451,11 @@ void trace_dump_float(double value)
}
void trace_dump_bytes(const void *data,
long unsigned size)
size_t size)
{
static const char hex_table[16] = "0123456789ABCDEF";
const uint8_t *p = data;
long unsigned i;
size_t i;
if (!dumping)
return;

View File

@@ -91,7 +91,7 @@ void trace_dump_bool(int value);
void trace_dump_int(long long int value);
void trace_dump_uint(long long unsigned value);
void trace_dump_float(double value);
void trace_dump_bytes(const void *data, long unsigned size);
void trace_dump_bytes(const void *data, size_t size);
void trace_dump_string(const char *str);
void trace_dump_enum(const char *value);
void trace_dump_array_begin(void);
@@ -130,7 +130,7 @@ void trace_dump_transfer_ptr(struct pipe_transfer *_transfer);
#define trace_dump_array(_type, _obj, _size) \
do { \
unsigned long idx; \
size_t idx; \
trace_dump_array_begin(); \
for(idx = 0; idx < (_size); ++idx) { \
trace_dump_elem_begin(); \
@@ -142,7 +142,7 @@ void trace_dump_transfer_ptr(struct pipe_transfer *_transfer);
#define trace_dump_struct_array(_type, _obj, _size) \
do { \
unsigned long idx; \
size_t idx; \
trace_dump_array_begin(); \
for(idx = 0; idx < (_size); ++idx) { \
trace_dump_elem_begin(); \

View File

@@ -310,6 +310,7 @@ enum pipe_transfer_usage {
#define PIPE_CAP_TEXTURE_MIRROR_CLAMP 24
#define PIPE_CAP_TEXTURE_MIRROR_REPEAT 25
#define PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS 26
#define PIPE_CAP_TGSI_CONT_SUPPORTED 27
/**

View File

@@ -536,13 +536,39 @@ pf_get_nblocks(const struct pipe_format_block *block, unsigned width, unsigned h
return pf_get_nblocksx(block, width)*pf_get_nblocksy(block, height);
}
static INLINE size_t
pf_get_stride(const struct pipe_format_block *block, unsigned width)
{
return pf_get_nblocksx(block, width)*block->size;
}
static INLINE size_t
pf_get_2d_size(const struct pipe_format_block *block, size_t stride, unsigned height)
{
return pf_get_nblocksy(block, height)*stride;
}
static INLINE boolean
pf_is_depth_stencil( enum pipe_format format )
pf_is_depth_or_stencil( enum pipe_format format )
{
return (pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) +
pf_get_component_bits( format, PIPE_FORMAT_COMP_S )) != 0;
}
static INLINE boolean
pf_is_depth_and_stencil( enum pipe_format format )
{
return (pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) != 0 &&
pf_get_component_bits( format, PIPE_FORMAT_COMP_S ) != 0);
}
/** DEPRECATED: For backwards compatibility */
static INLINE boolean
pf_is_depth_stencil( enum pipe_format format )
{
return pf_is_depth_or_stencil( format );
}
static INLINE boolean
pf_is_compressed( enum pipe_format format )
{

View File

@@ -62,29 +62,29 @@ pipe_is_referenced(struct pipe_reference *reference)
* Set 'ptr' to point to 'reference' and update reference counting.
* The old thing pointed to, if any, will be unreferenced first.
* 'reference' may be NULL.
*
* XXX: thread safety issues!
*/
static INLINE bool
pipe_reference(struct pipe_reference **ptr, struct pipe_reference *reference)
{
bool destroy = FALSE;
/* bump the reference.count first */
if (reference) {
assert(pipe_is_referenced(reference));
p_atomic_inc(&reference->count);
}
if (*ptr) {
assert(pipe_is_referenced(*ptr));
if (p_atomic_dec_zero(&(*ptr)->count)) {
destroy = TRUE;
if(*ptr != reference) {
/* bump the reference.count first */
if (reference) {
assert(pipe_is_referenced(reference));
p_atomic_inc(&reference->count);
}
if (*ptr) {
assert(pipe_is_referenced(*ptr));
if (p_atomic_dec_zero(&(*ptr)->count)) {
destroy = TRUE;
}
}
*ptr = reference;
}
*ptr = reference;
return destroy;
}

View File

@@ -36,6 +36,7 @@
#include "pipe/p_compiler.h"
#include "util/u_debug.h" /* for assert */
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS)

View File

@@ -231,7 +231,6 @@ dri_create_buffer(__DRIscreenPrivate * sPriv,
if (visual->depthBits) {
if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM,
PIPE_TEXTURE_2D,
PIPE_TEXTURE_USAGE_RENDER_TARGET |
PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0))
depthFormat = PIPE_FORMAT_Z24S8_UNORM;
else
@@ -242,7 +241,6 @@ dri_create_buffer(__DRIscreenPrivate * sPriv,
if (visual->stencilBits) {
if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM,
PIPE_TEXTURE_2D,
PIPE_TEXTURE_USAGE_RENDER_TARGET |
PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0))
stencilFormat = PIPE_FORMAT_Z24S8_UNORM;
else

View File

@@ -1817,7 +1817,7 @@ Fake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
if (!dpy || !config || !pixmap)
return 0;
for (attr = attribList; *attr; attr++) {
for (attr = attribList; attr && *attr; attr++) {
switch (*attr) {
case GLX_TEXTURE_FORMAT_EXT:
attr++;

View File

@@ -43,19 +43,27 @@ except ImportError:
return struct.unpack(fmt, buf[offset:offset + size])
def make_image(surface):
def make_image(surface, x=None, y=None, w=None, h=None):
if x is None:
x = 0
if y is None:
y = 0
if w is None:
w = surface.width - x
if h is None:
h = surface.height - y
data = surface.get_tile_rgba8(0, 0, surface.width, surface.height)
import Image
outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1)
return outimage
def save_image(filename, surface):
outimage = make_image(surface)
def save_image(filename, surface, x=None, y=None, w=None, h=None):
outimage = make_image(surface, x, y, w, h)
outimage.save(filename, "PNG")
def show_image(surface, title):
outimage = make_image(surface)
def show_image(surface, title, x=None, y=None, w=None, h=None):
outimage = make_image(surface, x, y, w, h)
import Tkinter as tk
from PIL import Image, ImageTk
@@ -305,7 +313,11 @@ class Screen(Object):
def get_tex_transfer(self, texture, face, level, zslice, usage, x, y, w, h):
if texture is None:
return None
return Transfer(texture.get_surface(face, level, zslice), x, y, w, h)
transfer = Transfer(texture.get_surface(face, level, zslice), x, y, w, h)
if transfer and usage != gallium.PIPE_TRANSFER_WRITE:
if self.interpreter.options.all:
self.interpreter.present(transfer.surface, 'transf_read', x, y, w, h)
return transfer
def tex_transfer_destroy(self, transfer):
self.interpreter.unregister_object(transfer)
@@ -314,6 +326,8 @@ class Screen(Object):
if transfer is None:
return
transfer.surface.put_tile_raw(transfer.x, transfer.y, transfer.w, transfer.h, data, stride)
if self.interpreter.options.all:
self.interpreter.present(transfer.surface, 'transf_write', transfer.x, transfer.y, transfer.w, transfer.h)
def user_buffer_create(self, data, size):
# We don't really care to distinguish between user and regular buffers
@@ -577,6 +591,14 @@ class Context(Object):
self.real.draw_range_elements(indexBuffer, indexSize, minIndex, maxIndex, mode, start, count)
self._set_dirty()
def is_texture_referenced(self, texture, face, level):
#return self.real.is_texture_referenced(format, texture, face, level)
pass
def is_buffer_referenced(self, buf):
#return self.real.is_buffer_referenced(format, buf)
pass
def _set_dirty(self):
if self.interpreter.options.step:
self._present()
@@ -602,6 +624,9 @@ class Context(Object):
if self.cbufs and self.cbufs[0]:
self.interpreter.present(self.cbufs[0], "cbuf")
if self.zsbuf:
if self.interpreter.options.all:
self.interpreter.present(self.zsbuf, "zsbuf")
class Interpreter(parser.TraceDumper):
@@ -671,16 +696,16 @@ class Interpreter(parser.TraceDumper):
def verbosity(self, level):
return self.options.verbosity >= level
def present(self, surface, description):
def present(self, surface, description, x=None, y=None, w=None, h=None):
if self.call_no < self.options.start:
return
if self.options.images:
filename = '%s_%04u.png' % (description, self.call_no)
save_image(filename, surface)
filename = '%04u_%s.png' % (self.call_no, description)
save_image(filename, surface, x, y, w, h)
else:
title = '%u. %s' % (self.call_no, description)
show_image(surface, title)
show_image(surface, title, x, y, w, h)
class Main(parser.Main):
@@ -690,6 +715,7 @@ class Main(parser.Main):
optparser.add_option("-q", "--quiet", action="store_const", const=0, dest="verbosity", help="no messages")
optparser.add_option("-v", "--verbose", action="count", dest="verbosity", default=1, help="increase verbosity level")
optparser.add_option("-i", "--images", action="store_true", dest="images", default=False, help="save images instead of showing them")
optparser.add_option("-a", "--all", action="store_true", dest="all", default=False, help="show depth, stencil, and transfers")
optparser.add_option("-s", "--step", action="store_true", dest="step", default=False, help="step trhough every draw")
optparser.add_option("-f", "--from", action="store", type="int", dest="start", default=0, help="from call no")
optparser.add_option("-t", "--to", action="store", type="int", dest="stop", default=0, help="until call no")

View File

@@ -46,6 +46,14 @@ for name, value in globals().items():
if name.startswith("PIPE_FORMAT_") and isinstance(value, int):
formats[value] = name
def is_depth_stencil_format(format):
# FIXME: make and use binding to pf_is_depth_stencil
return format in (
PIPE_FORMAT_Z32_UNORM,
PIPE_FORMAT_Z24S8_UNORM,
PIPE_FORMAT_Z24X8_UNORM,
PIPE_FORMAT_Z16_UNORM,
)
def make_image(width, height, rgba):
import Image

View File

@@ -99,7 +99,7 @@ def is_pot(n):
return n & (n - 1) == 0
class TextureTest(TestCase):
class TextureColorSampleTest(TestCase):
tags = (
'target',
@@ -286,6 +286,206 @@ class TextureTest(TestCase):
self.assert_rgba(cbuf, x, y, w, h, expected_rgba, 4.0/256, 0.85)
class TextureDepthSampleTest(TestCase):
tags = (
'target',
'format',
'width',
'height',
'depth',
'last_level',
'face',
'level',
'zslice',
)
def test(self):
dev = self.dev
target = self.target
format = self.format
width = self.width
height = self.height
depth = self.depth
last_level = self.last_level
face = self.face
level = self.level
zslice = self.zslice
tex_usage = PIPE_TEXTURE_USAGE_SAMPLER
geom_flags = 0
if width != height:
geom_flags |= PIPE_TEXTURE_GEOM_NON_SQUARE
if not is_pot(width) or not is_pot(height) or not is_pot(depth):
geom_flags |= PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO
if not dev.is_format_supported(format, target, tex_usage, geom_flags):
raise TestSkip
ctx = self.dev.context_create()
# disabled blending/masking
blend = Blend()
blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE
blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE
blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO
blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO
blend.colormask = PIPE_MASK_RGBA
ctx.set_blend(blend)
# depth/stencil/alpha
depth_stencil_alpha = DepthStencilAlpha()
depth_stencil_alpha.depth.enabled = 1
depth_stencil_alpha.depth.writemask = 1
depth_stencil_alpha.depth.func = PIPE_FUNC_LESS
ctx.set_depth_stencil_alpha(depth_stencil_alpha)
# rasterizer
rasterizer = Rasterizer()
rasterizer.front_winding = PIPE_WINDING_CW
rasterizer.cull_mode = PIPE_WINDING_NONE
rasterizer.bypass_vs_clip_and_viewport = 1
ctx.set_rasterizer(rasterizer)
# samplers
sampler = Sampler()
sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE
sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE
sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE
sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST
sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST
sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST
sampler.normalized_coords = 1
sampler.min_lod = 0
sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1
ctx.set_sampler(0, sampler)
# texture
texture = dev.texture_create(
target = target,
format = format,
width = width,
height = height,
depth = depth,
last_level = last_level,
tex_usage = tex_usage,
)
expected_rgba = FloatArray(height*width*4)
texture.get_surface(
face = face,
level = level,
zslice = zslice,
).sample_rgba(expected_rgba)
ctx.set_sampler_texture(0, texture)
# framebuffer
cbuf_tex = dev.texture_create(
PIPE_FORMAT_A8R8G8B8_UNORM,
width,
height,
tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET,
)
zsbuf_tex = dev.texture_create(
PIPE_FORMAT_Z24X8_UNORM,
width,
height,
tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET,
)
cbuf = cbuf_tex.get_surface()
zsbuf = zsbuf_tex.get_surface()
fb = Framebuffer()
fb.width = width
fb.height = height
fb.nr_cbufs = 1
fb.set_cbuf(0, cbuf)
fb.set_zsbuf(zsbuf)
ctx.set_framebuffer(fb)
rgba = FloatArray(4);
rgba[0] = 0.5
rgba[1] = 0.5
rgba[2] = 0.5
rgba[3] = 0.5
ctx.clear(PIPE_CLEAR_DEPTHSTENCIL, rgba, 1.0, 0)
del fb
# vertex shader
vs = Shader('''
VERT1.1
DCL IN[0], POSITION, CONSTANT
DCL IN[1], GENERIC, CONSTANT
DCL OUT[0], POSITION, CONSTANT
DCL OUT[1], GENERIC, CONSTANT
0:MOV OUT[0], IN[0]
1:MOV OUT[1], IN[1]
2:END
''')
#vs.dump()
ctx.set_vertex_shader(vs)
# fragment shader
op = {
PIPE_TEXTURE_1D: "1D",
PIPE_TEXTURE_2D: "2D",
PIPE_TEXTURE_3D: "3D",
PIPE_TEXTURE_CUBE: "CUBE",
}[target]
fs = Shader('''
FRAG1.1
DCL IN[0], GENERIC[0], LINEAR
DCL SAMP[0], CONSTANT
DCL OUT[0].z, POSITION
0:TEX OUT[0].z, IN[0], SAMP[0], %s
1:END
''' % op)
#fs.dump()
ctx.set_fragment_shader(fs)
nverts = 4
nattrs = 2
verts = FloatArray(nverts * nattrs * 4)
x = 0
y = 0
w, h = minify((width, height), level)
pos = [
[x, y],
[x+w, y],
[x+w, y+h],
[x, y+h],
]
tex = tex_coords(texture, face, level, zslice)
for i in range(0, 4):
j = 8*i
verts[j + 0] = pos[i][0] # x
verts[j + 1] = pos[i][1] # y
verts[j + 2] = 0.0 # z
verts[j + 3] = 1.0 # w
verts[j + 4] = tex[i][0] # s
verts[j + 5] = tex[i][1] # r
verts[j + 6] = tex[i][2] # q
verts[j + 7] = 1.0
ctx.draw_vertices(PIPE_PRIM_TRIANGLE_FAN,
nverts,
nattrs,
verts)
ctx.flush()
zsbuf = zsbuf_tex.get_surface()
self.assert_rgba(zsbuf, x, y, w, h, expected_rgba, 4.0/256, 0.85)
def main():
dev = Device()
@@ -297,18 +497,13 @@ def main():
PIPE_TEXTURE_3D,
]
formats = [
color_formats = [
PIPE_FORMAT_A8R8G8B8_UNORM,
PIPE_FORMAT_X8R8G8B8_UNORM,
#PIPE_FORMAT_A8R8G8B8_SRGB,
PIPE_FORMAT_R5G6B5_UNORM,
PIPE_FORMAT_A1R5G5B5_UNORM,
PIPE_FORMAT_A4R4G4B4_UNORM,
#PIPE_FORMAT_Z32_UNORM,
#PIPE_FORMAT_Z24S8_UNORM,
#PIPE_FORMAT_Z24X8_UNORM,
#PIPE_FORMAT_Z16_UNORM,
#PIPE_FORMAT_S8_UNORM,
PIPE_FORMAT_A8_UNORM,
PIPE_FORMAT_L8_UNORM,
PIPE_FORMAT_YCBCR,
@@ -318,6 +513,13 @@ def main():
#PIPE_FORMAT_DXT5_RGBA,
]
depth_formats = [
PIPE_FORMAT_Z32_UNORM,
PIPE_FORMAT_Z24S8_UNORM,
PIPE_FORMAT_Z24X8_UNORM,
PIPE_FORMAT_Z16_UNORM,
]
sizes = [64, 32, 16, 8, 4, 2, 1]
#sizes = [1020, 508, 252, 62, 30, 14, 6, 3]
#sizes = [64]
@@ -332,8 +534,8 @@ def main():
PIPE_TEX_FACE_NEG_Z,
]
for target in targets:
for format in formats:
for format in color_formats:
for target in targets:
for size in sizes:
if target == PIPE_TEXTURE_3D:
depth = size
@@ -347,7 +549,7 @@ def main():
for level in range(0, last_level + 1):
zslice = 0
while zslice < depth >> level:
test = TextureTest(
test = TextureColorSampleTest(
dev = dev,
target = target,
format = format,
@@ -361,6 +563,27 @@ def main():
)
suite.add_test(test)
zslice = (zslice + 1)*2 - 1
for format in depth_formats:
target = PIPE_TEXTURE_2D
depth = 1
face = 0
last_level = 0
level = 0
zslice = 0
for size in sizes:
test = TextureDepthSampleTest(
dev = dev,
target = target,
format = format,
width = size,
height = size,
depth = depth,
last_level = last_level,
face = face,
level = level,
zslice = zslice,
)
suite.add_test(test)
suite.run()

View File

@@ -54,7 +54,15 @@ DrvCreateLayerContext(
HDC hdc,
INT iLayerPlane )
{
return stw_create_layer_context( hdc, iLayerPlane );
DHGLRC r;
r = stw_create_layer_context( hdc, iLayerPlane );
if (DBG)
debug_printf( "%s( %p, %i ) = %u\n",
__FUNCTION__, hdc, iLayerPlane, r );
return r;
}
DHGLRC APIENTRY
@@ -68,7 +76,15 @@ BOOL APIENTRY
DrvDeleteContext(
DHGLRC dhglrc )
{
return stw_delete_context( dhglrc );
BOOL r;
r = stw_delete_context( dhglrc );
if (DBG)
debug_printf( "%s( %u ) = %u\n",
__FUNCTION__, dhglrc, r );
return r;
}
BOOL APIENTRY
@@ -126,7 +142,7 @@ DrvGetProcAddress(
r = stw_get_proc_address( lpszProc );
if (DBG)
debug_printf( "%s( \", __FUNCTION__%s\" ) = %p\n", lpszProc, r );
debug_printf( "%s( \"%s\" ) = %p\n", __FUNCTION__, lpszProc, r );
return r;
}
@@ -515,14 +531,16 @@ DrvSetContext(
DHGLRC dhglrc,
PFN_SETPROCTABLE pfnSetProcTable )
{
if (DBG)
debug_printf( "%s( 0x%p, %u, 0x%p )\n",
__FUNCTION__, hdc, dhglrc, pfnSetProcTable );
PGLCLTPROCTABLE r = (PGLCLTPROCTABLE)&cpt;
if (!stw_make_current( hdc, dhglrc ))
return NULL;
r = NULL;
return (GLCLTPROCTABLE *)&cpt;
if (DBG)
debug_printf( "%s( 0x%p, %u, 0x%p ) = %p\n",
__FUNCTION__, hdc, dhglrc, pfnSetProcTable, r );
return r;
}
int APIENTRY

View File

@@ -47,6 +47,23 @@
#include "stw_context.h"
#include "stw_tls.h"
static INLINE struct stw_context *
stw_context(GLcontext *glctx)
{
if(!glctx)
return NULL;
assert(glctx->DriverCtx);
return (struct stw_context *)glctx->DriverCtx;
}
static INLINE struct stw_context *
stw_current_context(void)
{
GET_CURRENT_CONTEXT( glctx );
return stw_context(glctx);
}
BOOL
stw_copy_context(
UINT_PTR hglrcSrc,
@@ -90,7 +107,7 @@ stw_share_lists(
ctx2 = stw_lookup_context_locked( hglrc2 );
if (ctx1 && ctx2 &&
ctx1->pfi == ctx2->pfi) {
ctx1->iPixelFormat == ctx2->iPixelFormat) {
ret = _mesa_share_state(ctx2->st->ctx, ctx1->st->ctx);
}
@@ -99,57 +116,49 @@ stw_share_lists(
return ret;
}
static void
stw_viewport(GLcontext * glctx, GLint x, GLint y,
GLsizei width, GLsizei height)
{
struct stw_context *ctx = (struct stw_context *)glctx->DriverCtx;
struct stw_framebuffer *fb;
fb = stw_framebuffer_from_hdc( ctx->hdc );
if(fb)
stw_framebuffer_update(fb);
}
UINT_PTR
stw_create_layer_context(
HDC hdc,
int iLayerPlane )
{
uint pfi;
const struct stw_pixelformat_info *pf = NULL;
int iPixelFormat;
const struct stw_pixelformat_info *pfi;
GLvisual visual;
struct stw_context *ctx = NULL;
GLvisual *visual = NULL;
struct pipe_screen *screen = NULL;
struct pipe_context *pipe = NULL;
if(!stw_dev)
return 0;
if (iLayerPlane != 0)
return 0;
pfi = stw_pixelformat_get( hdc );
if (pfi == 0)
iPixelFormat = GetPixelFormat(hdc);
if(!iPixelFormat)
return 0;
pf = stw_pixelformat_get_info( pfi - 1 );
pfi = stw_pixelformat_get_info( iPixelFormat - 1 );
stw_pixelformat_visual(&visual, pfi);
ctx = CALLOC_STRUCT( stw_context );
if (ctx == NULL)
goto no_ctx;
ctx->hdc = hdc;
ctx->color_bits = GetDeviceCaps( ctx->hdc, BITSPIXEL );
/* Create visual based on flags
*/
visual = _mesa_create_visual(
(pf->pfd.iPixelType == PFD_TYPE_RGBA) ? GL_TRUE : GL_FALSE,
(pf->pfd.dwFlags & PFD_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE,
(pf->pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE,
pf->pfd.cRedBits,
pf->pfd.cGreenBits,
pf->pfd.cBlueBits,
pf->pfd.cAlphaBits,
(pf->pfd.iPixelType == PFD_TYPE_COLORINDEX) ? pf->pfd.cColorBits : 0,
pf->pfd.cDepthBits,
pf->pfd.cStencilBits,
pf->pfd.cAccumRedBits,
pf->pfd.cAccumGreenBits,
pf->pfd.cAccumBlueBits,
pf->pfd.cAccumAlphaBits,
pf->numSamples );
if (visual == NULL)
goto no_visual;
ctx->iPixelFormat = iPixelFormat;
screen = stw_dev->screen;
@@ -169,15 +178,16 @@ stw_create_layer_context(
pipe = trace_context_create(stw_dev->screen, pipe);
#endif
/* pass to stw_flush_frontbuffer as context_private */
assert(!pipe->priv);
pipe->priv = hdc;
ctx->st = st_create_context( pipe, visual, NULL );
ctx->st = st_create_context( pipe, &visual, NULL );
if (ctx->st == NULL)
goto no_st_ctx;
ctx->st->ctx->DriverCtx = ctx;
ctx->pfi = pf;
ctx->st->ctx->Driver.Viewport = stw_viewport;
pipe_mutex_lock( stw_dev->mutex );
ctx->hglrc = handle_table_add(stw_dev->ctx_table, ctx);
@@ -193,9 +203,7 @@ no_hglrc:
no_st_ctx:
pipe->destroy( pipe );
no_pipe:
_mesa_destroy_visual( visual );
no_visual:
FREE( ctx );
FREE(ctx);
no_ctx:
return 0;
}
@@ -216,22 +224,12 @@ stw_delete_context(
pipe_mutex_unlock( stw_dev->mutex );
if (ctx) {
GLcontext *glctx = ctx->st->ctx;
GET_CURRENT_CONTEXT( glcurctx );
struct stw_framebuffer *fb;
/* Unbind current if deleting current context.
*/
if (glcurctx == glctx)
struct stw_context *curctx = stw_current_context();
/* Unbind current if deleting current context. */
if (curctx == ctx)
st_make_current( NULL, NULL, NULL );
fb = stw_framebuffer_from_hdc( ctx->hdc );
if (fb)
stw_framebuffer_destroy( fb );
if (WindowFromDC( ctx->hdc ) != NULL)
ReleaseDC( WindowFromDC( ctx->hdc ), ctx->hdc );
st_destroy_context(ctx->st);
FREE(ctx);
@@ -261,13 +259,8 @@ stw_release_context(
* current for this thread. We should check that and return False
* if not the case.
*/
{
GLcontext *glctx = ctx->st->ctx;
GET_CURRENT_CONTEXT( glcurctx );
if (glcurctx != glctx)
return FALSE;
}
if (ctx != stw_current_context())
return FALSE;
if (stw_make_current( NULL, 0 ) == FALSE)
return FALSE;
@@ -275,46 +268,13 @@ stw_release_context(
return TRUE;
}
/* Find the width and height of the window named by hdc.
*/
static void
stw_get_window_size( HDC hdc, GLuint *pwidth, GLuint *pheight )
{
GLuint width, height;
HWND hwnd;
hwnd = WindowFromDC( hdc );
if (hwnd) {
RECT rect;
GetClientRect( hwnd, &rect );
width = rect.right - rect.left;
height = rect.bottom - rect.top;
}
else {
width = GetDeviceCaps( hdc, HORZRES );
height = GetDeviceCaps( hdc, VERTRES );
}
if(width < 1)
width = 1;
if(height < 1)
height = 1;
*pwidth = width;
*pheight = height;
}
UINT_PTR
stw_get_current_context( void )
{
GET_CURRENT_CONTEXT( glcurctx );
struct stw_context *ctx;
if(!glcurctx)
return 0;
ctx = (struct stw_context *)glcurctx->DriverCtx;
assert(ctx);
ctx = stw_current_context();
if(!ctx)
return 0;
@@ -324,14 +284,9 @@ stw_get_current_context( void )
HDC
stw_get_current_dc( void )
{
GET_CURRENT_CONTEXT( glcurctx );
struct stw_context *ctx;
if(!glcurctx)
return NULL;
ctx = (struct stw_context *)glcurctx->DriverCtx;
assert(ctx);
ctx = stw_current_context();
if(!ctx)
return NULL;
@@ -343,67 +298,75 @@ stw_make_current(
HDC hdc,
UINT_PTR hglrc )
{
struct stw_context *curctx;
struct stw_context *ctx;
GET_CURRENT_CONTEXT( glcurctx );
struct stw_framebuffer *fb;
GLuint width = 0;
GLuint height = 0;
struct stw_context *curctx = NULL;
if (!stw_dev)
return FALSE;
goto fail;
pipe_mutex_lock( stw_dev->mutex );
ctx = stw_lookup_context_locked( hglrc );
pipe_mutex_unlock( stw_dev->mutex );
if (glcurctx != NULL) {
curctx = (struct stw_context *) glcurctx->DriverCtx;
if (curctx != ctx)
st_flush(glcurctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
curctx = stw_current_context();
if (curctx != NULL) {
if (curctx->hglrc != hglrc)
st_flush(curctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
/* Return if already current. */
if (curctx->hglrc == hglrc && curctx->hdc == hdc) {
ctx = curctx;
fb = stw_framebuffer_from_hdc( hdc );
goto success;
}
}
if (hdc == NULL || hglrc == 0) {
st_make_current( NULL, NULL, NULL );
return TRUE;
return st_make_current( NULL, NULL, NULL );
}
/* Return if already current.
*/
if (glcurctx != NULL) {
if (curctx != NULL && curctx == ctx && ctx->hdc == hdc)
return TRUE;
pipe_mutex_lock( stw_dev->mutex );
ctx = stw_lookup_context_locked( hglrc );
if(!ctx)
goto fail;
fb = stw_framebuffer_from_hdc_locked( hdc );
if(!fb) {
/* Applications should call SetPixelFormat before creating a context,
* but not all do, and the opengl32 runtime seems to use a default pixel
* format in some cases, so we must create a framebuffer for those here
*/
int iPixelFormat = GetPixelFormat(hdc);
if(iPixelFormat)
fb = stw_framebuffer_create_locked( hdc, iPixelFormat );
if(!fb)
goto fail;
}
pipe_mutex_unlock( stw_dev->mutex );
fb = stw_framebuffer_from_hdc( hdc );
if(fb->iPixelFormat != ctx->iPixelFormat)
goto fail;
if (hdc != NULL)
stw_get_window_size( hdc, &width, &height );
/* Lazy allocation of the frame buffer */
if(!stw_framebuffer_allocate(fb))
goto fail;
/* Lazy creation of stw_framebuffers.
*/
if (fb == NULL && ctx != NULL && hdc != NULL) {
GLvisual *visual = &ctx->st->ctx->Visual;
fb = stw_framebuffer_create( hdc, visual, ctx->pfi, width, height );
if (fb == NULL)
return FALSE;
}
if (ctx && fb) {
pipe_mutex_lock( fb->mutex );
st_make_current( ctx->st, fb->stfb, fb->stfb );
st_resize_framebuffer( fb->stfb, width, height );
pipe_mutex_unlock( fb->mutex );
ctx->hdc = hdc;
ctx->st->pipe->priv = hdc;
}
else {
/* Detach */
st_make_current( NULL, NULL, NULL );
}
/* Bind the new framebuffer */
ctx->hdc = hdc;
/* pass to stw_flush_frontbuffer as context_private */
ctx->st->pipe->priv = hdc;
if(!st_make_current( ctx->st, fb->stfb, fb->stfb ))
goto fail;
success:
assert(fb);
if(fb)
stw_framebuffer_update(fb);
return TRUE;
fail:
st_make_current( NULL, NULL, NULL );
return FALSE;
}

View File

@@ -31,15 +31,13 @@
#include <windows.h>
struct st_context;
struct stw_pixelformat_info;
struct stw_context
{
struct st_context *st;
UINT_PTR hglrc;
int iPixelFormat;
HDC hdc;
DWORD color_bits;
const struct stw_pixelformat_info *pfi;
};
#endif /* STW_CONTEXT_H */

View File

@@ -30,6 +30,7 @@
#include "glapi/glthread.h"
#include "util/u_debug.h"
#include "pipe/p_screen.h"
#include "state_tracker/st_public.h"
#ifdef DEBUG
#include "trace/tr_screen.h"
@@ -57,21 +58,45 @@ struct stw_device *stw_dev = NULL;
* stw_winsys::flush_front_buffer.
*/
static void
st_flush_frontbuffer(struct pipe_screen *screen,
stw_flush_frontbuffer(struct pipe_screen *screen,
struct pipe_surface *surface,
void *context_private )
{
const struct stw_winsys *stw_winsys = stw_dev->stw_winsys;
HDC hdc = (HDC)context_private;
struct stw_framebuffer *fb;
#ifdef DEBUG
if(stw_dev->trace_running) {
screen = trace_screen(screen)->screen;
surface = trace_surface(surface)->surface;
}
fb = stw_framebuffer_from_hdc( hdc );
/* fb can be NULL if window was destroyed already */
if (fb) {
pipe_mutex_lock( fb->mutex );
#if DEBUG
{
struct pipe_surface *surface2;
if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_FRONT_LEFT, &surface2 ))
assert(0);
else
assert(surface2 == surface);
}
#endif
#ifdef DEBUG
if(stw_dev->trace_running) {
screen = trace_screen(screen)->screen;
surface = trace_surface(surface)->surface;
}
#endif
}
stw_winsys->flush_frontbuffer(screen, surface, hdc);
if(fb) {
stw_framebuffer_update(fb);
pipe_mutex_unlock( fb->mutex );
}
}
@@ -111,7 +136,7 @@ stw_init(const struct stw_winsys *stw_winsys)
stw_dev->screen = screen;
#endif
stw_dev->screen->flush_frontbuffer = st_flush_frontbuffer;
stw_dev->screen->flush_frontbuffer = &stw_flush_frontbuffer;
pipe_mutex_init( stw_dev->mutex );
@@ -133,20 +158,13 @@ error1:
boolean
stw_init_thread(void)
{
if (!stw_tls_init_thread())
return FALSE;
if (!stw_framebuffer_init_thread())
return FALSE;
return TRUE;
return stw_tls_init_thread();
}
void
stw_cleanup_thread(void)
{
stw_framebuffer_cleanup_thread();
stw_tls_cleanup_thread();
}
@@ -173,6 +191,8 @@ stw_cleanup(void)
}
pipe_mutex_unlock( stw_dev->mutex );
stw_framebuffer_cleanup();
pipe_mutex_destroy( stw_dev->mutex );
stw_dev->screen->destroy(stw_dev->screen);

View File

@@ -45,11 +45,46 @@
#include "stw_tls.h"
static INLINE struct stw_framebuffer *
stw_framebuffer_from_hwnd_locked(
HWND hwnd )
{
struct stw_framebuffer *fb;
for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
if (fb->hWnd == hwnd)
break;
return fb;
}
static INLINE void
stw_framebuffer_destroy_locked(
struct stw_framebuffer *fb )
{
struct stw_framebuffer **link;
link = &stw_dev->fb_head;
while (*link != fb)
link = &(*link)->next;
assert(*link);
*link = fb->next;
fb->next = NULL;
st_unreference_framebuffer(fb->stfb);
pipe_mutex_destroy( fb->mutex );
FREE( fb );
}
/**
* @sa http://msdn.microsoft.com/en-us/library/ms644975(VS.85).aspx
* @sa http://msdn.microsoft.com/en-us/library/ms644960(VS.85).aspx
*/
static LRESULT CALLBACK
LRESULT CALLBACK
stw_call_window_proc(
int nCode,
WPARAM wParam,
@@ -69,113 +104,212 @@ stw_call_window_proc(
struct stw_framebuffer *fb;
pipe_mutex_lock( stw_dev->mutex );
for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
if (fb->hWnd == pParams->hwnd)
break;
fb = stw_framebuffer_from_hwnd_locked( pParams->hwnd );
pipe_mutex_unlock( stw_dev->mutex );
if(fb) {
unsigned width = LOWORD( pParams->lParam );
unsigned height = HIWORD( pParams->lParam );
/* FIXME: The mesa statetracker makes the assumptions that only
* one context is using the framebuffer, and that that context is the
* current one. However neither holds true, as WGL allows more than
* one context to be bound to the same drawable, and this function can
* be called from any thread.
*/
pipe_mutex_lock( fb->mutex );
st_resize_framebuffer( fb->stfb, width, height );
fb->must_resize = TRUE;
fb->width = width;
fb->height = height;
pipe_mutex_unlock( fb->mutex );
}
}
if (pParams->message == WM_DESTROY) {
struct stw_framebuffer *fb;
pipe_mutex_lock( stw_dev->mutex );
fb = stw_framebuffer_from_hwnd_locked( pParams->hwnd );
if(fb)
stw_framebuffer_destroy_locked(fb);
pipe_mutex_unlock( stw_dev->mutex );
}
return CallNextHookEx(tls_data->hCallWndProcHook, nCode, wParam, lParam);
}
/* Create a new framebuffer object which will correspond to the given HDC.
static void
stw_framebuffer_get_size( struct stw_framebuffer *fb )
{
unsigned width, height;
RECT rect;
assert(fb->hWnd);
GetClientRect( fb->hWnd, &rect );
width = rect.right - rect.left;
height = rect.bottom - rect.top;
if(width < 1)
width = 1;
if(height < 1)
height = 1;
if(width != fb->width || height != fb->height) {
fb->must_resize = TRUE;
fb->width = width;
fb->height = height;
}
}
/**
* Create a new framebuffer object which will correspond to the given HDC.
*/
struct stw_framebuffer *
stw_framebuffer_create(
stw_framebuffer_create_locked(
HDC hdc,
GLvisual *visual,
const struct stw_pixelformat_info *pfi,
GLuint width,
GLuint height )
int iPixelFormat )
{
enum pipe_format colorFormat, depthFormat, stencilFormat;
HWND hWnd;
struct stw_framebuffer *fb;
const struct stw_pixelformat_info *pfi;
colorFormat = pfi->color_format;
/* We only support drawing to a window. */
hWnd = WindowFromDC( hdc );
if(!hWnd)
return NULL;
assert(pf_layout( pfi->depth_stencil_format ) == PIPE_FORMAT_LAYOUT_RGBAZS );
if(pf_get_component_bits( pfi->depth_stencil_format, PIPE_FORMAT_COMP_Z ))
depthFormat = pfi->depth_stencil_format;
else
depthFormat = PIPE_FORMAT_NONE;
if(pf_get_component_bits( pfi->depth_stencil_format, PIPE_FORMAT_COMP_S ))
stencilFormat = pfi->depth_stencil_format;
else
stencilFormat = PIPE_FORMAT_NONE;
fb = CALLOC_STRUCT( stw_framebuffer );
if (fb == NULL)
return NULL;
fb->hDC = hdc;
fb->hWnd = WindowFromDC( hdc );
fb->hWnd = hWnd;
fb->iPixelFormat = iPixelFormat;
fb->pfi = pfi = stw_pixelformat_get_info( iPixelFormat - 1 );
stw_pixelformat_visual(&fb->visual, pfi);
stw_framebuffer_get_size(fb);
pipe_mutex_init( fb->mutex );
fb->stfb = st_create_framebuffer(
visual,
colorFormat,
depthFormat,
stencilFormat,
width,
height,
(void *) fb );
if(!fb->stfb) {
FREE(fb);
return NULL;
}
pipe_mutex_lock( stw_dev->mutex );
fb->next = stw_dev->fb_head;
stw_dev->fb_head = fb;
pipe_mutex_unlock( stw_dev->mutex );
return fb;
}
void
stw_framebuffer_destroy(
struct stw_framebuffer *fb )
BOOL
stw_framebuffer_allocate(
struct stw_framebuffer *fb)
{
struct stw_framebuffer **link;
pipe_mutex_lock( fb->mutex );
if(!fb->stfb) {
const struct stw_pixelformat_info *pfi = fb->pfi;
enum pipe_format colorFormat, depthFormat, stencilFormat;
colorFormat = pfi->color_format;
assert(pf_layout( pfi->depth_stencil_format ) == PIPE_FORMAT_LAYOUT_RGBAZS );
if(pf_get_component_bits( pfi->depth_stencil_format, PIPE_FORMAT_COMP_Z ))
depthFormat = pfi->depth_stencil_format;
else
depthFormat = PIPE_FORMAT_NONE;
if(pf_get_component_bits( pfi->depth_stencil_format, PIPE_FORMAT_COMP_S ))
stencilFormat = pfi->depth_stencil_format;
else
stencilFormat = PIPE_FORMAT_NONE;
assert(fb->must_resize);
assert(fb->width);
assert(fb->height);
fb->stfb = st_create_framebuffer(
&fb->visual,
colorFormat,
depthFormat,
stencilFormat,
fb->width,
fb->height,
(void *) fb );
// to notify the context
fb->must_resize = TRUE;
}
pipe_mutex_unlock( fb->mutex );
return fb->stfb ? TRUE : FALSE;
}
/**
* Update the framebuffer's size if necessary.
*/
void
stw_framebuffer_update(
struct stw_framebuffer *fb)
{
assert(fb->stfb);
assert(fb->height);
assert(fb->width);
/* XXX: It would be nice to avoid checking the size again -- in theory
* stw_call_window_proc would have cought the resize and stored the right
* size already, but unfortunately threads created before the DllMain is
* called don't get a DLL_THREAD_ATTACH notification, and there is no way
* to know of their existing without using the not very portable PSAPI.
*/
stw_framebuffer_get_size(fb);
if(fb->must_resize) {
st_resize_framebuffer(fb->stfb, fb->width, fb->height);
fb->must_resize = FALSE;
}
}
void
stw_framebuffer_cleanup( void )
{
struct stw_framebuffer *fb;
struct stw_framebuffer *next;
pipe_mutex_lock( stw_dev->mutex );
link = &stw_dev->fb_head;
while (link && *link != fb)
link = &(*link)->next;
assert(*link);
if (link)
*link = fb->next;
fb->next = NULL;
fb = stw_dev->fb_head;
while (fb) {
next = fb->next;
stw_framebuffer_destroy_locked(fb);
fb = next;
}
stw_dev->fb_head = NULL;
pipe_mutex_unlock( stw_dev->mutex );
st_unreference_framebuffer(fb->stfb);
pipe_mutex_destroy( fb->mutex );
FREE( fb );
}
/**
* Given an hdc, return the corresponding stw_framebuffer.
*/
struct stw_framebuffer *
stw_framebuffer_from_hdc_locked(
HDC hdc )
{
struct stw_framebuffer *fb;
for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
if (fb->hDC == hdc)
break;
return fb;
}
/**
* Given an hdc, return the corresponding stw_framebuffer.
*/
@@ -186,15 +320,69 @@ stw_framebuffer_from_hdc(
struct stw_framebuffer *fb;
pipe_mutex_lock( stw_dev->mutex );
for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
if (fb->hDC == hdc)
break;
fb = stw_framebuffer_from_hdc_locked(hdc);
pipe_mutex_unlock( stw_dev->mutex );
return fb;
}
BOOL
stw_pixelformat_set(
HDC hdc,
int iPixelFormat )
{
uint count;
uint index;
struct stw_framebuffer *fb;
index = (uint) iPixelFormat - 1;
count = stw_pixelformat_get_extended_count();
if (index >= count)
return FALSE;
pipe_mutex_lock( stw_dev->mutex );
fb = stw_framebuffer_from_hdc_locked(hdc);
if(fb) {
/* SetPixelFormat must be called only once */
pipe_mutex_unlock( stw_dev->mutex );
return FALSE;
}
fb = stw_framebuffer_create_locked(hdc, iPixelFormat);
if(!fb) {
pipe_mutex_unlock( stw_dev->mutex );
return FALSE;
}
pipe_mutex_unlock( stw_dev->mutex );
/* Some applications mistakenly use the undocumented wglSetPixelFormat
* function instead of SetPixelFormat, so we call SetPixelFormat here to
* avoid opengl32.dll's wglCreateContext to fail */
if (GetPixelFormat(hdc) == 0) {
SetPixelFormat(hdc, iPixelFormat, NULL);
}
return TRUE;
}
int
stw_pixelformat_get(
HDC hdc )
{
struct stw_framebuffer *fb;
fb = stw_framebuffer_from_hdc(hdc);
if(!fb)
return 0;
return fb->iPixelFormat;
}
BOOL
stw_swap_buffers(
HDC hdc )
@@ -207,6 +395,9 @@ stw_swap_buffers(
if (fb == NULL)
return FALSE;
if (!(fb->pfi->pfd.dwFlags & PFD_DOUBLEBUFFER))
return TRUE;
pipe_mutex_lock( fb->mutex );
/* If we're swapping the buffer associated with the current context
@@ -231,6 +422,8 @@ stw_swap_buffers(
stw_dev->stw_winsys->flush_frontbuffer( screen, surface, hdc );
stw_framebuffer_update(fb);
pipe_mutex_unlock( fb->mutex );
return TRUE;
@@ -247,38 +440,3 @@ stw_swap_layer_buffers(
return FALSE;
}
boolean
stw_framebuffer_init_thread(void)
{
struct stw_tls_data *tls_data;
tls_data = stw_tls_get_data();
if(!tls_data)
return FALSE;
tls_data->hCallWndProcHook = SetWindowsHookEx(WH_CALLWNDPROC,
stw_call_window_proc,
NULL,
GetCurrentThreadId());
if(tls_data->hCallWndProcHook == NULL)
return FALSE;
return TRUE;
}
void
stw_framebuffer_cleanup_thread(void)
{
struct stw_tls_data *tls_data;
tls_data = stw_tls_get_data();
if(!tls_data)
return;
if(tls_data->hCallWndProcHook) {
UnhookWindowsHookEx(tls_data->hCallWndProcHook);
tls_data->hCallWndProcHook = NULL;
}
}

View File

@@ -44,33 +44,44 @@ struct stw_framebuffer
HDC hDC;
HWND hWnd;
int iPixelFormat;
const struct stw_pixelformat_info *pfi;
GLvisual visual;
pipe_mutex mutex;
struct st_framebuffer *stfb;
/* FIXME: Make this work for multiple contexts bound to the same framebuffer */
boolean must_resize;
unsigned width;
unsigned height;
/** This is protected by stw_device::mutex, not the mutex above */
struct stw_framebuffer *next;
};
struct stw_framebuffer *
stw_framebuffer_create(
stw_framebuffer_create_locked(
HDC hdc,
GLvisual *visual,
const struct stw_pixelformat_info *pfi,
GLuint width,
GLuint height );
int iPixelFormat );
BOOL
stw_framebuffer_allocate(
struct stw_framebuffer *fb );
void
stw_framebuffer_destroy(
struct stw_framebuffer *fb );
stw_framebuffer_update(
struct stw_framebuffer *fb);
void
stw_framebuffer_cleanup(void);
struct stw_framebuffer *
stw_framebuffer_from_hdc_locked(
HDC hdc );
struct stw_framebuffer *
stw_framebuffer_from_hdc(
HDC hdc );
boolean
stw_framebuffer_init_thread(void);
void
stw_framebuffer_cleanup_thread(void);
#endif /* STW_FRAMEBUFFER_H */

Some files were not shown because too many files have changed in this diff Show More