diff options
| author | John Schoenick <[email protected]> | 2015-09-09 18:35:41 -0700 |
|---|---|---|
| committer | John Schoenick <[email protected]> | 2015-09-09 18:35:41 -0700 |
| commit | 0d8dceea4310fde5706b3ce1c70609d72a38efdf (patch) | |
| tree | c831ef32c2c801a5c5a80401736b52c7b5a528ec /mp/src/public/togl/linuxwin/dxabstract.h | |
| parent | Updated the SDK with the latest code from the TF and HL2 branches. (diff) | |
| download | source-sdk-2013-master.tar.xz source-sdk-2013-master.zip | |
Diffstat (limited to 'mp/src/public/togl/linuxwin/dxabstract.h')
| -rw-r--r-- | mp/src/public/togl/linuxwin/dxabstract.h | 73 |
1 files changed, 52 insertions, 21 deletions
diff --git a/mp/src/public/togl/linuxwin/dxabstract.h b/mp/src/public/togl/linuxwin/dxabstract.h index 0e367329..b601e78d 100644 --- a/mp/src/public/togl/linuxwin/dxabstract.h +++ b/mp/src/public/togl/linuxwin/dxabstract.h @@ -1,4 +1,26 @@ //========= Copyright Valve Corporation, All rights reserved. ============// +// TOGL CODE LICENSE +// +// Copyright 2011-2014 Valve Corporation +// All Rights Reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 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. // // dxabstract.h // @@ -18,8 +40,10 @@ #define IUNKNOWN_ALLOC_SPEW 0 #define IUNKNOWN_ALLOC_SPEW_MARK_ALL 0 + TOGL_INTERFACE void toglGetClientRect( VD3DHWND hWnd, RECT *destRect ); + struct TOGL_CLASS IUnknown { int m_refcount[2]; @@ -138,7 +162,6 @@ struct TOGL_CLASS IDirect3DBaseTexture9 : public IDirect3DResource9 // "A T { D3DSURFACE_DESC m_descZero; // desc of top level. CGLMTex *m_tex; // a CGLMTex can represent all forms of tex - int m_srgbFlipCount; virtual ~IDirect3DBaseTexture9(); D3DRESOURCETYPE TOGLMETHODCALLTYPE GetType(); @@ -270,7 +293,8 @@ struct TOGL_CLASS IDirect3DPixelShader9 : public IDirect3DResource9 //was IUnkno uint m_pixHighWater; // count of active constant slots referenced by shader. uint m_pixSamplerMask; // (1<<n) mask of samplers referemnced by this pixel shader // this can help FlushSamplers avoid SRGB flipping on textures not being referenced... - uint m_pixSamplerTypes; // SAMPLER_TYPE_2D, etc. + uint m_pixSamplerTypes; // SAMPLER_TYPE_2D, etc. + uint m_pixFragDataMask; // (1<<n) mask of gl_FragData[n] referenced by this pixel shader virtual ~IDirect3DPixelShader9(); }; @@ -404,6 +428,7 @@ struct TOGL_CLASS IDirect3DDevice9 : public IUnknown // HRESULT TOGLMETHODCALLTYPE Reset(D3DPRESENT_PARAMETERS* pPresentationParameters); HRESULT TOGLMETHODCALLTYPE SetViewport(CONST D3DVIEWPORT9* pViewport); + HRESULT TOGLMETHODCALLTYPE GetViewport(D3DVIEWPORT9* pViewport); HRESULT TOGLMETHODCALLTYPE BeginScene(); HRESULT TOGLMETHODCALLTYPE Clear(DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil); HRESULT TOGLMETHODCALLTYPE EndScene(); @@ -463,6 +488,7 @@ struct TOGL_CLASS IDirect3DDevice9 : public IUnknown // POSIX only - preheating for a specific vertex/pixel shader pair - trigger GLSL link inside GLM HRESULT TOGLMETHODCALLTYPE LinkShaderPair( IDirect3DVertexShader9* vs, IDirect3DPixelShader9* ps ); + HRESULT TOGLMETHODCALLTYPE ValidateShaderPair( IDirect3DVertexShader9* vs, IDirect3DPixelShader9* ps ); HRESULT TOGLMETHODCALLTYPE QueryShaderPair( int index, GLMShaderPairInfo *infoOut ); // vertex buffers @@ -484,7 +510,7 @@ struct TOGL_CLASS IDirect3DDevice9 : public IUnknown FORCEINLINE HRESULT TOGLMETHODCALLTYPE SetIndices(IDirect3DIndexBuffer9* pIndexData); HRESULT TOGLMETHODCALLTYPE SetIndicesNonInline(IDirect3DIndexBuffer9* pIndexData); - + // State management. FORCEINLINE HRESULT TOGLMETHODCALLTYPE SetRenderStateInline(D3DRENDERSTATETYPE State,DWORD Value); FORCEINLINE HRESULT TOGLMETHODCALLTYPE SetRenderStateConstInline(D3DRENDERSTATETYPE State,DWORD Value); @@ -495,7 +521,13 @@ struct TOGL_CLASS IDirect3DDevice9 : public IUnknown FORCEINLINE void TOGLMETHODCALLTYPE SetSamplerStates(DWORD Sampler, DWORD AddressU, DWORD AddressV, DWORD AddressW, DWORD MinFilter, DWORD MagFilter, DWORD MipFilter ); void TOGLMETHODCALLTYPE SetSamplerStatesNonInline(DWORD Sampler, DWORD AddressU, DWORD AddressV, DWORD AddressW, DWORD MinFilter, DWORD MagFilter, DWORD MipFilter ); - + +#ifdef OSX + // required for 10.6 support + HRESULT TOGLMETHODCALLTYPE FlushIndexBindings(void); // push index buffer (set index ptr) + HRESULT TOGLMETHODCALLTYPE FlushVertexBindings(uint baseVertexIndex); // push vertex streams (set attrib ptrs) +#endif + // Draw. HRESULT TOGLMETHODCALLTYPE DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount); HRESULT TOGLMETHODCALLTYPE DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount); @@ -514,6 +546,7 @@ struct TOGL_CLASS IDirect3DDevice9 : public IUnknown HRESULT TOGLMETHODCALLTYPE SetLight(DWORD Index,CONST D3DLIGHT9*); void TOGLMETHODCALLTYPE SetGammaRamp(UINT iSwapChain,DWORD Flags,CONST D3DGAMMARAMP* pRamp); + void TOGLMETHODCALLTYPE SaveGLState(); void TOGLMETHODCALLTYPE RestoreGLState(); @@ -544,7 +577,6 @@ struct TOGL_CLASS IDirect3DDevice9 : public IUnknown private: IDirect3DDevice9( const IDirect3DDevice9& ); IDirect3DDevice9& operator= ( const IDirect3DDevice9& ); - // Flushing changes to GL void FlushClipPlaneEquation(); void InitStates(); @@ -567,8 +599,9 @@ private: // Member variables DWORD m_nValidMarker; - - IDirect3DDevice9Params m_params; // mirror of the creation inputs +public: + IDirect3DDevice9Params m_params; // mirror of the creation inputs +private: // D3D flavor stuff IDirect3DSurface9 *m_pRenderTargets[4]; @@ -586,8 +619,8 @@ private: IDirect3DVertexShader9 *m_vertexShader; // Set by SetVertexShader... IDirect3DPixelShader9 *m_pixelShader; // Set by SetPixelShader... - IDirect3DBaseTexture9 *m_textures[16]; // set by SetTexture... NULL if stage inactive - D3DSamplerDesc m_samplers[16]; // set by SetSamplerState.. + IDirect3DBaseTexture9 *m_textures[GLM_SAMPLER_COUNT]; // set by SetTexture... NULL if stage inactive + // GLM flavor stuff GLMContext *m_ctx; CGLMFBOMap *m_pFBOs; @@ -673,7 +706,7 @@ private: bool m_FogEnable; // not really pushed to GL, just latched here // samplers - GLMTexSamplingParams m_samplers[ 16 ]; + //GLMTexSamplingParams m_samplers[GLM_SAMPLER_COUNT]; } gl; #if GL_BATCH_PERF_ANALYSIS @@ -710,7 +743,7 @@ FORCEINLINE HRESULT TOGLMETHODCALLTYPE IDirect3DDevice9::SetSamplerState( DWORD return SetSamplerStateNonInline( Sampler, Type, Value ); #else Assert( GetCurrentOwnerThreadId() == ThreadGetCurrentId() ); - Assert( Sampler < 16 ); + Assert( Sampler < GLM_SAMPLER_COUNT ); m_ctx->SetSamplerDirty( Sampler ); @@ -747,7 +780,7 @@ FORCEINLINE HRESULT TOGLMETHODCALLTYPE IDirect3DDevice9::SetSamplerState( DWORD m_ctx->SetSamplerMaxAnisotropy( Sampler, Value); break; case D3DSAMP_SRGBTEXTURE: - m_samplers[ Sampler ].m_srgb = Value; + //m_samplers[ Sampler ].m_srgb = Value; m_ctx->SetSamplerSRGBTexture(Sampler, Value); break; case D3DSAMP_SHADOWFILTER: @@ -768,7 +801,7 @@ FORCEINLINE void TOGLMETHODCALLTYPE IDirect3DDevice9::SetSamplerStates( SetSamplerStatesNonInline( Sampler, AddressU, AddressV, AddressW, MinFilter, MagFilter, MipFilter ); #else Assert( GetCurrentOwnerThreadId() == ThreadGetCurrentId() ); - Assert( Sampler < 16); + Assert( Sampler < GLM_SAMPLER_COUNT); m_ctx->SetSamplerDirty( Sampler ); @@ -782,6 +815,7 @@ FORCEINLINE HRESULT TOGLMETHODCALLTYPE IDirect3DDevice9::SetTexture(DWORD Stage, return SetTextureNonInline( Stage, pTexture ); #else Assert( GetCurrentOwnerThreadId() == ThreadGetCurrentId() ); + Assert( Stage < GLM_SAMPLER_COUNT ); m_textures[Stage] = pTexture; m_ctx->SetSamplerTex( Stage, pTexture ? pTexture->m_tex : NULL ); return S_OK; @@ -809,13 +843,10 @@ FORCEINLINE GLenum D3DBlendOperationToGL( DWORD operation ) switch (operation) { case D3DBLENDOP_ADD : return GL_FUNC_ADD; // The result is the destination added to the source. Result = Source + Destination - - /* not covered by dxabstract.h.. - case D3DBLENDOP_SUBTRACT : return GL_FUNC_SUBTRACT; // The result is the destination subtracted from to the source. Result = Source - Destination - case D3DBLENDOP_REVSUBTRACT : return GL_FUNC_REVERSE_SUBTRACT; // The result is the source subtracted from the destination. Result = Destination - Source - case D3DBLENDOP_MIN : return GL_MIN; // The result is the minimum of the source and destination. Result = MIN(Source, Destination) - case D3DBLENDOP_MAX : return GL_MAX; // The result is the maximum of the source and destination. Result = MAX(Source, Destination) - */ + case D3DBLENDOP_SUBTRACT : return GL_FUNC_SUBTRACT; // The result is the destination subtracted from to the source. Result = Source - Destination + case D3DBLENDOP_REVSUBTRACT : return GL_FUNC_REVERSE_SUBTRACT; // The result is the source subtracted from the destination. Result = Destination - Source + case D3DBLENDOP_MIN : return GL_MIN; // The result is the minimum of the source and destination. Result = MIN(Source, Destination) + case D3DBLENDOP_MAX : return GL_MAX; // The result is the maximum of the source and destination. Result = MAX(Source, Destination) default: DXABSTRACT_BREAK_ON_ERROR(); return 0xFFFFFFFF; @@ -1174,7 +1205,7 @@ FORCEINLINE HRESULT TOGLMETHODCALLTYPE IDirect3DDevice9::SetStreamSource(UINT St // OK, we are being given the stride, we don't need to calc it.. GLMPRINTF(("-X- IDirect3DDevice9::SetStreamSource setting stream #%d to D3D buf %p (GL name %d); offset %d, stride %d", StreamNumber, pStreamData, (pStreamData) ? pStreamData->m_vtxBuffer->m_name: -1, OffsetInBytes, Stride)); - + if ( !pStreamData ) { OffsetInBytes = 0; |