diff --git a/changes.txt b/changes.txt index 74833877..808328dd 100644 --- a/changes.txt +++ b/changes.txt @@ -9,6 +9,9 @@ Changes in ogl-es (not yet released - will be merged with trunk at some point) -------------------------- Changes in 1.9 (not yet released) +- Add getActiveColor functions to IGUIStaticText and IGUIButton (get currently used color). +- Add IGUIEnvironment::addToDeletionQueue to allow save removal of gui elements while iterating over them (like the same named function in ISceneManager). +- IGUIEnvironment::drawAll has now a parameter to allow disabling automatic resize to screensize. Makes it easier to use partial screens with full alignment support. - No longer try to set WM_QUIT when using an external Window on Win32. Thx @Marko Mahnic for the patch (https://sourceforge.net/p/irrlicht/bugs/449) - ply meshloader now also supports textures with uv-labels named texture_u/texture_v. @@ -22,15 +25,16 @@ Changes in 1.9 (not yet released) - Improvements to B3D writer for speed, readability and handling of low framerate animations. Thanks @JLouisB for the patch (For more info, see: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=2&t=50067&start=15) - Add another render pass ESNRP_GUI which is drawn last and is p.E. useful for rendering gui nodes in the scenemanager. -- BurningVideo: 0.51 +- BurningVideo: 0.52 - 10 year anniversary update - Lighting model reworked. moved to eyespace like openGL. [Specular Highlights, Fog, Sphere/Reflection Map] - increased internal s4DVertex to support 4 Textures and 4 Colors [switchable] - Textures are handled as sRGB during Mipmap Generation. More accurate, less visual disruption - - 2D is drawn as 3D like hardware drivers. [switchable]. enables viewport scaling, material2D + - 2D is drawn as 3D like hardware drivers. [switchable]. enables viewport scaling, material2D, scissor - Texture Spatial Resolution Limiting working. [lower memory consumption,SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE] - NormalMap for 1 Light accurate. still all lights are accumulated - SuperTuxKart 8.0.1 playable + - Internal Backbuffer Scaling and Interlacing - Known Problems - Depthbuffer range not equal to Hardware Drivers. Problems with Orthographic Stencil Shadows - Triangle MipMap Selection. Wrong for TextureAtlas and Billboards @@ -309,6 +313,7 @@ Changes in 1.9 (not yet released) -------------------------- Changes in 1.8.5 + - Update libpng to 1.6.37 (from 1.6.23) - Fix CIrrDeviceSDL::getVideoModeList which didn't return video modes before. Thx @kas1e for report and patch. - CIrrDeviceMacOSX now sets the SEvent.MouseInput Shift and Control values on mouse events like the other devices. Thanks @ Zero King for patch (#321) - isWindowFocused in IrrDeviceSDL device now returns the input focus like the other devices. Before it was returning a mouse-over-window state. diff --git a/examples/Demo/CMainMenu.cpp b/examples/Demo/CMainMenu.cpp index 432c8727..f67d9f3c 100644 --- a/examples/Demo/CMainMenu.cpp +++ b/examples/Demo/CMainMenu.cpp @@ -72,24 +72,14 @@ bool CMainMenu::run() // add list box gui::IGUIListBox* box = guienv->addListBox(core::rect(10,10,220,120), optTab, 1); - - const wchar_t* const names[] = - {L"Software Renderer", L"Burning's Video", - L"Direct3D 8", L"Direct3D 9", L"OpenGL 1.x-4.x", - L"OpenGL-ES 1.x", L"OpenGL-ES 2.x"}; for (u32 i=1; iaddItem(names[i-1]); - } - - switch (driverType ) - { - case video::EDT_OPENGL: selected = 0; break; - case video::EDT_DIRECT3D9: selected = 1; break; - case video::EDT_BURNINGSVIDEO: selected = 2; break; - case video::EDT_SOFTWARE: selected = 3; break; - default: break; + { + box->addItem(core::stringw(video::DRIVER_TYPE_NAMES[i]).c_str()); + if ( driverType == video::E_DRIVER_TYPE(i) ) + selected = box->getItemCount()-1; + } } box->setSelected(selected); diff --git a/include/IGUIButton.h b/include/IGUIButton.h index 1976adaf..88eb97bb 100644 --- a/include/IGUIButton.h +++ b/include/IGUIButton.h @@ -139,6 +139,10 @@ namespace gui /** \return: The override color */ virtual video::SColor getOverrideColor(void) const = 0; + //! Gets the currently used text color + /** Either a skin-color for the current state or the override color */ + virtual video::SColor getActiveColor() const = 0; + //! Sets if the button text should use the override color or the color in the gui skin. /** \param enable: If set to true, the override color, which can be set with IGUIStaticText::setOverrideColor is used, otherwise the diff --git a/include/IGUIEnvironment.h b/include/IGUIEnvironment.h index 695b41b8..4bd3db87 100644 --- a/include/IGUIEnvironment.h +++ b/include/IGUIEnvironment.h @@ -74,7 +74,9 @@ class IGUIEnvironment : public virtual IReferenceCounted public: //! Draws all gui elements by traversing the GUI environment starting at the root node. - virtual void drawAll() = 0; + /** \param When true ensure the GuiEnvironment (aka the RootGUIElement) has the same size as the current driver screensize. + Can be set to false to control that size yourself, p.E when not the full size should be used for UI. */ + virtual void drawAll(bool useScreenSize=true) = 0; //! Sets the focus to an element. /** Causes a EGET_ELEMENT_FOCUS_LOST event followed by a @@ -621,10 +623,10 @@ public: virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)=0; //! writes an element - virtual void writeGUIElement(io::IXMLWriter* writer, IGUIElement* node) =0; + virtual void writeGUIElement(io::IXMLWriter* writer, IGUIElement* element) =0; //! reads an element - virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* node) =0; + virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* element) =0; //! Find the next element which would be selected when pressing the tab-key /** If you set the focus for the result you can manually force focus-changes like they @@ -644,6 +646,17 @@ public: //! Get the way the gui does handle focus changes /** \returns A bitmask which is a combination of ::EFOCUS_FLAG flags.*/ virtual u32 getFocusBehavior() const = 0; + + //! Adds a IGUIElement to deletion queue. + /** Queued elements will be removed at the end of each drawAll call. + Or latest in the destructor of the GUIEnvironment. + This can be used to allow an element removing itself safely in a function + iterating over gui elements, like an overloaded IGUIElement::draw or + IGUIElement::OnPostRender function. + Note that in general just calling IGUIElement::remove() is enough. + Unless you create your own GUI elements removing themselves you won't need it. + \param element: Element to remove */ + virtual void addToDeletionQueue(IGUIElement* element) = 0; }; diff --git a/include/IGUIStaticText.h b/include/IGUIStaticText.h index beb8f597..33db281e 100644 --- a/include/IGUIStaticText.h +++ b/include/IGUIStaticText.h @@ -51,6 +51,10 @@ namespace gui /** \return: The override color */ virtual video::SColor getOverrideColor(void) const = 0; + //! Gets the currently used text color + /** Either a skin-color for the current state or the override color */ + virtual video::SColor getActiveColor() const = 0; + //! Sets if the static text should use the override color or the color in the gui skin. /** \param enable: If set to true, the override color, which can be set with IGUIStaticText::setOverrideColor is used, otherwise the diff --git a/include/IImage.h b/include/IImage.h index 09c40f42..3d4d5fa0 100644 --- a/include/IImage.h +++ b/include/IImage.h @@ -29,6 +29,9 @@ public: //! constructor IImage(ECOLOR_FORMAT format, const core::dimension2d& size, bool deleteMemory) : Format(format), Size(size), Data(0), MipMapsData(0), BytesPerPixel(0), Pitch(0), DeleteMemory(deleteMemory), DeleteMipMapsMemory(false) +#if defined(IRRLICHT_sRGB) + ,Format_sRGB(1) +#endif { BytesPerPixel = getBitsPerPixelFromFormat(Format) / 8; Pitch = BytesPerPixel * Size.Width; @@ -50,6 +53,18 @@ public: return Format; } +#if defined(IRRLICHT_sRGB) + //! Texture is linear/sRGB (should be part of ColorFormat: default yes) + int get_sRGB() const + { + return Format_sRGB; + } + void set_sRGB(int val) + { + Format_sRGB = val; + } +#endif + //! Returns width and height of image data. const core::dimension2d& getDimension() const { @@ -534,6 +549,22 @@ public: return false; } +#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) + static bool isRenderTargetOnlyFormat(const ECOLOR_FORMAT format) + { + switch (format) + { + case ECF_A1R5G5B5: + case ECF_R5G6B5: + case ECF_R8G8B8: + case ECF_A8R8G8B8: + return false; + default: + return true; + } + } +#endif + protected: ECOLOR_FORMAT Format; core::dimension2d Size; @@ -548,8 +579,12 @@ protected: bool DeleteMipMapsMemory; core::irrAllocator Allocator; +#if defined(IRRLICHT_sRGB) + int Format_sRGB; +#endif }; + } // end namespace video } // end namespace irr diff --git a/source/Irrlicht/CBurningShader_Raster_Reference.cpp b/source/Irrlicht/CBurningShader_Raster_Reference.cpp index 3d9dacc6..45858a07 100644 --- a/source/Irrlicht/CBurningShader_Raster_Reference.cpp +++ b/source/Irrlicht/CBurningShader_Raster_Reference.cpp @@ -698,7 +698,7 @@ REALINLINE void CBurningShader_Raster_Reference::scanline2() return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); const f32 subPixel = ( (f32) pShader.xStart ) - line.x[0]; // store slopes in endpoint, and correct first pixel @@ -722,8 +722,8 @@ REALINLINE void CBurningShader_Raster_Reference::scanline2() } SOFTWARE_DRIVER_2_CLIPCHECK_REF; - pShader.dst = (tVideoSample*) ( (u8*) RenderTarget->getData() + ( line.y * RenderTarget->getPitch() ) + ( pShader.xStart << VIDEO_SAMPLE_GRANULARITY ) ); - pShader.z = (fp24*) ( (u8*) DepthBuffer->lock() + ( line.y * DepthBuffer->getPitch() ) + ( pShader.xStart << VIDEO_SAMPLE_GRANULARITY ) ); + pShader.dst = (tVideoSample*) ( (u8*) RenderTarget->getData() + ( line.y * RenderTarget->getPitch() ) + ( pShader.xStart << SOFTWARE_DRIVER_2_RENDERTARGET_GRANULARITY) ); + pShader.z = (fp24*) ( (u8*) DepthBuffer->lock() + ( line.y * DepthBuffer->getPitch() ) + ( pShader.xStart << SOFTWARE_DRIVER_2_RENDERTARGET_GRANULARITY) ); for ( pShader.i = 0; pShader.i <= pShader.dx; ++pShader.i ) { @@ -764,10 +764,10 @@ REALINLINE void CBurningShader_Raster_Reference::scanline () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); // search z-buffer for first not occulled pixel - pShader.z = (fp24*) ( (u8*) DepthBuffer->lock() + ( line.y * DepthBuffer->getPitch() ) + ( pShader.xStart << VIDEO_SAMPLE_GRANULARITY ) ); + pShader.z = (fp24*) ( (u8*) DepthBuffer->lock() + ( line.y * DepthBuffer->getPitch() ) + ( pShader.xStart << SOFTWARE_DRIVER_2_RENDERTARGET_GRANULARITY) ); // subTexel const f32 subPixel = ( (f32) pShader.xStart ) - line.x[0]; @@ -807,7 +807,7 @@ REALINLINE void CBurningShader_Raster_Reference::scanline () line.w[0] = a; line.w[1] = b; - pShader.dst = (tVideoSample*) ( (u8*) RenderTarget->getData() + ( line.y * RenderTarget->getPitch() ) + ( pShader.xStart << VIDEO_SAMPLE_GRANULARITY ) ); + pShader.dst = (tVideoSample*) ( (u8*) RenderTarget->getData() + ( line.y * RenderTarget->getPitch() ) + ( pShader.xStart << SOFTWARE_DRIVER_2_RENDERTARGET_GRANULARITY) ); a = (f32) pShader.i + subPixel; @@ -863,9 +863,9 @@ void CBurningShader_Raster_Reference::drawTriangle(const s4DVertex* burning_rest // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero2( c->Pos.y - a->Pos.y ); - scan.invDeltaY[1] = reciprocal_zero2( b->Pos.y - a->Pos.y ); - scan.invDeltaY[2] = reciprocal_zero2( c->Pos.y - b->Pos.y ); + scan.invDeltaY[0] = fill_step_y( c->Pos.y - a->Pos.y ); + scan.invDeltaY[1] = fill_step_y( b->Pos.y - a->Pos.y ); + scan.invDeltaY[2] = fill_step_y( c->Pos.y - b->Pos.y ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; @@ -959,7 +959,7 @@ void CBurningShader_Raster_Reference::drawTriangle(const s4DVertex* burning_rest } // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.w[scan.left] = scan.w[0]; @@ -1076,7 +1076,7 @@ void CBurningShader_Raster_Reference::drawTriangle(const s4DVertex* burning_rest } // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.w[scan.left] = scan.w[0]; diff --git a/source/Irrlicht/CDepthBuffer.cpp b/source/Irrlicht/CDepthBuffer.cpp index eed72345..ec05bdab 100644 --- a/source/Irrlicht/CDepthBuffer.cpp +++ b/source/Irrlicht/CDepthBuffer.cpp @@ -40,7 +40,7 @@ CDepthBuffer::~CDepthBuffer() //! clears the zbuffer -void CDepthBuffer::clear(f32 value) +void CDepthBuffer::clear(f32 value, interlaced_control interlaced) { ieee754 zMaxValue; @@ -50,7 +50,7 @@ void CDepthBuffer::clear(f32 value) zMaxValue.f = value; #endif - memset32 ( Buffer, zMaxValue.u, TotalSize ); + memset32_interlaced(Buffer, zMaxValue.u, Pitch, Size.Height, interlaced); } @@ -66,9 +66,10 @@ void CDepthBuffer::setSize(const core::dimension2d& size) delete [] Buffer; Pitch = size.Width * sizeof ( fp24 ); - TotalSize = Pitch * size.Height; + size_t TotalSize = Pitch * size.Height; Buffer = new u8[align_next(TotalSize,16)]; - clear (); + + clear( 1.f, interlace_disabled()); } @@ -107,7 +108,7 @@ CStencilBuffer::~CStencilBuffer() //! clears the buffer -void CStencilBuffer::clear(u8 value) +void CStencilBuffer::clear(u32 value, const interlaced_control interlaced) { u32 set = value; if (Bit == 8) @@ -115,7 +116,7 @@ void CStencilBuffer::clear(u8 value) set |= set << 8; set |= set << 16; } - memset32 ( Buffer, set, TotalSize ); + memset32_interlaced ( Buffer, set, Pitch,Size.Height,interlaced ); } @@ -131,9 +132,10 @@ void CStencilBuffer::setSize(const core::dimension2d& size) delete [] Buffer; Pitch = size.Width * sizeof (tStencilSample); - TotalSize = Pitch * size.Height; + size_t TotalSize = Pitch * size.Height; Buffer = new u8[align_next(TotalSize,16)]; - clear (); + + clear(0, interlace_disabled()); } diff --git a/source/Irrlicht/CDepthBuffer.h b/source/Irrlicht/CDepthBuffer.h index aa9c33de..609f7a73 100644 --- a/source/Irrlicht/CDepthBuffer.h +++ b/source/Irrlicht/CDepthBuffer.h @@ -23,7 +23,7 @@ namespace video virtual ~CDepthBuffer(); //! clears the zbuffer - virtual void clear(f32 value=1.f) _IRR_OVERRIDE_; + virtual void clear(f32 value, const interlaced_control interlaced) _IRR_OVERRIDE_; //! sets the new size of the zbuffer virtual void setSize(const core::dimension2d& size) _IRR_OVERRIDE_; @@ -45,7 +45,6 @@ namespace video u8* Buffer; core::dimension2d Size; - u32 TotalSize; u32 Pitch; }; @@ -61,7 +60,7 @@ namespace video virtual ~CStencilBuffer(); //! clears the zbuffer - virtual void clear(u8 value=0) _IRR_OVERRIDE_; + virtual void clear(u32 value, const interlaced_control interlaced) _IRR_OVERRIDE_; //! sets the new size of the zbuffer virtual void setSize(const core::dimension2d& size) _IRR_OVERRIDE_; @@ -82,7 +81,6 @@ namespace video private: u8* Buffer; core::dimension2d Size; - u32 TotalSize; u32 Pitch; u32 Bit; }; diff --git a/source/Irrlicht/CGUIButton.cpp b/source/Irrlicht/CGUIButton.cpp index 895e31a2..95d2b37d 100644 --- a/source/Irrlicht/CGUIButton.cpp +++ b/source/Irrlicht/CGUIButton.cpp @@ -327,7 +327,7 @@ void CGUIButton::draw() if (font) font->draw(Text.c_str(), rect, - OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), + getActiveColor(), true, true, &AbsoluteClippingRect); } @@ -466,6 +466,16 @@ video::SColor CGUIButton::getOverrideColor() const return OverrideColor; } +irr::video::SColor CGUIButton::getActiveColor() const +{ + if ( OverrideColorEnabled ) + return OverrideColor; + IGUISkin* skin = Environment->getSkin(); + if (skin) + return OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT); + return OverrideColor; +} + void CGUIButton::enableOverrideColor(bool enable) { OverrideColorEnabled = enable; diff --git a/source/Irrlicht/CGUIButton.h b/source/Irrlicht/CGUIButton.h index ab383db7..88ca8f44 100644 --- a/source/Irrlicht/CGUIButton.h +++ b/source/Irrlicht/CGUIButton.h @@ -50,6 +50,9 @@ namespace gui //! Gets the override color virtual video::SColor getOverrideColor(void) const _IRR_OVERRIDE_; + //! Gets the currently used text color + virtual video::SColor getActiveColor() const _IRR_OVERRIDE_; + //! Sets if the button text should use the override color or the color in the gui skin. virtual void enableOverrideColor(bool enable) _IRR_OVERRIDE_; diff --git a/source/Irrlicht/CGUIContextMenu.cpp b/source/Irrlicht/CGUIContextMenu.cpp index 3a6484be..d38ceeda 100644 --- a/source/Irrlicht/CGUIContextMenu.cpp +++ b/source/Irrlicht/CGUIContextMenu.cpp @@ -136,10 +136,10 @@ void CGUIContextMenu::setSubMenu(u32 index, CGUIContextMenu* menu) Items[index].SubMenu->drop(); Items[index].SubMenu = menu; - menu->setVisible(false); - if (Items[index].SubMenu) + if (menu) { + menu->setVisible(false); menu->AllowFocus = false; if ( Environment->getFocus() == menu ) { diff --git a/source/Irrlicht/CGUIEnvironment.cpp b/source/Irrlicht/CGUIEnvironment.cpp index e29195b2..e970d640 100644 --- a/source/Irrlicht/CGUIEnvironment.cpp +++ b/source/Irrlicht/CGUIEnvironment.cpp @@ -101,6 +101,8 @@ CGUIEnvironment::CGUIEnvironment(io::IFileSystem* fs, video::IVideoDriver* drive //! destructor CGUIEnvironment::~CGUIEnvironment() { + clearDeletionQueue(); + if ( HoveredNoSubelement && HoveredNoSubelement != this ) { HoveredNoSubelement->drop(); @@ -191,19 +193,18 @@ void CGUIEnvironment::loadBuiltInFont() //! draws all gui elements -void CGUIEnvironment::drawAll() +void CGUIEnvironment::drawAll(bool useScreenSize) { - if (Driver) + if (useScreenSize && Driver) { core::dimension2d dim(Driver->getScreenSize()); if (AbsoluteRect.LowerRightCorner.X != dim.Width || - AbsoluteRect.LowerRightCorner.Y != dim.Height) + AbsoluteRect.UpperLeftCorner.X != 0 || + AbsoluteRect.LowerRightCorner.Y != dim.Height || + AbsoluteRect.UpperLeftCorner.Y != 0 + ) { - // resize gui environment - DesiredRect.LowerRightCorner = dim; - AbsoluteClippingRect = DesiredRect; - AbsoluteRect = DesiredRect; - updateAbsolutePosition(); + setRelativePosition(core::recti(0,0,dim.Width, dim.Height)); } } @@ -213,6 +214,8 @@ void CGUIEnvironment::drawAll() draw(); OnPostRender ( os::Timer::getTime () ); + + clearDeletionQueue(); } @@ -471,6 +474,28 @@ void CGUIEnvironment::OnPostRender( u32 time ) IGUIElement::OnPostRender ( time ); } +void CGUIEnvironment::addToDeletionQueue(IGUIElement* element) +{ + if (!element) + return; + + element->grab(); + DeletionQueue.push_back(element); +} + +void CGUIEnvironment::clearDeletionQueue() +{ + if (DeletionQueue.empty()) + return; + + for (u32 i=0; iremove(); + DeletionQueue[i]->drop(); + } + + DeletionQueue.clear(); +} // void CGUIEnvironment::updateHoveredElement(core::position2d mousePos) diff --git a/source/Irrlicht/CGUIEnvironment.h b/source/Irrlicht/CGUIEnvironment.h index 58b7f545..e87e236f 100644 --- a/source/Irrlicht/CGUIEnvironment.h +++ b/source/Irrlicht/CGUIEnvironment.h @@ -31,7 +31,7 @@ public: virtual ~CGUIEnvironment(); //! draws all gui elements - virtual void drawAll() _IRR_OVERRIDE_; + virtual void drawAll(bool useScreenSize) _IRR_OVERRIDE_; //! returns the current video driver virtual video::IVideoDriver* getVideoDriver() const _IRR_OVERRIDE_; @@ -269,8 +269,14 @@ public: //! Get the way the gui does handle focus changes virtual u32 getFocusBehavior() const _IRR_OVERRIDE_; + //! Adds a IGUIElement to deletion queue. + virtual void addToDeletionQueue(IGUIElement* element) _IRR_OVERRIDE_; + private: + //! clears the deletion queue + void clearDeletionQueue(); + void updateHoveredElement(core::position2d mousePos); void loadBuiltInFont(); @@ -322,6 +328,8 @@ private: IEventReceiver* UserReceiver; IOSOperator* Operator; u32 FocusFlags; + core::array DeletionQueue; + static const io::path DefaultFontName; }; diff --git a/source/Irrlicht/CGUIFont.cpp b/source/Irrlicht/CGUIFont.cpp index 08579244..0fa82981 100644 --- a/source/Irrlicht/CGUIFont.cpp +++ b/source/Irrlicht/CGUIFont.cpp @@ -203,17 +203,15 @@ void CGUIFont::setMaxHeight() return; MaxHeight = 0; - s32 t; core::array< core::rect >& p = SpriteBank->getPositions(); for (u32 i=0; iMaxHeight) MaxHeight = t; } - } void CGUIFont::pushTextureCreationFlags(bool(&flags)[3]) diff --git a/source/Irrlicht/CGUIStaticText.cpp b/source/Irrlicht/CGUIStaticText.cpp index fc26a1a9..086c357d 100644 --- a/source/Irrlicht/CGUIStaticText.cpp +++ b/source/Irrlicht/CGUIStaticText.cpp @@ -99,8 +99,8 @@ void CGUIStaticText::draw() font->getDimension(Text.c_str()).Width; } - font->draw(Text.c_str(), frameRect, - OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), + font->draw(Text.c_str(), frameRect, + getActiveColor(), HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, (RestrainTextInside ? &AbsoluteClippingRect : NULL)); } else @@ -129,7 +129,7 @@ void CGUIStaticText::draw() } font->draw(BrokenText[i].c_str(), r, - OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), + getActiveColor(), HAlign == EGUIA_CENTER, false, (RestrainTextInside ? &AbsoluteClippingRect : NULL)); r.LowerRightCorner.Y += height; @@ -254,6 +254,16 @@ video::SColor CGUIStaticText::getOverrideColor() const } +irr::video::SColor CGUIStaticText::getActiveColor() const +{ + if ( OverrideColorEnabled ) + return OverrideColor; + IGUISkin* skin = Environment->getSkin(); + if (skin) + return OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT); + return OverrideColor; +} + //! Sets if the static text should use the override color or the //! color in the gui skin. void CGUIStaticText::enableOverrideColor(bool enable) diff --git a/source/Irrlicht/CGUIStaticText.h b/source/Irrlicht/CGUIStaticText.h index 7ca74019..b7fbf738 100644 --- a/source/Irrlicht/CGUIStaticText.h +++ b/source/Irrlicht/CGUIStaticText.h @@ -66,6 +66,9 @@ namespace gui //! Gets the override color virtual video::SColor getOverrideColor() const _IRR_OVERRIDE_; + //! Gets the currently used text color + virtual video::SColor getActiveColor() const _IRR_OVERRIDE_; + //! Sets if the static text should use the override color or the //! color in the gui skin. virtual void enableOverrideColor(bool enable) _IRR_OVERRIDE_; diff --git a/source/Irrlicht/CGUITreeView.cpp b/source/Irrlicht/CGUITreeView.cpp index f6d7743a..b348a791 100644 --- a/source/Irrlicht/CGUITreeView.cpp +++ b/source/Irrlicht/CGUITreeView.cpp @@ -264,9 +264,7 @@ IGUITreeViewNode* CGUITreeViewNode::getNextSibling() const IGUITreeViewNode* CGUITreeViewNode::getNextVisible() const { IGUITreeViewNode* next = 0; - IGUITreeViewNode* node = 0; - - node = const_cast( this ); + const IGUITreeViewNode* node = this; if( node->getExpanded() && node->hasChildren() ) { @@ -756,10 +754,7 @@ bool CGUITreeView::OnEvent( const SEvent &event ) void CGUITreeView::mouseAction( s32 xpos, s32 ypos, bool onlyHover /*= false*/ ) { IGUITreeViewNode* oldSelected = Selected; - IGUITreeViewNode* hitNode = 0; s32 selIdx=-1; - s32 n; - IGUITreeViewNode* node; SEvent event; event.EventType = EET_GUI_EVENT; @@ -776,9 +771,9 @@ void CGUITreeView::mouseAction( s32 xpos, s32 ypos, bool onlyHover /*= false*/ ) selIdx = ( ( ypos - 1 ) + scrollBarVPos ) / ItemHeight; } - hitNode = 0; - node = Root->getFirstChild(); - n = 0; + IGUITreeViewNode* hitNode = 0; + IGUITreeViewNode* node = Root->getFirstChild(); + s32 n = 0; while( node ) { if( selIdx == n ) @@ -1026,7 +1021,7 @@ void CGUITreeView::draw() iconWidth += ImageList->getImageSize().Width + 3; textRect.UpperLeftCorner.X += ImageList->getImageSize().Width + 3; } - else if( ( IconFont && reinterpret_cast( node )->Icon.size() ) + else if( ( IconFont && static_cast( node )->Icon.size() ) && ( ( ImageLeftOfIcon && n == 1 ) || ( !ImageLeftOfIcon && n == 0 ) ) ) { diff --git a/source/Irrlicht/CNullDriver.cpp b/source/Irrlicht/CNullDriver.cpp index 23110e33..87a51df4 100644 --- a/source/Irrlicht/CNullDriver.cpp +++ b/source/Irrlicht/CNullDriver.cpp @@ -1076,7 +1076,7 @@ const wchar_t* CNullDriver::getName() const //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do -//! this: Frist, draw all geometry. Then use this method, to draw the shadow +//! this: First, draw all geometry. Then use this method, to draw the shadow //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. void CNullDriver::drawStencilShadowVolume(const core::array& triangles, bool zfail, u32 debugDataVisible) { diff --git a/source/Irrlicht/CNullDriver.h b/source/Irrlicht/CNullDriver.h index ebd700de..11191661 100644 --- a/source/Irrlicht/CNullDriver.h +++ b/source/Irrlicht/CNullDriver.h @@ -288,7 +288,7 @@ namespace video virtual void addExternalImageWriter(IImageWriter* writer) _IRR_OVERRIDE_; //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do - //! this: Frist, draw all geometry. Then use this method, to draw the shadow + //! this: First, draw all geometry. Then use this method, to draw the shadow //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. virtual void drawStencilShadowVolume(const core::array& triangles, bool zfail=true, u32 debugDataVisible=0) _IRR_OVERRIDE_; diff --git a/source/Irrlicht/CSoftwareDriver2.cpp b/source/Irrlicht/CSoftwareDriver2.cpp index 666c9849..605b15b4 100644 --- a/source/Irrlicht/CSoftwareDriver2.cpp +++ b/source/Irrlicht/CSoftwareDriver2.cpp @@ -39,25 +39,25 @@ bool mat44_transposed_inverse(irr::core::CMatrix4& out, const irr::core::CMat d = 1.0 / d; T* burning_restrict o = out.pointer(); - o[0] = (T)(d*(m[5] * (m[10] * m[15] - m[11] * m[14]) + m[6] * (m[11] * m[13] - m[9] * m[15]) + m[7] * (m[9] * m[14] - m[10] * m[13]))); - o[4] = (T)(d*(m[9] * (m[2] * m[15] - m[3] * m[14]) + m[10] * (m[3] * m[13] - m[1] * m[15]) + m[11] * (m[1] * m[14] - m[2] * m[13]))); - o[8] = (T)(d*(m[13] * (m[2] * m[7] - m[3] * m[6]) + m[14] * (m[3] * m[5] - m[1] * m[7]) + m[15] * (m[1] * m[6] - m[2] * m[5]))); - o[12] = (T)(d*(m[1] * (m[7] * m[10] - m[6] * m[11]) + m[2] * (m[5] * m[11] - m[7] * m[9]) + m[3] * (m[6] * m[9] - m[5] * m[10]))); + o[0] = (T)(d * (m[5] * (m[10] * m[15] - m[11] * m[14]) + m[6] * (m[11] * m[13] - m[9] * m[15]) + m[7] * (m[9] * m[14] - m[10] * m[13]))); + o[4] = (T)(d * (m[9] * (m[2] * m[15] - m[3] * m[14]) + m[10] * (m[3] * m[13] - m[1] * m[15]) + m[11] * (m[1] * m[14] - m[2] * m[13]))); + o[8] = (T)(d * (m[13] * (m[2] * m[7] - m[3] * m[6]) + m[14] * (m[3] * m[5] - m[1] * m[7]) + m[15] * (m[1] * m[6] - m[2] * m[5]))); + o[12] = (T)(d * (m[1] * (m[7] * m[10] - m[6] * m[11]) + m[2] * (m[5] * m[11] - m[7] * m[9]) + m[3] * (m[6] * m[9] - m[5] * m[10]))); - o[1] = (T)(d*(m[6] * (m[8] * m[15] - m[11] * m[12]) + m[7] * (m[10] * m[12] - m[8] * m[14]) + m[4] * (m[11] * m[14] - m[10] * m[15]))); - o[5] = (T)(d*(m[10] * (m[0] * m[15] - m[3] * m[12]) + m[11] * (m[2] * m[12] - m[0] * m[14]) + m[8] * (m[3] * m[14] - m[2] * m[15]))); - o[9] = (T)(d*(m[14] * (m[0] * m[7] - m[3] * m[4]) + m[15] * (m[2] * m[4] - m[0] * m[6]) + m[12] * (m[3] * m[6] - m[2] * m[7]))); - o[13] = (T)(d*(m[2] * (m[7] * m[8] - m[4] * m[11]) + m[3] * (m[4] * m[10] - m[6] * m[8]) + m[0] * (m[6] * m[11] - m[7] * m[10]))); + o[1] = (T)(d * (m[6] * (m[8] * m[15] - m[11] * m[12]) + m[7] * (m[10] * m[12] - m[8] * m[14]) + m[4] * (m[11] * m[14] - m[10] * m[15]))); + o[5] = (T)(d * (m[10] * (m[0] * m[15] - m[3] * m[12]) + m[11] * (m[2] * m[12] - m[0] * m[14]) + m[8] * (m[3] * m[14] - m[2] * m[15]))); + o[9] = (T)(d * (m[14] * (m[0] * m[7] - m[3] * m[4]) + m[15] * (m[2] * m[4] - m[0] * m[6]) + m[12] * (m[3] * m[6] - m[2] * m[7]))); + o[13] = (T)(d * (m[2] * (m[7] * m[8] - m[4] * m[11]) + m[3] * (m[4] * m[10] - m[6] * m[8]) + m[0] * (m[6] * m[11] - m[7] * m[10]))); - o[2] = (T)(d*(m[7] * (m[8] * m[13] - m[9] * m[12]) + m[4] * (m[9] * m[15] - m[11] * m[13]) + m[5] * (m[11] * m[12] - m[8] * m[15]))); - o[6] = (T)(d*(m[11] * (m[0] * m[13] - m[1] * m[12]) + m[8] * (m[1] * m[15] - m[3] * m[13]) + m[9] * (m[3] * m[12] - m[0] * m[15]))); - o[10] = (T)(d*(m[15] * (m[0] * m[5] - m[1] * m[4]) + m[12] * (m[1] * m[7] - m[3] * m[5]) + m[13] * (m[3] * m[4] - m[0] * m[7]))); - o[14] = (T)(d*(m[3] * (m[5] * m[8] - m[4] * m[9]) + m[0] * (m[7] * m[9] - m[5] * m[11]) + m[1] * (m[4] * m[11] - m[7] * m[8]))); + o[2] = (T)(d * (m[7] * (m[8] * m[13] - m[9] * m[12]) + m[4] * (m[9] * m[15] - m[11] * m[13]) + m[5] * (m[11] * m[12] - m[8] * m[15]))); + o[6] = (T)(d * (m[11] * (m[0] * m[13] - m[1] * m[12]) + m[8] * (m[1] * m[15] - m[3] * m[13]) + m[9] * (m[3] * m[12] - m[0] * m[15]))); + o[10] = (T)(d * (m[15] * (m[0] * m[5] - m[1] * m[4]) + m[12] * (m[1] * m[7] - m[3] * m[5]) + m[13] * (m[3] * m[4] - m[0] * m[7]))); + o[14] = (T)(d * (m[3] * (m[5] * m[8] - m[4] * m[9]) + m[0] * (m[7] * m[9] - m[5] * m[11]) + m[1] * (m[4] * m[11] - m[7] * m[8]))); - o[3] = (T)(d*(m[4] * (m[10] * m[13] - m[9] * m[14]) + m[5] * (m[8] * m[14] - m[10] * m[12]) + m[6] * (m[9] * m[12] - m[8] * m[13]))); - o[7] = (T)(d*(m[8] * (m[2] * m[13] - m[1] * m[14]) + m[9] * (m[0] * m[14] - m[2] * m[12]) + m[10] * (m[1] * m[12] - m[0] * m[13]))); - o[11] = (T)(d*(m[12] * (m[2] * m[5] - m[1] * m[6]) + m[13] * (m[0] * m[6] - m[2] * m[4]) + m[14] * (m[1] * m[4] - m[0] * m[5]))); - o[15] = (T)(d*(m[0] * (m[5] * m[10] - m[6] * m[9]) + m[1] * (m[6] * m[8] - m[4] * m[10]) + m[2] * (m[4] * m[9] - m[5] * m[8]))); + o[3] = (T)(d * (m[4] * (m[10] * m[13] - m[9] * m[14]) + m[5] * (m[8] * m[14] - m[10] * m[12]) + m[6] * (m[9] * m[12] - m[8] * m[13]))); + o[7] = (T)(d * (m[8] * (m[2] * m[13] - m[1] * m[14]) + m[9] * (m[0] * m[14] - m[2] * m[12]) + m[10] * (m[1] * m[12] - m[0] * m[13]))); + o[11] = (T)(d * (m[12] * (m[2] * m[5] - m[1] * m[6]) + m[13] * (m[0] * m[6] - m[2] * m[4]) + m[14] * (m[1] * m[4] - m[0] * m[5]))); + o[15] = (T)(d * (m[0] * (m[5] * m[10] - m[6] * m[9]) + m[1] * (m[6] * m[8] - m[4] * m[10]) + m[2] * (m[4] * m[9] - m[5] * m[8]))); return true; } @@ -85,25 +85,25 @@ bool mat44_inverse(CMatrix4& out, const CMatrix4& M) d = 1.0 / d; T* o = out.pointer(); - o[0] = (T)(d*(m[5] * (m[10] * m[15] - m[11] * m[14]) + m[6] * (m[11] * m[13] - m[9] * m[15]) + m[7] * (m[9] * m[14] - m[10] * m[13]))); - o[1] = (T)(d*(m[9] * (m[2] * m[15] - m[3] * m[14]) + m[10] * (m[3] * m[13] - m[1] * m[15]) + m[11] * (m[1] * m[14] - m[2] * m[13]))); - o[2] = (T)(d*(m[13] * (m[2] * m[7] - m[3] * m[6]) + m[14] * (m[3] * m[5] - m[1] * m[7]) + m[15] * (m[1] * m[6] - m[2] * m[5]))); - o[3] = (T)(d*(m[1] * (m[7] * m[10] - m[6] * m[11]) + m[2] * (m[5] * m[11] - m[7] * m[9]) + m[3] * (m[6] * m[9] - m[5] * m[10]))); + o[0] = (T)(d * (m[5] * (m[10] * m[15] - m[11] * m[14]) + m[6] * (m[11] * m[13] - m[9] * m[15]) + m[7] * (m[9] * m[14] - m[10] * m[13]))); + o[1] = (T)(d * (m[9] * (m[2] * m[15] - m[3] * m[14]) + m[10] * (m[3] * m[13] - m[1] * m[15]) + m[11] * (m[1] * m[14] - m[2] * m[13]))); + o[2] = (T)(d * (m[13] * (m[2] * m[7] - m[3] * m[6]) + m[14] * (m[3] * m[5] - m[1] * m[7]) + m[15] * (m[1] * m[6] - m[2] * m[5]))); + o[3] = (T)(d * (m[1] * (m[7] * m[10] - m[6] * m[11]) + m[2] * (m[5] * m[11] - m[7] * m[9]) + m[3] * (m[6] * m[9] - m[5] * m[10]))); - o[4] = (T)(d*(m[6] * (m[8] * m[15] - m[11] * m[12]) + m[7] * (m[10] * m[12] - m[8] * m[14]) + m[4] * (m[11] * m[14] - m[10] * m[15]))); - o[5] = (T)(d*(m[10] * (m[0] * m[15] - m[3] * m[12]) + m[11] * (m[2] * m[12] - m[0] * m[14]) + m[8] * (m[3] * m[14] - m[2] * m[15]))); - o[6] = (T)(d*(m[14] * (m[0] * m[7] - m[3] * m[4]) + m[15] * (m[2] * m[4] - m[0] * m[6]) + m[12] * (m[3] * m[6] - m[2] * m[7]))); - o[7] = (T)(d*(m[2] * (m[7] * m[8] - m[4] * m[11]) + m[3] * (m[4] * m[10] - m[6] * m[8]) + m[0] * (m[6] * m[11] - m[7] * m[10]))); + o[4] = (T)(d * (m[6] * (m[8] * m[15] - m[11] * m[12]) + m[7] * (m[10] * m[12] - m[8] * m[14]) + m[4] * (m[11] * m[14] - m[10] * m[15]))); + o[5] = (T)(d * (m[10] * (m[0] * m[15] - m[3] * m[12]) + m[11] * (m[2] * m[12] - m[0] * m[14]) + m[8] * (m[3] * m[14] - m[2] * m[15]))); + o[6] = (T)(d * (m[14] * (m[0] * m[7] - m[3] * m[4]) + m[15] * (m[2] * m[4] - m[0] * m[6]) + m[12] * (m[3] * m[6] - m[2] * m[7]))); + o[7] = (T)(d * (m[2] * (m[7] * m[8] - m[4] * m[11]) + m[3] * (m[4] * m[10] - m[6] * m[8]) + m[0] * (m[6] * m[11] - m[7] * m[10]))); - o[8] = (T)(d*(m[7] * (m[8] * m[13] - m[9] * m[12]) + m[4] * (m[9] * m[15] - m[11] * m[13]) + m[5] * (m[11] * m[12] - m[8] * m[15]))); - o[9] = (T)(d*(m[11] * (m[0] * m[13] - m[1] * m[12]) + m[8] * (m[1] * m[15] - m[3] * m[13]) + m[9] * (m[3] * m[12] - m[0] * m[15]))); - o[10] = (T)(d*(m[15] * (m[0] * m[5] - m[1] * m[4]) + m[12] * (m[1] * m[7] - m[3] * m[5]) + m[13] * (m[3] * m[4] - m[0] * m[7]))); - o[11] = (T)(d*(m[3] * (m[5] * m[8] - m[4] * m[9]) + m[0] * (m[7] * m[9] - m[5] * m[11]) + m[1] * (m[4] * m[11] - m[7] * m[8]))); + o[8] = (T)(d * (m[7] * (m[8] * m[13] - m[9] * m[12]) + m[4] * (m[9] * m[15] - m[11] * m[13]) + m[5] * (m[11] * m[12] - m[8] * m[15]))); + o[9] = (T)(d * (m[11] * (m[0] * m[13] - m[1] * m[12]) + m[8] * (m[1] * m[15] - m[3] * m[13]) + m[9] * (m[3] * m[12] - m[0] * m[15]))); + o[10] = (T)(d * (m[15] * (m[0] * m[5] - m[1] * m[4]) + m[12] * (m[1] * m[7] - m[3] * m[5]) + m[13] * (m[3] * m[4] - m[0] * m[7]))); + o[11] = (T)(d * (m[3] * (m[5] * m[8] - m[4] * m[9]) + m[0] * (m[7] * m[9] - m[5] * m[11]) + m[1] * (m[4] * m[11] - m[7] * m[8]))); - o[12] = (T)(d*(m[4] * (m[10] * m[13] - m[9] * m[14]) + m[5] * (m[8] * m[14] - m[10] * m[12]) + m[6] * (m[9] * m[12] - m[8] * m[13]))); - o[13] = (T)(d*(m[8] * (m[2] * m[13] - m[1] * m[14]) + m[9] * (m[0] * m[14] - m[2] * m[12]) + m[10] * (m[1] * m[12] - m[0] * m[13]))); - o[14] = (T)(d*(m[12] * (m[2] * m[5] - m[1] * m[6]) + m[13] * (m[0] * m[6] - m[2] * m[4]) + m[14] * (m[1] * m[4] - m[0] * m[5]))); - o[15] = (T)(d*(m[0] * (m[5] * m[10] - m[6] * m[9]) + m[1] * (m[6] * m[8] - m[4] * m[10]) + m[2] * (m[4] * m[9] - m[5] * m[8]))); + o[12] = (T)(d * (m[4] * (m[10] * m[13] - m[9] * m[14]) + m[5] * (m[8] * m[14] - m[10] * m[12]) + m[6] * (m[9] * m[12] - m[8] * m[13]))); + o[13] = (T)(d * (m[8] * (m[2] * m[13] - m[1] * m[14]) + m[9] * (m[0] * m[14] - m[2] * m[12]) + m[10] * (m[1] * m[12] - m[0] * m[13]))); + o[14] = (T)(d * (m[12] * (m[2] * m[5] - m[1] * m[6]) + m[13] * (m[0] * m[6] - m[2] * m[4]) + m[14] * (m[1] * m[4] - m[0] * m[5]))); + o[15] = (T)(d * (m[0] * (m[5] * m[10] - m[6] * m[9]) + m[1] * (m[6] * m[8] - m[4] * m[10]) + m[2] * (m[4] * m[9] - m[5] * m[8]))); return true; } @@ -115,8 +115,8 @@ inline void transformVec4Vec4(const irr::core::CMatrix4& m, T* burning_restri { const T* burning_restrict M = m.pointer(); - out[0] = in[0] * M[0] + in[1] * M[4] + in[2] * M[8] + in[3] * M[12]; - out[1] = in[0] * M[1] + in[1] * M[5] + in[2] * M[9] + in[3] * M[13]; + out[0] = in[0] * M[0] + in[1] * M[4] + in[2] * M[8] + in[3] * M[12]; + out[1] = in[0] * M[1] + in[1] * M[5] + in[2] * M[9] + in[3] * M[13]; out[2] = in[0] * M[2] + in[1] * M[6] + in[2] * M[10] + in[3] * M[14]; out[3] = in[0] * M[3] + in[1] * M[7] + in[2] * M[11] + in[3] * M[15]; } @@ -124,13 +124,13 @@ inline void transformVec4Vec4(const irr::core::CMatrix4& m, T* burning_restri #if 0 // void CMatrix4::transformVect(T *out, const core::vector3df &in) const template -inline void transformVec3Vec4(const irr::core::CMatrix4& m,T* burning_restrict out, const core::vector3df &in) +inline void transformVec3Vec4(const irr::core::CMatrix4& m, T* burning_restrict out, const core::vector3df& in) { const T* burning_restrict M = m.pointer(); - out[0] = in.X*M[0] + in.Y*M[4] + in.Z*M[8] + M[12]; - out[1] = in.X*M[1] + in.Y*M[5] + in.Z*M[9] + M[13]; - out[2] = in.X*M[2] + in.Y*M[6] + in.Z*M[10] + M[14]; - out[3] = in.X*M[3] + in.Y*M[7] + in.Z*M[11] + M[15]; + out[0] = in.X * M[0] + in.Y * M[4] + in.Z * M[8] + M[12]; + out[1] = in.X * M[1] + in.Y * M[5] + in.Z * M[9] + M[13]; + out[2] = in.X * M[2] + in.Y * M[6] + in.Z * M[10] + M[14]; + out[3] = in.X * M[3] + in.Y * M[7] + in.Z * M[11] + M[15]; } #endif @@ -172,105 +172,78 @@ static inline float powf_limit(const float a, const float b) return r; } - -#if defined(Tweak_Burning) - -// run time parameter -struct tweakBurning +//! clamp(value,0,1) +static inline const float clampf01(const float v) { - tweakBurning() + return v < 0.f ? 0.f : v > 1.f ? 1.f : v; +} + +// IImage::fill +static void image_fill(irr::video::IImage* image, const irr::video::SColor& color, const interlaced_control interlaced) +{ + if (0 == image) + return; + + unsigned int c = color.color; + + switch (image->getColorFormat()) { - current = 11; - step = 0.0001f; - - ndc_shrink_x = -0.75f; - ndc_scale_x = 0.5f; - ndc_trans_x = -0.5f; - - ndc_shrink_y = -0.75f; - ndc_scale_y = -0.5f; - ndc_trans_y = -0.5f; - - tex_w_add = 0.f; - tex_h_add = 0.f; - tex_cx_add = 0.f; - tex_cy_add = 0.f; - - AreaMinDrawSize = 0.001f; + case irr::video::ECF_A1R5G5B5: + c = color.toA1R5G5B5(); + c |= c << 16; + break; + default: + break; } - int current; + irr::memset32_interlaced(image->getData(), c, image->getPitch(), image->getDimension().Height, interlaced); +} - union + +union scale_setup +{ + struct { - struct { - f32 step; - - f32 ndc_shrink_x; - f32 ndc_scale_x; - f32 ndc_trans_x; - - f32 ndc_shrink_y; - f32 ndc_scale_y; - f32 ndc_trans_y; - - f32 tex_w_add; - f32 tex_cx_add; - f32 tex_h_add; - f32 tex_cy_add; - - f32 AreaMinDrawSize; //! minimal visible covered area for primitive - }; - f32 val[16]; + unsigned char x : 3; + unsigned char y : 3; + unsigned char i : 2; }; - static const char* const name[16]; - void postEventFromUser(const SEvent& e); + unsigned char v; }; -const char* const tweakBurning::name[] = { "step", - "ndc_shrink_x","ndc_scale_x","ndc_trans_x", - "ndc_shrink_y","ndc_scale_y","ndc_trans_y", - "tex_w_add","tex_cx_add","tex_h_add","tex_cy_add", - "dc_area",0 }; - -void tweakBurning::postEventFromUser(const SEvent& e) +//setup Antialias. v0.52 uses as Interlaced +void get_scale(scale_setup& s, const irr::SIrrlichtCreationParameters& params) { - int show = 0; - if (e.EventType == EET_KEY_INPUT_EVENT) + s.x = 1; + s.y = 1; + s.i = 0; + if (params.AntiAlias && params.WindowSize.Width <= 160 && params.WindowSize.Height <= 120) { - switch (e.KeyInput.Key) - { - case KEY_KEY_1: step *= 0.9f; if (step < 0.00001f) step = 0.0001f; show = 2; break; - case KEY_KEY_2: step *= 1.1f; show = 2; break; - - case KEY_KEY_3: if (!e.KeyInput.PressedDown) { current -= 1; if (current < 1) current = 11; show = 1; } break; - case KEY_KEY_4: if (!e.KeyInput.PressedDown) { current += 1; if (current > 11) current = 1; show = 1; } break; - - case KEY_KEY_5: val[current] -= e.KeyInput.Shift ? step * 100.f : step; show = 1; break; - case KEY_KEY_6: val[current] += e.KeyInput.Shift ? step * 100.f : step; show = 1; break; - default: - break; - } + return; } - if (show) + + switch (params.AntiAlias) { - if (step < 0.0001f) step = 0.0001f; - char buf[256]; - if (show == 2) sprintf(buf, "%s %f\n", name[0], val[0]); - else sprintf(buf, "%s %f\n", name[current], val[current]); - os::Printer::print(buf); + case 2: s.x = 1; s.y = 1; s.i = 1; break; + case 4: s.x = 2; s.y = 2; s.i = 0; break; + case 8: s.x = 2; s.y = 2; s.i = 1; break; + case 16:s.x = 4; s.y = 4; s.i = 0; break; + case 32:s.x = 4; s.y = 4; s.i = 1; break; + + case 3: s.x = 3; s.y = 3; s.i = 0; break; + case 5: s.x = 3; s.y = 3; s.i = 1; break; } } -void CBurningVideoDriver::postEventFromUser(const void* sevent) +//turn on/off fpu exception +void fpu_exception(int on) { - if (sevent) Tweak.postEventFromUser(*(const SEvent*)sevent); + return; +#if defined(_WIN32) + _clearfp(); + _controlfp(on ? _EM_INEXACT : -1, _MCW_EM); +#endif } -tweakBurning Tweak; -#endif //defined(Tweak_Burning) - - - namespace irr { namespace video @@ -278,51 +251,62 @@ namespace video //! constructor CBurningVideoDriver::CBurningVideoDriver(const irr::SIrrlichtCreationParameters& params, io::IFileSystem* io, video::IImagePresenter* presenter) -: CNullDriver(io, params.WindowSize), BackBuffer(0), Presenter(presenter), + : CNullDriver(io, params.WindowSize), BackBuffer(0), Presenter(presenter), WindowId(0), SceneSourceRect(0), RenderTargetTexture(0), RenderTargetSurface(0), CurrentShader(0), - DepthBuffer(0), StencilBuffer ( 0 ) + DepthBuffer(0), StencilBuffer(0) { //enable fpu exception - //unsigned int fp_control_state = _controlfp(_EM_INEXACT, _MCW_EM); + fpu_exception(1); - #ifdef _DEBUG +#ifdef _DEBUG setDebugName("CBurningVideoDriver"); - #endif +#endif VertexCache_map_source_format(); - // create backbuffer - BackBuffer = new CImage(BURNINGSHADER_COLOR_FORMAT, params.WindowSize); + //Use AntiAlias(hack) to shrink BackBuffer Size and keep ScreenSize the same as Input + scale_setup scale; + get_scale(scale, params); + + //Control Interlaced BackBuffer + Interlaced.enable = scale.i; + Interlaced.bypass = !Interlaced.enable; + Interlaced.nr = 0; + + // create backbuffer. + core::dimension2du use(params.WindowSize.Width / scale.x, params.WindowSize.Height / scale.y); + BackBuffer = new CImage(SOFTWARE_DRIVER_2_RENDERTARGET_COLOR_FORMAT, use); if (BackBuffer) { - BackBuffer->fill(SColor(0)); + //BackBuffer->fill(SColor(0)); + image_fill(BackBuffer, SColor(0), interlace_disabled()); // create z buffer - if ( params.ZBufferBits ) + if (params.ZBufferBits) DepthBuffer = video::createDepthBuffer(BackBuffer->getDimension()); // create stencil buffer - if ( params.Stencilbuffer ) - StencilBuffer = video::createStencilBuffer(BackBuffer->getDimension(),8); + if (params.Stencilbuffer) + StencilBuffer = video::createStencilBuffer(BackBuffer->getDimension(), 8); } - DriverAttributes->setAttribute("MaxIndices", 1<<16); + DriverAttributes->setAttribute("MaxIndices", 1 << 16); DriverAttributes->setAttribute("MaxTextures", BURNING_MATERIAL_MAX_TEXTURES); - DriverAttributes->setAttribute("MaxTextureSize", SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE ? SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE : 1<<20); - DriverAttributes->setAttribute("MaxLights", 1024 ); //glsl::gl_MaxLights); + DriverAttributes->setAttribute("MaxTextureSize", SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE); + DriverAttributes->setAttribute("MaxLights", 1024); //glsl::gl_MaxLights); DriverAttributes->setAttribute("MaxTextureLODBias", 16.f); DriverAttributes->setAttribute("Version", 50); // create triangle renderers - memset( BurningShader, 0, sizeof ( BurningShader ) ); + memset(BurningShader, 0, sizeof(BurningShader)); //BurningShader[ETR_FLAT] = createTRFlat2(DepthBuffer); //BurningShader[ETR_FLAT_WIRE] = createTRFlatWire2(DepthBuffer); BurningShader[ETR_GOURAUD] = createTriangleRendererGouraud2(this); BurningShader[ETR_GOURAUD_NOZ] = createTriangleRendererGouraudNoZ2(this); //BurningShader[ETR_GOURAUD_ALPHA] = createTriangleRendererGouraudAlpha2(this ); - BurningShader[ETR_GOURAUD_ALPHA_NOZ] = createTRGouraudAlphaNoZ2(this ); // 2D + BurningShader[ETR_GOURAUD_ALPHA_NOZ] = createTRGouraudAlphaNoZ2(this); // 2D //BurningShader[ETR_GOURAUD_WIRE] = createTriangleRendererGouraudWire2(DepthBuffer); //BurningShader[ETR_TEXTURE_FLAT] = createTriangleRendererTextureFlat2(DepthBuffer); //BurningShader[ETR_TEXTURE_FLAT_WIRE] = createTriangleRendererTextureFlatWire2(DepthBuffer); @@ -338,14 +322,14 @@ CBurningVideoDriver::CBurningVideoDriver(const irr::SIrrlichtCreationParameters& BurningShader[ETR_TEXTURE_GOURAUD_NOZ] = createTRTextureGouraudNoZ2(this); BurningShader[ETR_TEXTURE_GOURAUD_ADD] = createTRTextureGouraudAdd2(this); BurningShader[ETR_TEXTURE_GOURAUD_ADD_NO_Z] = createTRTextureGouraudAddNoZ2(this); - BurningShader[ETR_TEXTURE_GOURAUD_VERTEX_ALPHA] = createTriangleRendererTextureVertexAlpha2 ( this ); + BurningShader[ETR_TEXTURE_GOURAUD_VERTEX_ALPHA] = createTriangleRendererTextureVertexAlpha2(this); - BurningShader[ETR_TEXTURE_GOURAUD_ALPHA] = createTRTextureGouraudAlpha(this ); - BurningShader[ETR_TEXTURE_GOURAUD_ALPHA_NOZ] = createTRTextureGouraudAlphaNoZ( this ); + BurningShader[ETR_TEXTURE_GOURAUD_ALPHA] = createTRTextureGouraudAlpha(this); + BurningShader[ETR_TEXTURE_GOURAUD_ALPHA_NOZ] = createTRTextureGouraudAlphaNoZ(this); - BurningShader[ETR_NORMAL_MAP_SOLID] = createTRNormalMap ( this ); - BurningShader[ETR_STENCIL_SHADOW] = createTRStencilShadow ( this ); - BurningShader[ETR_TEXTURE_BLEND] = createTRTextureBlend( this ); + BurningShader[ETR_NORMAL_MAP_SOLID] = createTRNormalMap(this); + BurningShader[ETR_STENCIL_SHADOW] = createTRStencilShadow(this); + BurningShader[ETR_TEXTURE_BLEND] = createTRTextureBlend(this); BurningShader[ETR_TRANSPARENT_REFLECTION_2_LAYER] = createTriangleRendererTexture_transparent_reflection_2_layer(this); //BurningShader[ETR_REFERENCE] = createTriangleRendererReference ( this ); @@ -353,42 +337,42 @@ CBurningVideoDriver::CBurningVideoDriver(const irr::SIrrlichtCreationParameters& BurningShader[ETR_COLOR] = create_burning_shader_color(this); // add the same renderer for all solid types - CSoftware2MaterialRenderer_SOLID* smr = new CSoftware2MaterialRenderer_SOLID( this); - CSoftware2MaterialRenderer_TRANSPARENT_ADD_COLOR* tmr = new CSoftware2MaterialRenderer_TRANSPARENT_ADD_COLOR( this); + CSoftware2MaterialRenderer_SOLID* smr = new CSoftware2MaterialRenderer_SOLID(this); + CSoftware2MaterialRenderer_TRANSPARENT_ADD_COLOR* tmr = new CSoftware2MaterialRenderer_TRANSPARENT_ADD_COLOR(this); //CSoftware2MaterialRenderer_UNSUPPORTED * umr = new CSoftware2MaterialRenderer_UNSUPPORTED ( this ); //!TODO: addMaterialRenderer depends on pushing order.... - addMaterialRenderer ( smr ); // EMT_SOLID - addMaterialRenderer ( smr ); // EMT_SOLID_2_LAYER, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP, - addMaterialRenderer ( tmr ); // EMT_LIGHTMAP_ADD, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP_M2, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP_M4, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP_LIGHTING, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP_LIGHTING_M2, - addMaterialRenderer ( smr ); // EMT_LIGHTMAP_LIGHTING_M4, - addMaterialRenderer ( smr ); // EMT_DETAIL_MAP, - addMaterialRenderer ( smr ); // EMT_SPHERE_MAP, - addMaterialRenderer ( smr ); // EMT_REFLECTION_2_LAYER, - addMaterialRenderer ( tmr ); // EMT_TRANSPARENT_ADD_COLOR, - addMaterialRenderer ( tmr ); // EMT_TRANSPARENT_ALPHA_CHANNEL, - addMaterialRenderer ( tmr ); // EMT_TRANSPARENT_ALPHA_CHANNEL_REF, - addMaterialRenderer ( tmr ); // EMT_TRANSPARENT_VERTEX_ALPHA, - addMaterialRenderer ( tmr ); // EMT_TRANSPARENT_REFLECTION_2_LAYER, - addMaterialRenderer ( smr ); // EMT_NORMAL_MAP_SOLID, - addMaterialRenderer ( tmr ); // EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR, - addMaterialRenderer ( tmr ); // EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA, - addMaterialRenderer ( smr ); // EMT_PARALLAX_MAP_SOLID, - addMaterialRenderer ( tmr ); // EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR, - addMaterialRenderer ( tmr ); // EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA, - addMaterialRenderer ( tmr ); // EMT_ONETEXTURE_BLEND + addMaterialRenderer(smr); // EMT_SOLID + addMaterialRenderer(smr); // EMT_SOLID_2_LAYER, + addMaterialRenderer(smr); // EMT_LIGHTMAP, + addMaterialRenderer(tmr); // EMT_LIGHTMAP_ADD, + addMaterialRenderer(smr); // EMT_LIGHTMAP_M2, + addMaterialRenderer(smr); // EMT_LIGHTMAP_M4, + addMaterialRenderer(smr); // EMT_LIGHTMAP_LIGHTING, + addMaterialRenderer(smr); // EMT_LIGHTMAP_LIGHTING_M2, + addMaterialRenderer(smr); // EMT_LIGHTMAP_LIGHTING_M4, + addMaterialRenderer(smr); // EMT_DETAIL_MAP, + addMaterialRenderer(smr); // EMT_SPHERE_MAP, + addMaterialRenderer(smr); // EMT_REFLECTION_2_LAYER, + addMaterialRenderer(tmr); // EMT_TRANSPARENT_ADD_COLOR, + addMaterialRenderer(tmr); // EMT_TRANSPARENT_ALPHA_CHANNEL, + addMaterialRenderer(tmr); // EMT_TRANSPARENT_ALPHA_CHANNEL_REF, + addMaterialRenderer(tmr); // EMT_TRANSPARENT_VERTEX_ALPHA, + addMaterialRenderer(tmr); // EMT_TRANSPARENT_REFLECTION_2_LAYER, + addMaterialRenderer(smr); // EMT_NORMAL_MAP_SOLID, + addMaterialRenderer(tmr); // EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR, + addMaterialRenderer(tmr); // EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA, + addMaterialRenderer(smr); // EMT_PARALLAX_MAP_SOLID, + addMaterialRenderer(tmr); // EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR, + addMaterialRenderer(tmr); // EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA, + addMaterialRenderer(tmr); // EMT_ONETEXTURE_BLEND - smr->drop (); - tmr->drop (); + smr->drop(); + tmr->drop(); //umr->drop (); // select render target - setRenderTargetImage(BackBuffer); + setRenderTargetImage2(BackBuffer,0, 0); //reset Lightspace EyeSpace.reset(); @@ -410,7 +394,7 @@ CBurningVideoDriver::~CBurningVideoDriver() } // delete triangle renderers - for (s32 i=0; idrop(); RenderTargetSurface = 0; } + + fpu_exception(0); + } @@ -458,7 +445,7 @@ bool CBurningVideoDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const on = 1; break; #endif -#ifdef SOFTWARE_DRIVER_2_MIPMAPPING +#if SOFTWARE_DRIVER_2_MIPMAPPING_MAX > 1 case EVDF_MIP_MAP: on = 1; break; @@ -510,85 +497,74 @@ bool CBurningVideoDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const } - -//! Create render target. -IRenderTarget* CBurningVideoDriver::addRenderTarget() -{ - CSoftwareRenderTarget2* renderTarget = new CSoftwareRenderTarget2(this); - RenderTargets.push_back(renderTarget); - - return renderTarget; -} - - //matrix multiplication void CBurningVideoDriver::transform_calc(E_TRANSFORMATION_STATE_BURNING_VIDEO state) { size_t* flag = TransformationFlag[TransformationStack]; - if (flag[state] & ETF_VALID ) return; + if (flag[state] & ETF_VALID) return; //check - int ok = 0; - switch ( state ) + size_t ok = 0; + switch (state) { - case ETS_PROJ_MODEL_VIEW: - if ( 0 == (flag[ETS_VIEW_PROJECTION] & ETF_VALID) ) transform_calc (ETS_VIEW_PROJECTION); - ok = flag[ETS_WORLD] & flag[ETS_VIEW] & flag[ETS_PROJECTION] & flag[ETS_VIEW_PROJECTION] & ETF_VALID; - break; - case ETS_VIEW_PROJECTION: - ok = flag[ETS_VIEW] & flag[ETS_PROJECTION] & ETF_VALID; - break; - case ETS_MODEL_VIEW: - ok = flag[ETS_WORLD] & flag[ETS_VIEW] & ETF_VALID; - break; - case ETS_NORMAL: - ok = flag[ETS_MODEL_VIEW] & ETF_VALID; - break; - default: - break; + case ETS_PROJ_MODEL_VIEW: + if (0 == (flag[ETS_VIEW_PROJECTION] & ETF_VALID)) transform_calc(ETS_VIEW_PROJECTION); + ok = flag[ETS_WORLD] & flag[ETS_VIEW] & flag[ETS_PROJECTION] & flag[ETS_VIEW_PROJECTION] & ETF_VALID; + break; + case ETS_VIEW_PROJECTION: + ok = flag[ETS_VIEW] & flag[ETS_PROJECTION] & ETF_VALID; + break; + case ETS_MODEL_VIEW: + ok = flag[ETS_WORLD] & flag[ETS_VIEW] & ETF_VALID; + break; + case ETS_NORMAL: + ok = flag[ETS_MODEL_VIEW] & ETF_VALID; + break; + default: + break; } - if ( !ok ) + if (!ok) { char buf[256]; - sprintf(buf,"transform_calc not valid for %d\n",state); + sprintf(buf, "transform_calc not valid for %d\n", state); os::Printer::log(buf, ELL_WARNING); } core::matrix4* matrix = Transformation[TransformationStack]; - switch ( state ) + switch (state) { - case ETS_PROJ_MODEL_VIEW: - if (flag[ETS_WORLD] & ETF_IDENTITY ) - { - matrix[state] = matrix[ETS_VIEW_PROJECTION]; - } - else - { - matrix[state].setbyproduct_nocheck(matrix[ETS_VIEW_PROJECTION], matrix[ETS_WORLD]); - } - break; + case ETS_PROJ_MODEL_VIEW: + if (flag[ETS_WORLD] & ETF_IDENTITY) + { + matrix[state] = matrix[ETS_VIEW_PROJECTION]; + } + else + { + matrix[state].setbyproduct_nocheck(matrix[ETS_VIEW_PROJECTION], matrix[ETS_WORLD]); + } + break; - case ETS_VIEW_PROJECTION: - matrix[state].setbyproduct_nocheck (matrix[ETS_PROJECTION], matrix[ETS_VIEW]); - break; - case ETS_MODEL_VIEW: - if ( flag[ETS_WORLD] & ETF_IDENTITY ) - { - matrix[state] = matrix[ETS_VIEW]; - } - else - { - matrix[state].setbyproduct_nocheck(matrix[ETS_VIEW], matrix[ETS_WORLD]); - } - break; - case ETS_NORMAL: - mat44_transposed_inverse(matrix[state], matrix[ETS_MODEL_VIEW]); - break; + case ETS_VIEW_PROJECTION: + matrix[state].setbyproduct_nocheck(matrix[ETS_PROJECTION], matrix[ETS_VIEW]); + break; + case ETS_MODEL_VIEW: + if (flag[ETS_WORLD] & ETF_IDENTITY) + { + matrix[state] = matrix[ETS_VIEW]; + } + else + { + matrix[state].setbyproduct_nocheck(matrix[ETS_VIEW], matrix[ETS_WORLD]); + } + break; + case ETS_NORMAL: + mat44_transposed_inverse(matrix[state], matrix[ETS_MODEL_VIEW]); + break; - default: - break; + default: + break; } flag[state] |= ETF_VALID; } @@ -615,18 +591,18 @@ void CBurningVideoDriver::setTransform(E_TRANSFORMATION_STATE state, const core: //maybe identity (mostly for texturematrix to avoid costly multiplication) #if defined ( USE_MATRIX_TEST ) - burning_setbit( TransformationFlag[state], mat.getDefinitelyIdentityMatrix(), ETF_IDENTITY ); + burning_setbit(TransformationFlag[state], mat.getDefinitelyIdentityMatrix(), ETF_IDENTITY); #else burning_setbit(flag[state], - !memcmp(mat.pointer(), core::IdentityMatrix.pointer(),sizeof(mat)),ETF_IDENTITY + !memcmp(mat.pointer(), core::IdentityMatrix.pointer(), sizeof(mat)), ETF_IDENTITY ); #endif #if 0 - if ( changed ) + if (changed) #endif - switch ( state ) - { + switch (state) + { case ETS_PROJECTION: flag[ETS_PROJ_MODEL_VIEW] &= ~ETF_VALID; flag[ETS_VIEW_PROJECTION] &= ~ETF_VALID; @@ -658,14 +634,14 @@ void CBurningVideoDriver::setTransform(E_TRANSFORMATION_STATE state, const core: #if _IRR_MATERIAL_MAX_TEXTURES_>7 case ETS_TEXTURE_7: #endif - if ( 0 == (flag[state] & ETF_IDENTITY ) ) + if (0 == (flag[state] & ETF_IDENTITY)) { EyeSpace.TL_Flag |= TL_TEXTURE_TRANSFORM; } break; default: break; - } + } } @@ -678,7 +654,13 @@ const core::matrix4& CBurningVideoDriver::getTransform(E_TRANSFORMATION_STATE st bool CBurningVideoDriver::beginScene(u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil, const SExposedVideoData& videoData, core::rect* sourceRect) { +#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) + CNullDriver::beginScene(clearFlag & ECBF_COLOR, clearFlag & ECBF_DEPTH, clearColor, videoData, sourceRect); +#else CNullDriver::beginScene(clearFlag, clearColor, clearDepth, clearStencil, videoData, sourceRect); +#endif + + Interlaced.nr = (Interlaced.nr + 1) & interlace_control_mask; WindowId = videoData.D3D9.HWnd; SceneSourceRect = sourceRect; @@ -695,28 +677,70 @@ bool CBurningVideoDriver::endScene() return Presenter->present(BackBuffer, WindowId, SceneSourceRect); } + +//! Create render target. +IRenderTarget* CBurningVideoDriver::addRenderTarget() +{ + CSoftwareRenderTarget2* renderTarget = new CSoftwareRenderTarget2(this); + RenderTargets.push_back(renderTarget); + + return renderTarget; +} + +#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) +bool CBurningVideoDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer, bool clearZBuffer, SColor color) +{ + CSoftwareRenderTarget2 target(this); + target.RenderTexture = texture; + target.TargetType = ERT_RENDER_TEXTURE; + target.Texture[0] = texture; + + if (texture) + texture->grab(); + + u16 flag = 0; + if (clearBackBuffer) flag |= ECBF_COLOR; + if (clearZBuffer) flag |= ECBF_DEPTH; + + return setRenderTargetEx(texture ? &target : 0, flag, color, 1.f, true); +} +#endif + bool CBurningVideoDriver::setRenderTargetEx(IRenderTarget* target, u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil) { +#if !defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) if (target && target->getDriverType() != EDT_BURNINGSVIDEO) { os::Printer::log("Fatal Error: Tried to set a render target not owned by this driver.", ELL_ERROR); return false; } - +#endif if (RenderTargetTexture) + { + //switching from texture to backbuffer + if (target == 0) + { + RenderTargetTexture->regenerateMipMapLevels(); + } RenderTargetTexture->drop(); + } - CSoftwareRenderTarget2* renderTarget = static_cast(target); - RenderTargetTexture = (renderTarget) ? renderTarget->getTexture() : 0; +#if !defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) + RenderTargetTexture = target ? target->getTexture()[0] : 0; +#else + RenderTargetTexture = target ? ((CSoftwareRenderTarget2*)target)->Texture[0] : 0; +#endif if (RenderTargetTexture) { RenderTargetTexture->grab(); - setRenderTargetImage(((CSoftwareTexture2*)RenderTargetTexture)->getTexture()); + Interlaced.bypass = 1; + setRenderTargetImage2(((CSoftwareTexture2*)RenderTargetTexture)->getImage()); } else { - setRenderTargetImage(BackBuffer); + Interlaced.bypass = !Interlaced.enable; + setRenderTargetImage2(BackBuffer); } clearBuffers(clearFlag, clearColor, clearDepth, clearStencil); @@ -724,14 +748,18 @@ bool CBurningVideoDriver::setRenderTargetEx(IRenderTarget* target, u16 clearFlag return true; } +static inline f32 map_value(f32 x, f32 in_min, f32 in_max, f32 out_min, f32 out_max) { + return (x - in_min) * (out_max - out_min) / (f32)(in_max - in_min) + out_min; +} + //! sets a render target -void CBurningVideoDriver::setRenderTargetImage(video::CImage* image) +void CBurningVideoDriver::setRenderTargetImage2(video::IImage* color, video::IImage* depth, video::IImage* stencil) { if (RenderTargetSurface) RenderTargetSurface->drop(); core::dimension2d current = RenderTargetSize; - RenderTargetSurface = image; + RenderTargetSurface = color; RenderTargetSize.Width = 0; RenderTargetSize.Height = 0; @@ -741,6 +769,9 @@ void CBurningVideoDriver::setRenderTargetImage(video::CImage* image) RenderTargetSize = RenderTargetSurface->getDimension(); } + RatioRenderTargetScreen.x = ScreenSize.Width ? (f32)RenderTargetSize.Width / ScreenSize.Width : 1.f; + RatioRenderTargetScreen.y = ScreenSize.Height ? (f32)RenderTargetSize.Height / ScreenSize.Height : 1.f; + int not_changed = current == RenderTargetSize; burning_setbit(TransformationFlag[0][ETS_PROJECTION], not_changed, ETF_VALID); burning_setbit(TransformationFlag[1][ETS_PROJECTION], not_changed, ETF_VALID); @@ -757,95 +788,66 @@ void CBurningVideoDriver::setRenderTargetImage(video::CImage* image) //--------- Transform from NDC to DC, transform TexCoo ---------------------------------------------- -// controls subtexel and fill convention -#if defined(SOFTWARE_DRIVER_2_SUBTEXEL) -#define SOFTWARE_DRIVER_2_PIXEL_CENTER -0.5f -#else -#define SOFTWARE_DRIVER_2_PIXEL_CENTER -0.5f -#endif -#if 1 +//! Blur 2D Image with PixelOffset. (default 0.375f for OpenGL and Burning) +/** SideEffects: +* if IRRLICHT_2D_TEXEL_OFFSET > 0 is applied to OpenGL/Burning, Pixel-exact Texture Coordinates do not match. +* Currently Version 1.8,1.9 has that in the Irrlicht 2D Examples where you get a Magenta Border on the Sprites +* and in the draw2DImage4cFilter Tests +*/ +#define IRRLICHT_2D_TEXEL_OFFSET 0.f + + +//--------- Transform from NDC to DC ---------------------------------------------- + +// used to scale <-1,-1><1,1> to viewport [center,scale] +// controls subtexel and fill convention. +// Don't tweak SOFTWARE_DRIVER_2_SUBTEXEL (-0.5f in m[1]) anymore to control texture blur effect, it's used for viewport scaling. +// naming is misleading. it will write outside memory location.. -// used to scale <-1,-1><1,1> to viewport void buildNDCToDCMatrix(f32* m, const core::rect& viewport, f32 tx) { - m[0] = (viewport.getWidth() + tx) * 0.5f; - m[1] = SOFTWARE_DRIVER_2_PIXEL_CENTER + ((viewport.UpperLeftCorner.X + viewport.LowerRightCorner.X) * 0.5f); + m[0] = (viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X + tx) * 0.5f; + m[1] = (viewport.UpperLeftCorner.X + viewport.LowerRightCorner.X-1) * 0.5f; - m[2] = (viewport.getHeight() + tx) * -0.5f; - m[3] = SOFTWARE_DRIVER_2_PIXEL_CENTER + ((viewport.UpperLeftCorner.Y + viewport.LowerRightCorner.Y) * 0.5f); + m[2] = (viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y + tx) * -0.5f; + m[3] = (viewport.UpperLeftCorner.Y + viewport.LowerRightCorner.Y-1) * 0.5f; } -#else -// used to scale <-1,-1><1,1> to viewport -void buildNDCToDCMatrix( core::matrix4& out, const core::rect& viewport) -{ - //guard band to stay in screen bounds.(empirical). get holes left side otherwise or out of screen - //TODO: match openGL or D3D. - //assumption pixel center, top-left rule and rounding error projection deny exact match without additional clipping - //or triangle render scanline doesn't step on correct texel center - //or sampler is not on texel center - - f32* m = out.pointer(); -#if defined(Tweak_Burning) && 0 - m[0] = (viewport.getWidth() + Tweak.ndc_shrink_x ) * Tweak.ndc_scale_x; - m[5] = (viewport.getHeight() + Tweak.ndc_shrink_y ) * Tweak.ndc_scale_y; - m[12] = Tweak.ndc_trans_x + ( (viewport.UpperLeftCorner.X + viewport.LowerRightCorner.X ) * 0.5f ); - m[13] = Tweak.ndc_trans_y + ( (viewport.UpperLeftCorner.Y + viewport.LowerRightCorner.Y ) * 0.5f ); -#endif - - m[0] = (viewport.getWidth() - 0.75f ) * 0.5f; - m[1] = 0.f; - m[2] = 0.f; - m[3] = 0.f; - m[4] = 0.f; - m[5] = (viewport.getHeight() - 0.75f ) * -0.5f; - m[6] = 0.f; - m[7] = 0.f; - m[8] = 0.f; - m[9] = 0.f; - m[10] = 1.f; - m[11] = 0.f; - m[12] = SOFTWARE_DRIVER_2_PIXEL_CENTER + ( (viewport.UpperLeftCorner.X + viewport.LowerRightCorner.X ) * 0.5f ); - m[13] = SOFTWARE_DRIVER_2_PIXEL_CENTER + ( (viewport.UpperLeftCorner.Y + viewport.LowerRightCorner.Y ) * 0.5f ); - m[14] = 0.f; - m[15] = 1.f; -} -#endif - - -//--------- Transform from NCD to DC ---------------------------------------------- //! sets a viewport void CBurningVideoDriver::setViewPort(const core::rect& area) { ViewPort = area; - core::rect rendert(0,0,RenderTargetSize.Width,RenderTargetSize.Height); + core::rect rendert(0, 0, RenderTargetSize.Width, RenderTargetSize.Height); ViewPort.clipAgainst(rendert); - buildNDCToDCMatrix(Transformation_ETS_CLIPSCALE[0], ViewPort,-0.375f); - buildNDCToDCMatrix(Transformation_ETS_CLIPSCALE[1], ViewPort, 0.f); // OverrideMaterial2DEnabled ? -0.375f : 0.f); + buildNDCToDCMatrix(Transformation_ETS_CLIPSCALE[0], ViewPort, 1.f/2048.f); //SkyBox,Billboard 90° problem + buildNDCToDCMatrix(Transformation_ETS_CLIPSCALE[1], ViewPort, 0.f); // OverrideMaterial2DEnabled ? -IRRLICHT_2D_TEXEL_OFFSET : 0.f); if (CurrentShader) - CurrentShader->setRenderTarget(RenderTargetSurface, ViewPort); + CurrentShader->setRenderTarget(RenderTargetSurface, ViewPort, Interlaced); } void CBurningVideoDriver::setScissor(int x, int y, int width, int height) { - AbsRectangle v0; - v0.x0 = x; - v0.y0 = y; - v0.x1 = x+width; - v0.y1 = y+width; + //openGL + //y = rt.Height - y - height; + + //coming from GUI + AbsRectangle v0; + v0.x0 = core::floor32(x * RatioRenderTargetScreen.x); + v0.y0 = core::floor32(y * RatioRenderTargetScreen.y); + v0.x1 = core::floor32((x + width) * RatioRenderTargetScreen.x); + v0.y1 = core::floor32((y + height) * RatioRenderTargetScreen.y); - const core::dimension2d& rt = getCurrentRenderTargetSize(); AbsRectangle v1; v1.x0 = 0; v1.y0 = 0; - v1.x1 = rt.Width; - v1.y1 = rt.Height; + v1.x1 = RenderTargetSize.Width; + v1.y1 = RenderTargetSize.Height; intersect(Scissor, v0, v1); } @@ -858,14 +860,14 @@ void CBurningVideoDriver::setScissor(int x, int y, int width, int height) cam is (0,0,-1) */ -const sVec4 CBurningVideoDriver::NDCPlane[6+2] = +const sVec4 CBurningVideoDriver::NDCPlane[6 + 2] = { - sVec4( 0.f, 0.f, -1.f, -1.f ), // near - sVec4( 0.f, 0.f, 1.f, -1.f ), // far - sVec4( 1.f, 0.f, 0.f, -1.f ), // left - sVec4( -1.f, 0.f, 0.f, -1.f ), // right - sVec4( 0.f, 1.f, 0.f, -1.f ), // bottom - sVec4( 0.f, -1.f, 0.f, -1.f ) // top + sVec4(0.f, 0.f, -1.f, -1.f), // near + sVec4(0.f, 0.f, 1.f, -1.f), // far + sVec4(1.f, 0.f, 0.f, -1.f), // left + sVec4(-1.f, 0.f, 0.f, -1.f), // right + sVec4(0.f, 1.f, 0.f, -1.f), // bottom + sVec4(0.f, -1.f, 0.f, -1.f) // top }; @@ -892,80 +894,80 @@ const sVec4 CBurningVideoDriver::NDCPlane[6+2] = */ #ifdef IRRLICHT_FAST_MATH -REALINLINE size_t CBurningVideoDriver::clipToFrustumTest ( const s4DVertex* v ) const +REALINLINE size_t CBurningVideoDriver::clipToFrustumTest(const s4DVertex* v) const { size_t flag; f32 test[8]; - const f32 w = - v->Pos.w; + const f32 w = -v->Pos.w; // a conditional move is needed....FCOMI ( but we don't have it ) // so let the fpu calculate and write it back. // cpu makes the compare, interleaving - test[0] = v->Pos.z + w; + test[0] = v->Pos.z + w; test[1] = -v->Pos.z + w; - test[2] = v->Pos.x + w; + test[2] = v->Pos.x + w; test[3] = -v->Pos.x + w; - test[4] = v->Pos.y + w; + test[4] = v->Pos.y + w; test[5] = -v->Pos.y + w; const u32* a = F32_AS_U32_POINTER(test); - flag = (a[0] ) >> 31; + flag = (a[0]) >> 31; flag |= (a[1] & 0x80000000) >> 30; flag |= (a[2] & 0x80000000) >> 29; flag |= (a[3] & 0x80000000) >> 28; flag |= (a[4] & 0x80000000) >> 27; flag |= (a[5] & 0x80000000) >> 26; -/* - flag = (IR ( test[0] ) ) >> 31; - flag |= (IR ( test[1] ) & 0x80000000 ) >> 30; - flag |= (IR ( test[2] ) & 0x80000000 ) >> 29; - flag |= (IR ( test[3] ) & 0x80000000 ) >> 28; - flag |= (IR ( test[4] ) & 0x80000000 ) >> 27; - flag |= (IR ( test[5] ) & 0x80000000 ) >> 26; -*/ -/* - flag = F32_LOWER_EQUAL_0 ( test[0] ); - flag |= F32_LOWER_EQUAL_0 ( test[1] ) << 1; - flag |= F32_LOWER_EQUAL_0 ( test[2] ) << 2; - flag |= F32_LOWER_EQUAL_0 ( test[3] ) << 3; - flag |= F32_LOWER_EQUAL_0 ( test[4] ) << 4; - flag |= F32_LOWER_EQUAL_0 ( test[5] ) << 5; -*/ + /* + flag = (IR ( test[0] ) ) >> 31; + flag |= (IR ( test[1] ) & 0x80000000 ) >> 30; + flag |= (IR ( test[2] ) & 0x80000000 ) >> 29; + flag |= (IR ( test[3] ) & 0x80000000 ) >> 28; + flag |= (IR ( test[4] ) & 0x80000000 ) >> 27; + flag |= (IR ( test[5] ) & 0x80000000 ) >> 26; + */ + /* + flag = F32_LOWER_EQUAL_0 ( test[0] ); + flag |= F32_LOWER_EQUAL_0 ( test[1] ) << 1; + flag |= F32_LOWER_EQUAL_0 ( test[2] ) << 2; + flag |= F32_LOWER_EQUAL_0 ( test[3] ) << 3; + flag |= F32_LOWER_EQUAL_0 ( test[4] ) << 4; + flag |= F32_LOWER_EQUAL_0 ( test[5] ) << 5; + */ return flag; } #else -REALINLINE size_t clipToFrustumTest ( const s4DVertex* v ) +REALINLINE size_t clipToFrustumTest(const s4DVertex* v) { size_t flag = 0; - flag |= v->Pos.z <= v->Pos.w ? VERTEX4D_CLIP_NEAR : 0; - flag |= -v->Pos.z <= v->Pos.w ? VERTEX4D_CLIP_FAR : 0; + flag |= v->Pos.z <= v->Pos.w ? VERTEX4D_CLIP_NEAR : 0; + flag |= -v->Pos.z <= v->Pos.w ? VERTEX4D_CLIP_FAR : 0; - flag |= v->Pos.x <= v->Pos.w ? VERTEX4D_CLIP_LEFT : 0; - flag |= -v->Pos.x <= v->Pos.w ? VERTEX4D_CLIP_RIGHT : 0; + flag |= v->Pos.x <= v->Pos.w ? VERTEX4D_CLIP_LEFT : 0; + flag |= -v->Pos.x <= v->Pos.w ? VERTEX4D_CLIP_RIGHT : 0; - flag |= v->Pos.y <= v->Pos.w ? VERTEX4D_CLIP_BOTTOM : 0; - flag |= -v->Pos.y <= v->Pos.w ? VERTEX4D_CLIP_TOP : 0; + flag |= v->Pos.y <= v->Pos.w ? VERTEX4D_CLIP_BOTTOM : 0; + flag |= -v->Pos.y <= v->Pos.w ? VERTEX4D_CLIP_TOP : 0; -/* - for ( u32 i = 0; i <= 6; ++i ) - { - if (v->Pos.dot_xyzw(NDCPlane[i]) <= 0.f) flag |= ((size_t)1) << i; - } -*/ + /* + for ( u32 i = 0; i <= 6; ++i ) + { + if (v->Pos.dot_xyzw(NDCPlane[i]) <= 0.f) flag |= ((size_t)1) << i; + } + */ return flag; } #endif // _MSC_VER -size_t clipToHyperPlane ( +size_t clipToHyperPlane( s4DVertexPair* burning_restrict dest, const s4DVertexPair* burning_restrict source, const size_t inCount, @@ -979,39 +981,39 @@ size_t clipToHyperPlane ( const s4DVertex* b = source; ipoltype bDotPlane; - bDotPlane = b->Pos.dot_xyzw( plane ); + bDotPlane = b->Pos.dot_xyzw(plane); -/* - for( u32 i = 1; i < inCount + 1; ++i) - { -#if 0 - a = source + (i%inCount)*2; -#else - const s32 condition = i - inCount; - const s32 index = (( ( condition >> 31 ) & ( i ^ condition ) ) ^ condition ) << 1; - a = source + index; -#endif -*/ + /* + for( u32 i = 1; i < inCount + 1; ++i) + { + #if 0 + a = source + (i%inCount)*2; + #else + const s32 condition = i - inCount; + const s32 index = (( ( condition >> 31 ) & ( i ^ condition ) ) ^ condition ) << 1; + a = source + index; + #endif + */ //Sutherland–Hodgman - for(size_t i = 0; i < inCount; ++i) + for (size_t i = 0; i < inCount; ++i) { - a = source + (i == inCount-1 ? 0 : s4DVertex_ofs(i+1)); + a = source + (i == inCount - 1 ? 0 : s4DVertex_ofs(i + 1)); // current point inside - if (ipol_lower_equal_0(a->Pos.dot_xyzw( plane )) ) + if (ipol_lower_equal_0(a->Pos.dot_xyzw(plane))) { // last point outside - if (ipol_greater_0( bDotPlane ) ) + if (ipol_greater_0(bDotPlane)) { // intersect line segment with plane - out->interpolate(*b, *a, bDotPlane / (b->Pos - a->Pos).dot_xyzw(plane) ); + out->interpolate(*b, *a, bDotPlane / (b->Pos - a->Pos).dot_xyzw(plane)); out += sizeof_s4DVertexPairRel; outCount += 1; } // copy current to out //*out = *a; - memcpy_s4DVertexPair( out, a); + memcpy_s4DVertexPair(out, a); b = out; out += sizeof_s4DVertexPairRel; @@ -1020,11 +1022,11 @@ size_t clipToHyperPlane ( else { // current point outside - if (ipol_lower_equal_0( bDotPlane ) ) + if (ipol_lower_equal_0(bDotPlane)) { // previous was inside // intersect line segment with plane - out->interpolate(*b, *a, bDotPlane / (b->Pos - a->Pos).dot_xyzw(plane) ); + out->interpolate(*b, *a, bDotPlane / (b->Pos - a->Pos).dot_xyzw(plane)); out += sizeof_s4DVertexPairRel; outCount += 1; } @@ -1032,7 +1034,7 @@ size_t clipToHyperPlane ( b = a; } - bDotPlane = b->Pos.dot_xyzw( plane ); + bDotPlane = b->Pos.dot_xyzw(plane); } return outCount; @@ -1043,7 +1045,7 @@ size_t clipToHyperPlane ( Clip on all planes. Clipper.data clipmask per face */ -size_t CBurningVideoDriver::clipToFrustum(const size_t vIn /*, const size_t clipmask_for_face*/ ) +size_t CBurningVideoDriver::clipToFrustum(const size_t vIn /*, const size_t clipmask_for_face*/) { s4DVertexPair* v0 = Clipper.data; s4DVertexPair* v1 = Clipper_temp.data; @@ -1065,7 +1067,7 @@ size_t CBurningVideoDriver::clipToFrustum(const size_t vIn /*, const size_t clip //clipMask checked outside - always clip all planes #if 0 - if (0 == (clipMask & ((size_t)1< 0 dest[g].Tex[0] = source[g].Tex[0]; @@ -1147,34 +1149,34 @@ inline void CBurningVideoDriver::ndc_2_dc_and_project (s4DVertexPair* dest,const #endif #if BURNING_MATERIAL_MAX_COLORS > 0 - #ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - dest[g].Color[0] = source[g].Color[0] * iw; // alpha? - #else - dest[g].Color[0] = source[g].Color[0]; - #endif +#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT + dest[g].Color[0] = source[g].Color[0] * iw; // alpha? +#else + dest[g].Color[0] = source[g].Color[0]; +#endif #endif #if BURNING_MATERIAL_MAX_COLORS > 1 #ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - dest[g].Color[1] = source[g].Color[1] * iw; // alpha? + dest[g].Color[1] = source[g].Color[1] * iw; // alpha? #else - dest[g].Color[1] = source[g].Color[1]; + dest[g].Color[1] = source[g].Color[1]; #endif #endif #if BURNING_MATERIAL_MAX_COLORS > 2 #ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - dest[g].Color[2] = source[g].Color[2] * iw; // alpha? + dest[g].Color[2] = source[g].Color[2] * iw; // alpha? #else - dest[g].Color[2] = source[g].Color[2]; + dest[g].Color[2] = source[g].Color[2]; #endif #endif #if BURNING_MATERIAL_MAX_COLORS > 3 #ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - dest[g].Color[3] = source[g].Color[3] * iw; // alpha? + dest[g].Color[3] = source[g].Color[3] * iw; // alpha? #else - dest[g].Color[3] = source[g].Color[3]; + dest[g].Color[3] = source[g].Color[3]; #endif #endif @@ -1187,24 +1189,25 @@ inline void CBurningVideoDriver::ndc_2_dc_and_project (s4DVertexPair* dest,const +#if 0 /*! crossproduct in projected 2D, face */ -REALINLINE f32 CBurningVideoDriver::screenarea_inside(const s4DVertexPair* burning_restrict const face[] ) const +REALINLINE f32 CBurningVideoDriver::screenarea_inside(const s4DVertexPair* burning_restrict const face[]) const { - return ( ((face[1]+1)->Pos.x - (face[0]+1)->Pos.x) * ((face[2]+1)->Pos.y - (face[0]+1)->Pos.y) ) - - ( ((face[2]+1)->Pos.x - (face[0]+1)->Pos.x) * ((face[1]+1)->Pos.y - (face[0]+1)->Pos.y) ); -/* - float signedArea = 0; - for (int k = 1; k < output->count; k++) { - signedArea += (output->vertices[k - 1].values[0] * output->vertices[k - 0].values[1]); - signedArea -= (output->vertices[k - 0].values[0] * output->vertices[k - 1].values[1]); - } -*/ + return (((face[1] + 1)->Pos.x - (face[0] + 1)->Pos.x) * ((face[2] + 1)->Pos.y - (face[0] + 1)->Pos.y)) - + (((face[2] + 1)->Pos.x - (face[0] + 1)->Pos.x) * ((face[1] + 1)->Pos.y - (face[0] + 1)->Pos.y)); + /* + float signedArea = 0; + for (int k = 1; k < output->count; k++) { + signedArea += (output->vertices[k - 1].values[0] * output->vertices[k - 0].values[1]); + signedArea -= (output->vertices[k - 0].values[0] * output->vertices[k - 1].values[1]); + } + */ } -#if 0 -static inline f32 dot(const sVec2& a,const sVec2& b) { return a.x * b.x + a.y * b.y; } + +static inline f32 dot(const sVec2& a, const sVec2& b) { return a.x * b.x + a.y * b.y; } sVec2 dFdx(const sVec2& v) { return v; } sVec2 dFdy(const sVec2& v) { return v; } @@ -1217,7 +1220,8 @@ f32 MipmapLevel(const sVec2& uv, const sVec2& textureSize) } #endif -#define MAT_TEXTURE(tex) ( (video::CSoftwareTexture2*) Material.org.getTexture ( (u32)tex ) ) +//#define MAT_TEXTURE(tex) ( (video::CSoftwareTexture2*) Material.org.getTexture ( (u32)tex ) ) +#define MAT_TEXTURE(tex) ( (video::CSoftwareTexture2*) Material.org.TextureLayer[tex].Texture ) /*! calculate from unprojected. @@ -1227,7 +1231,7 @@ f32 MipmapLevel(const sVec2& uv, const sVec2& textureSize) Atlas problem */ REALINLINE s32 CBurningVideoDriver::lodFactor_inside(const s4DVertexPair* burning_restrict const face[], - const size_t m, f32 dc_area, f32 lod_bias) const + const size_t m, const f32 dc_area, const f32 lod_bias) const { /* sVec2 a(v[1]->Tex[tex].x - v[0]->Tex[tex].x,v[1]->Tex[tex].y - v[0]->Tex[tex].y); @@ -1257,7 +1261,7 @@ REALINLINE s32 CBurningVideoDriver::lodFactor_inside(const s4DVertexPair* burnin // - ((face[2]->Tex[m].x - face[0]->Tex[m].x) * (face[1]->Tex[m].y - face[0]->Tex[m].y)); //if (signedArea*signedArea <= 0.00000000001f) - if (signedArea.fields.exp == 0 ) + if (signedArea.fields.exp == 0) { ieee754 _max; _max.u = t[0].abs.frac_exp; @@ -1267,23 +1271,25 @@ REALINLINE s32 CBurningVideoDriver::lodFactor_inside(const s4DVertexPair* burnin signedArea.u = _max.fields.exp ? _max.u : ieee754_one; -/* - //dot,length - ieee754 v[2]; - v[0].f = t[0] * t[2]; - v[1].f = t[1] * t[3]; + /* + //dot,length + ieee754 v[2]; + v[0].f = t[0] * t[2]; + v[1].f = t[1] * t[3]; - //signedArea.f = t[4] > t[5] ? t[4] : t[5]; - signedArea.u = v[0].fields.frac > v[1].fields.frac ? v[0].u : v[1].u; - if (signedArea.fields.exp == 0) - { - return -1; - } -*/ + //signedArea.f = t[4] > t[5] ? t[4] : t[5]; + signedArea.u = v[0].fields.frac > v[1].fields.frac ? v[0].u : v[1].u; + if (signedArea.fields.exp == 0) + { + return -1; + } + */ } //only guessing: take more detail (lower mipmap) in light+bump textures //assume transparent add is ~50% transparent -> more detail + + // 2.f from dc_area, 2.f from tex triangle ( parallelogram area) const u32* d = MAT_TEXTURE(m)->getMipMap0_Area(); f32 texelspace = d[0] * d[1] * lod_bias; //(m ? 0.5f : 0.5f); @@ -1292,20 +1298,8 @@ REALINLINE s32 CBurningVideoDriver::lodFactor_inside(const s4DVertexPair* burnin ratio.fields.sign = 0; //log2(0)==denormal [ use high lod] [ only if dc_area == 0 checked outside ] -#if 0 - if (ratio.fields.exp == 0) - { - int g = 1; - } -#endif - //log2 return (ratio.fields.exp & 0x80) ? ratio.fields.exp - 127 : 0; /*denormal very high lod*/ - //return (ratio.f <= 1.f) ? 0 : 1; - //f32 texArea = MAT_TEXTURE(m)->getLODFactor(signedArea); // texelarea_inside(face, m); - //s32 lodFactor = s32_log2_f32(texArea * dc_area); /* avoid denorm */ - - //return MAT_TEXTURE(m)->getLODFactor(signedArea); } @@ -1357,15 +1351,15 @@ void CBurningVideoDriver::VertexCache_map_source_format() u32 s0 = sizeof(s4DVertex); u32 s1 = sizeof(s4DVertex_proxy); - if ( s1 <= sizeof_s4DVertex /2 ) + if (s1 <= sizeof_s4DVertex / 2) { - os::Printer::log ( "BurningVideo vertex format unnecessary to large", ELL_WARNING ); + os::Printer::log("BurningVideo vertex format unnecessary to large", ELL_WARNING); } //memcpy_vertex - if ( s0 != sizeof_s4DVertex || ((sizeof_s4DVertex * sizeof_s4DVertexPairRel)&31)) + if (s0 != sizeof_s4DVertex || ((sizeof_s4DVertex * sizeof_s4DVertexPairRel) & 31)) { - os::Printer::log ( "BurningVideo vertex format compile problem", ELL_ERROR ); + os::Printer::log("BurningVideo vertex format compile problem", ELL_ERROR); _IRR_DEBUG_BREAK_IF(1); } @@ -1377,6 +1371,13 @@ void CBurningVideoDriver::VertexCache_map_source_format() } #endif + if (((unsigned long long)Transformation&15) || ((unsigned long long)TransformationFlag & 15)) + { + os::Printer::log("BurningVideo Matrix Stack not 16 byte aligned", ELL_ERROR); + _IRR_DEBUG_BREAK_IF(1); + } + + SVSize* vSize = VertexCache.vSize; //vSize[E4VT_STANDARD].Format = VERTEX4D_FORMAT_TEXTURE_1 | VERTEX4D_FORMAT_COLOR_1 | VERTEX4D_FORMAT_LIGHT_1 | VERTEX4D_FORMAT_SPECULAR; vSize[E4VT_STANDARD].Format = VERTEX4D_FORMAT_TEXTURE_1 | VERTEX4D_FORMAT_COLOR_2_FOG; @@ -1420,30 +1421,30 @@ void CBurningVideoDriver::VertexCache_map_source_format() vSize[E4VT_LINE].TexCooSize = 0; size_t size; - for ( size_t i = 0; i < E4VT_COUNT; ++i ) + for (size_t i = 0; i < E4VT_COUNT; ++i) { size_t& flag = vSize[i].Format; #if !defined(SOFTWARE_DRIVER_2_USE_SEPARATE_SPECULAR_COLOR) flag &= ~VERTEX4D_FORMAT_SPECULAR; #endif - if ( vSize[i].TexSize > BURNING_MATERIAL_MAX_TEXTURES ) + if (vSize[i].TexSize > BURNING_MATERIAL_MAX_TEXTURES) vSize[i].TexSize = BURNING_MATERIAL_MAX_TEXTURES; size = (flag & VERTEX4D_FORMAT_MASK_TEXTURE) >> 16; - if ( size > BURNING_MATERIAL_MAX_TEXTURES ) + if (size > BURNING_MATERIAL_MAX_TEXTURES) { flag = (flag & ~VERTEX4D_FORMAT_MASK_TEXTURE) | (BURNING_MATERIAL_MAX_TEXTURES << 16); } size = (flag & VERTEX4D_FORMAT_MASK_COLOR) >> 20; - if ( size > BURNING_MATERIAL_MAX_COLORS ) + if (size > BURNING_MATERIAL_MAX_COLORS) { flag = (flag & ~VERTEX4D_FORMAT_MASK_COLOR) | (BURNING_MATERIAL_MAX_COLORS << 20); } size = (flag & VERTEX4D_FORMAT_MASK_LIGHT) >> 24; - if ( size > BURNING_MATERIAL_MAX_LIGHT_TANGENT) + if (size > BURNING_MATERIAL_MAX_LIGHT_TANGENT) { flag = (flag & ~VERTEX4D_FORMAT_MASK_LIGHT) | (BURNING_MATERIAL_MAX_LIGHT_TANGENT << 24); } @@ -1461,8 +1462,6 @@ void CBurningVideoDriver::VertexCache_map_source_format() Material.resetRenderStates = true; Material.Fallback_MaterialType = EMT_SOLID; - - } @@ -1476,15 +1475,15 @@ void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex, const u32 dest u8* burning_restrict source; s4DVertex* burning_restrict dest; - source = (u8*) VertexCache.vertices + ( sourceIndex * VertexCache.vSize[VertexCache.vType].Pitch ); + source = (u8*)VertexCache.vertices + (sourceIndex * VertexCache.vSize[VertexCache.vType].Pitch); // it's a look ahead so we never hit it.. // but give priority... //VertexCache.info[ destIndex ].hit = hitCount; // store info - VertexCache.info[ destIndex ].index = sourceIndex; - VertexCache.info[ destIndex ].hit = 0; + VertexCache.info[destIndex].index = sourceIndex; + VertexCache.info[destIndex].hit = 0; // destination Vertex dest = VertexCache.mem.data + s4DVertex_ofs(destIndex); @@ -1520,12 +1519,12 @@ void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex, const u32 dest #if defined (SOFTWARE_DRIVER_2_LIGHTING) || defined ( SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM ) // vertex, normal in light(eye) space - if ( Material.org.Lighting || (EyeSpace.TL_Flag & (TL_TEXTURE_TRANSFORM|TL_FOG)) ) + if (Material.org.Lighting || (EyeSpace.TL_Flag & (TL_TEXTURE_TRANSFORM | TL_FOG))) { sVec4 vertex4; //eye coordinate position of vertex - matrix[ETS_MODEL_VIEW].transformVect ( &vertex4.x, base->Pos ); + matrix[ETS_MODEL_VIEW].transformVect(&vertex4.x, base->Pos); - f32 iw = reciprocal_zero(vertex4.w); + const f32 iw = reciprocal_zero(vertex4.w); EyeSpace.vertex.x = vertex4.x * iw; EyeSpace.vertex.y = vertex4.y * iw; EyeSpace.vertex.z = vertex4.z * iw; @@ -1572,23 +1571,23 @@ void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex, const u32 dest #if BURNING_MATERIAL_MAX_COLORS > 0 -// apply lighting model + // apply lighting model #if defined (SOFTWARE_DRIVER_2_LIGHTING) - if ( Material.org.Lighting ) + if (Material.org.Lighting) { - lightVertex_eye ( dest, base->Color.color ); + lightVertex_eye(dest, base->Color.color); } else { - dest->Color[0].setA8R8G8B8 ( base->Color.color ); + dest->Color[0].setA8R8G8B8(base->Color.color); } #else - dest->Color[0].setA8R8G8B8 ( base->Color.color ); + dest->Color[0].setA8R8G8B8(base->Color.color); #endif #endif //vertex fog - if (EyeSpace.TL_Flag & TL_FOG ) //Material.org.FogEnable + if (EyeSpace.TL_Flag & TL_FOG) //Material.org.FogEnable { f32 fog_factor = 1.f; @@ -1611,230 +1610,151 @@ void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex, const u32 dest } sVec4* a = dest->Color + ((VertexCache.vSize[VertexCache.vType].Format & VERTEX4D_FORMAT_COLOR_2_FOG) ? 1 : 0); - a->a = core::clamp(fog_factor, 0.f, 1.f); + a->a = clampf01(fog_factor); } - // Texture Transform -#if defined ( SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM ) - - if ( 0 == (EyeSpace.TL_Flag & TL_TEXTURE_TRANSFORM) ) -#endif // SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM + // Texture Coo Transform + // Always set all internal uv (v1.9 SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM always on) + for (size_t t = 0; t < BURNING_MATERIAL_MAX_TEXTURES; ++t) { - // Irrlicht TCoords and TCoords2 must be contiguous memory. baseTCoord has no 4 byte aligned start address! - const f32* baseTCoord = &base->TCoords.X; - - switch (VertexCache.vSize[VertexCache.vType].TexCooSize) - { -#if BURNING_MATERIAL_MAX_TEXTURES == 4 - case 0: - dest->Tex[0].x = 0.f; - dest->Tex[0].y = 0.f; - dest->Tex[1].x = 0.f; - dest->Tex[1].y = 0.f; - dest->Tex[2].x = 0.f; - dest->Tex[2].y = 0.f; - dest->Tex[3].x = 0.f; - dest->Tex[3].y = 0.f; - break; - case 1: - dest->Tex[0].x = baseTCoord[0]; - dest->Tex[0].y = baseTCoord[1]; - dest->Tex[1].x = 0.f; - dest->Tex[1].y = 0.f; - dest->Tex[2].x = 0.f; - dest->Tex[2].y = 0.f; - dest->Tex[3].x = 0.f; - dest->Tex[3].y = 0.f; - break; - case 2: - dest->Tex[0].x = baseTCoord[0]; - dest->Tex[0].y = baseTCoord[1]; - dest->Tex[1].x = baseTCoord[2]; - dest->Tex[1].y = baseTCoord[3]; - dest->Tex[2].x = 0.f; - dest->Tex[2].y = 0.f; - dest->Tex[3].x = 0.f; - dest->Tex[3].y = 0.f; - break; - case 3: - dest->Tex[0].x = baseTCoord[0]; - dest->Tex[0].y = baseTCoord[1]; - dest->Tex[1].x = baseTCoord[2]; - dest->Tex[1].y = baseTCoord[3]; - dest->Tex[2].x = baseTCoord[4]; - dest->Tex[2].y = baseTCoord[5]; - dest->Tex[3].x = 0.f; - dest->Tex[3].y = 0.f; - break; - case 4: - dest->Tex[0].x = baseTCoord[0]; - dest->Tex[0].y = baseTCoord[1]; - dest->Tex[1].x = baseTCoord[2]; - dest->Tex[1].y = baseTCoord[3]; - dest->Tex[2].x = baseTCoord[4]; - dest->Tex[2].y = baseTCoord[5]; - dest->Tex[3].x = baseTCoord[6]; - dest->Tex[3].y = baseTCoord[7]; - break; -#endif - -#if BURNING_MATERIAL_MAX_TEXTURES == 2 - case 0: - dest->Tex[0].x = 0.f; - dest->Tex[0].y = 0.f; - dest->Tex[1].x = 0.f; - dest->Tex[1].y = 0.f; - break; - - case 1: - dest->Tex[0].x = baseTCoord[0]; - dest->Tex[0].y = baseTCoord[1]; - dest->Tex[1].x = 0.f; - dest->Tex[1].y = 0.f; - break; - case 2: - dest->Tex[0].x = baseTCoord[0]; - dest->Tex[0].y = baseTCoord[1]; - dest->Tex[1].x = baseTCoord[2]; - dest->Tex[1].y = baseTCoord[3]; - break; -#endif -#if BURNING_MATERIAL_MAX_TEXTURES == 1 - case 0: - dest->Tex[0].x = 0.f; - dest->Tex[0].y = 0.f; - break; - case 1: - dest->Tex[0].x = baseTCoord[0]; - dest->Tex[0].y = baseTCoord[1]; - break; -#endif - default: - break; - } - } -#if defined ( SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM ) - else - { - /* - Generate texture coordinates as linear functions so that: - u = Ux*x + Uy*y + Uz*z + Uw - v = Vx*x + Vy*y + Vz*z + Vw - The matrix M for this case is: - Ux Vx 0 0 - Uy Vy 0 0 - Uz Vz 0 0 - Uw Vw 0 0 - */ - - const sVec4& u = EyeSpace.cam_dir; // EyeSpace.vertex.normalized - const sVec4& n = EyeSpace.normal; sVec4 r; + f32 tx, ty; - const size_t* flag = TransformationFlag[TransformationStack]; - for ( u32 t = 0; t != VertexCache.vSize[VertexCache.vType].TexSize; ++t ) + // texgen + const size_t flag = TransformationFlag[TransformationStack][ETS_TEXTURE_0 + t]; + if (flag & ETF_TEXGEN_CAMERA_SPHERE) { - // texgen - if (flag[ETS_TEXTURE_0+t] & ETF_TEXGEN_CAMERA_SPHERE ) - { - //reflect(u,N) u - 2.0 * dot(N, u) * N - // cam is (0,0,-1), tex flipped - f32 dot = -2.f * n.dot_xyz(u); - r.x = u.x + dot * n.x; - r.y = u.y + dot * n.y; - r.z = u.z + dot * n.z; + //reflect(u,N) u - 2.0 * dot(N, u) * N + // cam is (0,0,-1), tex flipped - //openGL - f32 m = 2.f * sqrtf(r.x*r.x+r.y*r.y+(r.z+1.f)*(r.z+1.f)); - dest[0].Tex[t].x = r.x / m + 0.5f; - dest[0].Tex[t].y = -r.y / m + 0.5f; + const sVec4& u = EyeSpace.cam_dir; // EyeSpace.vertex.normalized + const sVec4& n = EyeSpace.normal; -/* - //~d3d with spheremap scale - f32 m = 0.25f / (0.00001f + sqrtf(r.x*r.x+r.y*r.y+r.z*r.z)); - dest[0].Tex[t].x = r.x * m + 0.5f; - dest[0].Tex[t].y = -r.y * m + 0.5f; -*/ - } - else if (flag[ETS_TEXTURE_0+t] & ETF_TEXGEN_CAMERA_REFLECTION ) - { - //reflect(u,N) u - 2.0 * dot(N, u) * N - // cam is (0,0,-1), tex flipped - f32 dot = -2.f * n.dot_xyz(u); - r.x = u.x + dot * n.x; - r.y = u.y + dot * n.y; - r.z = u.z + dot * n.z; + f32 dot = -2.f * n.dot_xyz(u); + r.x = u.x + dot * n.x; + r.y = u.y + dot * n.y; + r.z = u.z + dot * n.z; - //openGL - dest[0].Tex[t].x = r.x; - dest[0].Tex[t].y = -r.y; -/* + //openGL + f32 m = 2.f * sqrtf(r.x * r.x + r.y * r.y + (r.z + 1.f) * (r.z + 1.f)); + tx = r.x / m + 0.5f; + ty = -r.y / m + 0.5f; + + /* + //~d3d with spheremap scale + f32 m = 0.25f / (0.00001f + sqrtf(r.x*r.x+r.y*r.y+r.z*r.z)); + dest[0].Tex[t].x = r.x * m + 0.5f; + dest[0].Tex[t].y = -r.y * m + 0.5f; + */ + } + else if (flag & ETF_TEXGEN_CAMERA_REFLECTION) + { + //reflect(u,N) u - 2.0 * dot(N, u) * N + // cam is (0,0,-1), tex flipped + + const sVec4& u = EyeSpace.cam_dir; // EyeSpace.vertex.normalized + const sVec4& n = EyeSpace.normal; + + f32 dot = -2.f * n.dot_xyz(u); + r.x = u.x + dot * n.x; + r.y = u.y + dot * n.y; + r.z = u.z + dot * n.z; + + //openGL + tx = r.x; + ty = -r.y; + /* //~d3d with spheremap scale dest[0].Tex[t].x = r.x; dest[0].Tex[t].y = r.y; -*/ - } - else if (VertexCache.vSize[VertexCache.vType].TexCooSize > t) - { - const f32* M = matrix[ETS_TEXTURE_0 + t].pointer(); - - // Irrlicht TCoords and TCoords2 must be contiguous memory. baseTCoord has no 4 byte aligned start address! - const f32* baseTCoord = &base->TCoords.X; - - sVec4 srcT; - srcT.x = baseTCoord[(t * 2) + 0]; - srcT.y = baseTCoord[(t * 2) + 1]; - - switch ( Material.org.TextureLayer[t].TextureWrapU ) - { - case ETC_CLAMP: - case ETC_CLAMP_TO_EDGE: - case ETC_CLAMP_TO_BORDER: - dest->Tex[t].x = core::clamp ( (f32) ( M[0] * srcT.x + M[4] * srcT.y + M[8] ), 0.f, 1.f ); - break; - case ETC_MIRROR: - dest->Tex[t].x = M[0] * srcT.x + M[4] * srcT.y + M[8]; - if (core::fract(dest->Tex[t].x)>0.5f) - dest->Tex[t].x=1.f-dest->Tex[t].x; - break; - case ETC_MIRROR_CLAMP: - case ETC_MIRROR_CLAMP_TO_EDGE: - case ETC_MIRROR_CLAMP_TO_BORDER: - dest->Tex[t].x = core::clamp ( (f32) ( M[0] * srcT.x + M[4] * srcT.y + M[8] ), 0.f, 1.f ); - if (core::fract(dest->Tex[t].x)>0.5f) - dest->Tex[t].x=1.f-dest->Tex[t].x; - break; - case ETC_REPEAT: - default: - dest->Tex[t].x = M[0] * srcT.x + M[4] * srcT.y + M[8]; - break; - } - switch ( Material.org.TextureLayer[t].TextureWrapV ) - { - case ETC_CLAMP: - case ETC_CLAMP_TO_EDGE: - case ETC_CLAMP_TO_BORDER: - dest->Tex[t].y = core::clamp ( (f32) ( M[1] * srcT.x + M[5] * srcT.y + M[9] ), 0.f, 1.f ); - break; - case ETC_MIRROR: - dest->Tex[t].y = M[1] * srcT.x + M[5] * srcT.y + M[9]; - if (core::fract(dest->Tex[t].y)>0.5f) - dest->Tex[t].y=1.f-dest->Tex[t].y; - break; - case ETC_MIRROR_CLAMP: - case ETC_MIRROR_CLAMP_TO_EDGE: - case ETC_MIRROR_CLAMP_TO_BORDER: - dest->Tex[t].y = core::clamp ( (f32) ( M[1] * srcT.x + M[5] * srcT.y + M[9] ), 0.f, 1.f ); - if (core::fract(dest->Tex[t].y)>0.5f) - dest->Tex[t].y=1.f-dest->Tex[t].y; - break; - case ETC_REPEAT: - default: - dest->Tex[t].y = M[1] * srcT.x + M[5] * srcT.y + M[9]; - break; - } - } + */ } + else + if (t < VertexCache.vSize[VertexCache.vType].TexCooSize) + { + // Irrlicht TCoords and TCoords2 must be contiguous memory. baseTCoord has no 4 byte aligned start address! + const sVec2Pack* baseTCoord = (const sVec2Pack*)&base->TCoords.X; + + tx = baseTCoord[t].x; + ty = baseTCoord[t].y; + } + else + { + tx = 0.f; + ty = 0.f; + } + + //transform + if (!(flag & ETF_IDENTITY)) + { + /* + Generate texture coordinates as linear functions so that: + u = Ux*x + Uy*y + Uz*z + Uw + v = Vx*x + Vy*y + Vz*z + Vw + The matrix M for this case is: + Ux Vx 0 0 + Uy Vy 0 0 + Uz Vz 0 0 + Uw Vw 0 0 + */ + + const f32* M = matrix[ETS_TEXTURE_0 + t].pointer(); + + f32 _tx = tx; + f32 _ty = ty; + tx = M[0] * _tx + M[4] * _ty + M[8]; + ty = M[1] * _tx + M[5] * _ty + M[9]; + } + + switch (Material.org.TextureLayer[t].TextureWrapU) + { + case ETC_CLAMP: + case ETC_CLAMP_TO_EDGE: + case ETC_CLAMP_TO_BORDER: + tx = clampf01(tx); + break; + case ETC_MIRROR: + if (core::fract(tx) > 0.5f) + tx = 1.f - tx; + break; + case ETC_MIRROR_CLAMP: + case ETC_MIRROR_CLAMP_TO_EDGE: + case ETC_MIRROR_CLAMP_TO_BORDER: + tx = clampf01(tx); + if (core::fract(tx) > 0.5f) + tx = 1.f - tx; + break; + case ETC_REPEAT: + // texel access is always modulo + default: + break; + } + switch (Material.org.TextureLayer[t].TextureWrapV) + { + case ETC_CLAMP: + case ETC_CLAMP_TO_EDGE: + case ETC_CLAMP_TO_BORDER: + ty = clampf01(ty); + break; + case ETC_MIRROR: + if (core::fract(ty) > 0.5f) + ty = 1.f - ty; + break; + case ETC_MIRROR_CLAMP: + case ETC_MIRROR_CLAMP_TO_EDGE: + case ETC_MIRROR_CLAMP_TO_BORDER: + ty = clampf01(ty); + if (core::fract(ty) > 0.5f) + ty = 1.f - ty; + break; + case ETC_REPEAT: + // texel access is always modulo + default: + break; + } + + dest->Tex[t].x = tx; + dest->Tex[t].y = ty; } @@ -1843,7 +1763,7 @@ void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex, const u32 dest ((VertexCache.vSize[VertexCache.vType].Format & VERTEX4D_FORMAT_MASK_TANGENT) == VERTEX4D_FORMAT_BUMP_DOT3) ) { - const S3DVertexTangents *tangent = ((S3DVertexTangents*) source ); + const S3DVertexTangents* tangent = ((S3DVertexTangents*)source); sVec4 vp; sVec4 light_accu; @@ -1851,10 +1771,10 @@ void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex, const u32 dest light_accu.y = 0.f; light_accu.z = 0.f; light_accu.w = 0.f; - for ( u32 i = 0; i < 2 && i < EyeSpace.Light.size (); ++i ) + for (u32 i = 0; i < 2 && i < EyeSpace.Light.size(); ++i) { - const SBurningShaderLight &light = EyeSpace.Light[i]; - if ( !light.LightIsOn ) + const SBurningShaderLight& light = EyeSpace.Light[i]; + if (!light.LightIsOn) continue; // lightcolor with standard model @@ -1870,12 +1790,12 @@ void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex, const u32 dest #endif // transform by tangent matrix - light_accu.x += (vp.x * tangent->Tangent.X + vp.y * tangent->Tangent.Y + vp.z * tangent->Tangent.Z ); - light_accu.y += (vp.x * tangent->Binormal.X + vp.y * tangent->Binormal.Y + vp.z * tangent->Binormal.Z ); - light_accu.z += (vp.x * tangent->Normal.X + vp.y * tangent->Normal.Y + vp.z * tangent->Normal.Z ); + light_accu.x += (vp.x * tangent->Tangent.X + vp.y * tangent->Tangent.Y + vp.z * tangent->Tangent.Z); + light_accu.y += (vp.x * tangent->Binormal.X + vp.y * tangent->Binormal.Y + vp.z * tangent->Binormal.Z); + light_accu.z += (vp.x * tangent->Normal.X + vp.y * tangent->Normal.Y + vp.z * tangent->Normal.Z); } //normalize [-1,+1] to [0,1] -> obsolete - light_accu.normalize_pack_xyz(dest->LightTangent[0],1.f, 0.f); + light_accu.normalize_pack_xyz(dest->LightTangent[0], 1.f, 0.f); dest->Tex[1].x = dest->Tex[0].x; dest->Tex[1].y = dest->Tex[0].y; @@ -1888,29 +1808,29 @@ void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex, const u32 dest } #endif //if BURNING_MATERIAL_MAX_LIGHT_TANGENT > 0 -#endif // SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM +//#endif // SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM clipandproject: // test vertex visible - dest[0].flag = (u32) (clipToFrustumTest(dest) | VertexCache.vSize[VertexCache.vType].Format); + dest[0].flag = (u32)(clipToFrustumTest(dest) | VertexCache.vSize[VertexCache.vType].Format); dest[1].flag = dest[0].flag; // to DC Space, project homogenous vertex - if ( (dest[0].flag & VERTEX4D_CLIPMASK ) == VERTEX4D_INSIDE ) + if ((dest[0].flag & VERTEX4D_CLIPMASK) == VERTEX4D_INSIDE) { - ndc_2_dc_and_project ( dest+1, dest, s4DVertex_ofs(1)); + ndc_2_dc_and_project(dest + s4DVertex_proj(0), dest + s4DVertex_ofs(0), s4DVertex_ofs(1)); } } //todo: this should return only index -s4DVertexPair* CBurningVideoDriver::VertexCache_getVertex ( const u32 sourceIndex ) const +s4DVertexPair* CBurningVideoDriver::VertexCache_getVertex(const u32 sourceIndex) const { - for ( size_t i = 0; i < VERTEXCACHE_ELEMENT; ++i ) + for (size_t i = 0; i < VERTEXCACHE_ELEMENT; ++i) { - if ( VertexCache.info[ i ].index == sourceIndex ) + if (VertexCache.info[i].index == sourceIndex) { return VertexCache.mem.data + s4DVertex_ofs(i); } @@ -1927,8 +1847,8 @@ s4DVertexPair* CBurningVideoDriver::VertexCache_getVertex ( const u32 sourceInde void CBurningVideoDriver::VertexCache_get(s4DVertexPair* face[4]) { // next primitive must be complete in cache - if ( VertexCache.indicesIndex - VertexCache.indicesRun < VertexCache.primitiveHasVertex && - VertexCache.indicesIndex < VertexCache.indexCount + if (VertexCache.indicesIndex - VertexCache.indicesRun < VertexCache.primitiveHasVertex && + VertexCache.indicesIndex < VertexCache.indexCount ) { @@ -1949,74 +1869,74 @@ void CBurningVideoDriver::VertexCache_get(s4DVertexPair* face[4]) u32 dIndex = 0; u32 sourceIndex = 0; - while ( VertexCache.indicesIndex < VertexCache.indexCount && - fillIndex < VERTEXCACHE_ELEMENT - ) + while (VertexCache.indicesIndex < VertexCache.indexCount && + fillIndex < VERTEXCACHE_ELEMENT + ) { - switch ( VertexCache.iType ) + switch (VertexCache.iType) { - case E4IT_16BIT: - sourceIndex = ((u16*)VertexCache.indices) [ VertexCache.indicesIndex ]; - break; - case E4IT_32BIT: - sourceIndex = ((u32*)VertexCache.indices) [ VertexCache.indicesIndex ]; - break; - default: - case E4IT_NONE: - sourceIndex = VertexCache.indicesIndex; - break; + case E4IT_16BIT: + sourceIndex = ((u16*)VertexCache.indices)[VertexCache.indicesIndex]; + break; + case E4IT_32BIT: + sourceIndex = ((u32*)VertexCache.indices)[VertexCache.indicesIndex]; + break; + default: + case E4IT_NONE: + sourceIndex = VertexCache.indicesIndex; + break; } VertexCache.indicesIndex += 1; // if not exist, push back s32 exist = 0; - for ( dIndex = 0; dIndex < fillIndex; ++dIndex ) + for (dIndex = 0; dIndex < fillIndex; ++dIndex) { - if (VertexCache.info_temp[ dIndex ].index == sourceIndex ) + if (VertexCache.info_temp[dIndex].index == sourceIndex) { exist = 1; break; } } - if ( 0 == exist ) + if (0 == exist) { VertexCache.info_temp[fillIndex++].index = sourceIndex; } } // clear marks - for ( i = 0; i!= VERTEXCACHE_ELEMENT; ++i ) + for (i = 0; i != VERTEXCACHE_ELEMENT; ++i) { VertexCache.info[i].hit = 0; } // mark all existing - for ( i = 0; i!= fillIndex; ++i ) + for (i = 0; i != fillIndex; ++i) { - for ( dIndex = 0; dIndex < VERTEXCACHE_ELEMENT; ++dIndex ) + for (dIndex = 0; dIndex < VERTEXCACHE_ELEMENT; ++dIndex) { - if ( VertexCache.info[ dIndex ].index == VertexCache.info_temp[i].index ) + if (VertexCache.info[dIndex].index == VertexCache.info_temp[i].index) { VertexCache.info_temp[i].hit = dIndex; - VertexCache.info[ dIndex ].hit = 1; + VertexCache.info[dIndex].hit = 1; break; } } } // fill new - for ( i = 0; i!= fillIndex; ++i ) + for (i = 0; i != fillIndex; ++i) { - if (VertexCache.info_temp[i].hit != VERTEXCACHE_MISS ) + if (VertexCache.info_temp[i].hit != VERTEXCACHE_MISS) continue; - for ( dIndex = 0; dIndex < VERTEXCACHE_ELEMENT; ++dIndex ) + for (dIndex = 0; dIndex < VERTEXCACHE_ELEMENT; ++dIndex) { - if ( 0 == VertexCache.info[dIndex].hit ) + if (0 == VertexCache.info[dIndex].hit) { - VertexCache_fill (VertexCache.info_temp[i].index, dIndex ); + VertexCache_fill(VertexCache.info_temp[i].index, dIndex); VertexCache.info[dIndex].hit += 1; VertexCache.info_temp[i].hit = dIndex; break; @@ -2028,33 +1948,33 @@ void CBurningVideoDriver::VertexCache_get(s4DVertexPair* face[4]) //const u32 i0 = core::if_c_a_else_0 ( VertexCache.pType != scene::EPT_TRIANGLE_FAN, VertexCache.indicesRun ); const u32 i0 = VertexCache.pType != scene::EPT_TRIANGLE_FAN ? VertexCache.indicesRun : 0; - switch ( VertexCache.iType ) + switch (VertexCache.iType) { - case E4IT_16BIT: - { - const u16* p = (const u16*) VertexCache.indices; - face[0] = VertexCache_getVertex ( p[ i0 ] ); - face[1] = VertexCache_getVertex ( p[ VertexCache.indicesRun + 1] ); - face[2] = VertexCache_getVertex ( p[ VertexCache.indicesRun + 2] ); - } - break; + case E4IT_16BIT: + { + const u16* p = (const u16*)VertexCache.indices; + face[0] = VertexCache_getVertex(p[i0]); + face[1] = VertexCache_getVertex(p[VertexCache.indicesRun + 1]); + face[2] = VertexCache_getVertex(p[VertexCache.indicesRun + 2]); + } + break; - case E4IT_32BIT: - { - const u32* p = (const u32*) VertexCache.indices; - face[0] = VertexCache_getVertex ( p[ i0 ] ); - face[1] = VertexCache_getVertex ( p[ VertexCache.indicesRun + 1] ); - face[2] = VertexCache_getVertex ( p[ VertexCache.indicesRun + 2] ); - } - break; + case E4IT_32BIT: + { + const u32* p = (const u32*)VertexCache.indices; + face[0] = VertexCache_getVertex(p[i0]); + face[1] = VertexCache_getVertex(p[VertexCache.indicesRun + 1]); + face[2] = VertexCache_getVertex(p[VertexCache.indicesRun + 2]); + } + break; - case E4IT_NONE: - face[0] = VertexCache_getVertex ( VertexCache.indicesRun + 0 ); - face[1] = VertexCache_getVertex ( VertexCache.indicesRun + 1 ); - face[2] = VertexCache_getVertex ( VertexCache.indicesRun + 2 ); + case E4IT_NONE: + face[0] = VertexCache_getVertex(VertexCache.indicesRun + 0); + face[1] = VertexCache_getVertex(VertexCache.indicesRun + 1); + face[2] = VertexCache_getVertex(VertexCache.indicesRun + 2); break; - default: - face[0] = face[1] = face[2] = VertexCache_getVertex(VertexCache.indicesRun + 0); + default: + face[0] = face[1] = face[2] = VertexCache_getVertex(VertexCache.indicesRun + 0); break; } face[3] = face[0]; // quad unsupported @@ -2064,11 +1984,11 @@ void CBurningVideoDriver::VertexCache_get(s4DVertexPair* face[4]) /*! */ -int CBurningVideoDriver::VertexCache_reset ( const void* vertices, u32 vertexCount, - const void* indices, u32 primitiveCount, - E_VERTEX_TYPE vType, - scene::E_PRIMITIVE_TYPE pType, - E_INDEX_TYPE iType) +int CBurningVideoDriver::VertexCache_reset(const void* vertices, u32 vertexCount, + const void* indices, u32 primitiveCount, + E_VERTEX_TYPE vType, + scene::E_PRIMITIVE_TYPE pType, + E_INDEX_TYPE iType) { // These calls would lead to crashes due to wrong index usage. @@ -2087,18 +2007,18 @@ int CBurningVideoDriver::VertexCache_reset ( const void* vertices, u32 vertexCou switch (Material.org.MaterialType) // (Material.Fallback_MaterialType) { - case EMT_REFLECTION_2_LAYER: - case EMT_TRANSPARENT_REFLECTION_2_LAYER: - VertexCache.vType = E4VT_REFLECTION_MAP; - break; - default: - VertexCache.vType = (e4DVertexType)vType; - break; + case EMT_REFLECTION_2_LAYER: + case EMT_TRANSPARENT_REFLECTION_2_LAYER: + VertexCache.vType = E4VT_REFLECTION_MAP; + break; + default: + VertexCache.vType = (e4DVertexType)vType; + break; } //check material SVSize* vSize = VertexCache.vSize; - for (int m = (int)vSize[VertexCache.vType].TexSize-1; m >= 0 ; --m) + for (int m = (int)vSize[VertexCache.vType].TexSize - 1; m >= 0; --m) { ITexture* tex = MAT_TEXTURE(m); if (!tex) @@ -2115,12 +2035,12 @@ int CBurningVideoDriver::VertexCache_reset ( const void* vertices, u32 vertexCou VertexCache.indicesIndex = 0; VertexCache.indicesRun = 0; - switch ( iType ) + switch (iType) { - case EIT_16BIT: VertexCache.iType = E4IT_16BIT; break; - case EIT_32BIT: VertexCache.iType = E4IT_32BIT; break; - default: - VertexCache.iType = (e4DIndexType)iType; break; + case EIT_16BIT: VertexCache.iType = E4IT_16BIT; break; + case EIT_32BIT: VertexCache.iType = E4IT_32BIT; break; + default: + VertexCache.iType = (e4DIndexType)iType; break; } if (!VertexCache.indices) VertexCache.iType = E4IT_NONE; @@ -2128,65 +2048,65 @@ int CBurningVideoDriver::VertexCache_reset ( const void* vertices, u32 vertexCou VertexCache.pType = pType; VertexCache.primitiveHasVertex = 3; VertexCache.indicesPitch = 1; - switch ( VertexCache.pType ) + switch (VertexCache.pType) { // most types here will not work as expected, only triangles/triangle_fan // is known to work. - case scene::EPT_POINTS: - VertexCache.indexCount = primitiveCount; - VertexCache.indicesPitch = 1; - VertexCache.primitiveHasVertex = 1; - break; - case scene::EPT_LINE_STRIP: - VertexCache.indexCount = primitiveCount+1; - VertexCache.indicesPitch = 1; - VertexCache.primitiveHasVertex = 2; - break; - case scene::EPT_LINE_LOOP: - VertexCache.indexCount = primitiveCount+1; - VertexCache.indicesPitch = 1; - VertexCache.primitiveHasVertex = 2; - break; - case scene::EPT_LINES: - VertexCache.indexCount = 2*primitiveCount; - VertexCache.indicesPitch = 2; - VertexCache.primitiveHasVertex = 2; - break; - case scene::EPT_TRIANGLE_STRIP: - VertexCache.indexCount = primitiveCount+2; - VertexCache.indicesPitch = 1; - VertexCache.primitiveHasVertex = 3; - break; - case scene::EPT_TRIANGLES: - VertexCache.indexCount = primitiveCount + primitiveCount + primitiveCount; - VertexCache.indicesPitch = 3; - VertexCache.primitiveHasVertex = 3; - break; - case scene::EPT_TRIANGLE_FAN: - VertexCache.indexCount = primitiveCount + 2; - VertexCache.indicesPitch = 1; - VertexCache.primitiveHasVertex = 3; - break; - case scene::EPT_QUAD_STRIP: - VertexCache.indexCount = 2*primitiveCount + 2; - VertexCache.indicesPitch = 2; - VertexCache.primitiveHasVertex = 4; - break; - case scene::EPT_QUADS: - VertexCache.indexCount = 4*primitiveCount; - VertexCache.indicesPitch = 4; - VertexCache.primitiveHasVertex = 4; - break; - case scene::EPT_POLYGON: - VertexCache.indexCount = primitiveCount+1; - VertexCache.indicesPitch = 1; - VertexCache.primitiveHasVertex = primitiveCount; - break; - case scene::EPT_POINT_SPRITES: - VertexCache.indexCount = primitiveCount; - VertexCache.indicesPitch = 1; - VertexCache.primitiveHasVertex = 1; - break; + case scene::EPT_POINTS: + VertexCache.indexCount = primitiveCount; + VertexCache.indicesPitch = 1; + VertexCache.primitiveHasVertex = 1; + break; + case scene::EPT_LINE_STRIP: + VertexCache.indexCount = primitiveCount + 1; + VertexCache.indicesPitch = 1; + VertexCache.primitiveHasVertex = 2; + break; + case scene::EPT_LINE_LOOP: + VertexCache.indexCount = primitiveCount + 1; + VertexCache.indicesPitch = 1; + VertexCache.primitiveHasVertex = 2; + break; + case scene::EPT_LINES: + VertexCache.indexCount = 2 * primitiveCount; + VertexCache.indicesPitch = 2; + VertexCache.primitiveHasVertex = 2; + break; + case scene::EPT_TRIANGLE_STRIP: + VertexCache.indexCount = primitiveCount + 2; + VertexCache.indicesPitch = 1; + VertexCache.primitiveHasVertex = 3; + break; + case scene::EPT_TRIANGLES: + VertexCache.indexCount = primitiveCount + primitiveCount + primitiveCount; + VertexCache.indicesPitch = 3; + VertexCache.primitiveHasVertex = 3; + break; + case scene::EPT_TRIANGLE_FAN: + VertexCache.indexCount = primitiveCount + 2; + VertexCache.indicesPitch = 1; + VertexCache.primitiveHasVertex = 3; + break; + case scene::EPT_QUAD_STRIP: + VertexCache.indexCount = 2 * primitiveCount + 2; + VertexCache.indicesPitch = 2; + VertexCache.primitiveHasVertex = 4; + break; + case scene::EPT_QUADS: + VertexCache.indexCount = 4 * primitiveCount; + VertexCache.indicesPitch = 4; + VertexCache.primitiveHasVertex = 4; + break; + case scene::EPT_POLYGON: + VertexCache.indexCount = primitiveCount + 1; + VertexCache.indicesPitch = 1; + VertexCache.primitiveHasVertex = primitiveCount; + break; + case scene::EPT_POINT_SPRITES: + VertexCache.indexCount = primitiveCount; + VertexCache.indicesPitch = 1; + VertexCache.primitiveHasVertex = 1; + break; } //memset( VertexCache.info, VERTEXCACHE_MISS, sizeof ( VertexCache.info ) ); @@ -2201,8 +2121,8 @@ int CBurningVideoDriver::VertexCache_reset ( const void* vertices, u32 vertexCou //! draws a vertex primitive list void CBurningVideoDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, - const void* indexList, u32 primitiveCount, - E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) + const void* indexList, u32 primitiveCount, + E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) { if (!checkPrimitiveCount(primitiveCount)) @@ -2220,7 +2140,7 @@ void CBurningVideoDriver::drawVertexPrimitiveList(const void* vertices, u32 vert //Matrices needed for this primitive transform_calc(ETS_PROJ_MODEL_VIEW); - if ( Material.org.Lighting || (EyeSpace.TL_Flag & (TL_TEXTURE_TRANSFORM | TL_FOG)) ) + if (Material.org.Lighting || (EyeSpace.TL_Flag & (TL_TEXTURE_TRANSFORM | TL_FOG))) { transform_calc(ETS_MODEL_VIEW); transform_calc(ETS_NORMAL); @@ -2233,7 +2153,7 @@ void CBurningVideoDriver::drawVertexPrimitiveList(const void* vertices, u32 vert size_t vertex_from_clipper; // from VertexCache or CurrentOut size_t has_vertex_run; - for ( size_t primitive_run = 0; primitive_run < primitiveCount; ++primitive_run) + for (size_t primitive_run = 0; primitive_run < primitiveCount; ++primitive_run) { //collect pointer to face vertices VertexCache_get(face); @@ -2253,14 +2173,14 @@ void CBurningVideoDriver::drawVertexPrimitiveList(const void* vertices, u32 vert clipMask_i &= VERTEX4D_CLIPMASK; clipMask_o &= VERTEX4D_CLIPMASK; - if (clipMask_i != VERTEX4D_INSIDE ) + if (clipMask_i != VERTEX4D_INSIDE) { // if primitive fully outside or outside on same side continue; vOut = 0; vertex_from_clipper = 0; } - else if (clipMask_o == VERTEX4D_INSIDE ) + else if (clipMask_o == VERTEX4D_INSIDE) { // if primitive fully inside vOut = VertexCache.primitiveHasVertex; @@ -2280,7 +2200,7 @@ void CBurningVideoDriver::drawVertexPrimitiveList(const void* vertices, u32 vert vertex_from_clipper = 1; // to DC Space, project homogenous vertex - ndc_2_dc_and_project(Clipper.data + s4DVertex_proj(0), Clipper.data, s4DVertex_ofs(vOut)); + ndc_2_dc_and_project(Clipper.data + s4DVertex_proj(0), Clipper.data + s4DVertex_ofs(0), s4DVertex_ofs(vOut)); } #else { @@ -2301,7 +2221,19 @@ void CBurningVideoDriver::drawVertexPrimitiveList(const void* vertices, u32 vert } //area of primitive in device space - f32 dc_area = screenarea_inside(face); + // projected triangle screen area is used for culling ( sign of normal ) and mipmap selection + //f32 dc_area = screenarea_inside(face); + + // crossproduct (area of parallelogram * 0.5 = triangle screen size) + f32 dc_area; + { + const sVec4& v0 = (face[0] + s4DVertex_proj(0))->Pos; + const sVec4& v1 = (face[1] + s4DVertex_proj(0))->Pos; + const sVec4& v2 = (face[2] + s4DVertex_proj(0))->Pos; + + //dc_area = a.x * b.y - b.x * a.y; + dc_area = ((v1.x - v0.x) * (v2.y - v0.y) - (v2.x - v0.x) * (v1.y - v0.y)) * 0.5f; + } //geometric clipping has problem with invisible or very small Triangles //size_t sign = dc_area < 0.001f ? CULL_BACK : dc_area > 0.001f ? CULL_FRONT : CULL_INVISIBLE; @@ -2312,7 +2244,7 @@ void CBurningVideoDriver::drawVertexPrimitiveList(const void* vertices, u32 vert if (Material.CullFlag & sign) break; //continue; - //select mipmap ratio between drawing space and texture space + //select mipmap ratio between drawing space and texture space (for multiply divide here) dc_area = reciprocal_zero(dc_area); // select mipmap @@ -2321,17 +2253,29 @@ void CBurningVideoDriver::drawVertexPrimitiveList(const void* vertices, u32 vert video::CSoftwareTexture2* tex = MAT_TEXTURE(m); //only guessing: take more detail (lower mipmap) in light+bump textures + f32 lod_bias = 0.100f;// core::clamp(map_value((f32)ScreenSize.Width * ScreenSize.Height, 160 * 120, 640 * 480, 1.f / 8.f, 1.f / 8.f), 0.01f, 1.f); + //assume transparent add is ~50% transparent -> more detail - f32 lod_bias = Material.org.MaterialType == EMT_TRANSPARENT_ADD_COLOR ? 0.1f : 0.33f; + switch (Material.org.MaterialType) + { + case EMT_TRANSPARENT_ADD_COLOR: + case EMT_TRANSPARENT_ALPHA_CHANNEL: + lod_bias *= 0.5f; + break; + default: + break; + } lod_bias *= tex->get_lod_bias(); + //lod_bias += Material.org.TextureLayer[m].LODBias * 0.125f; + s32 lodFactor = lodFactor_inside(face, m, dc_area, lod_bias); CurrentShader->setTextureParam(m, tex, lodFactor); //currently shader receives texture coordinate as Pixelcoo of 1 Texture select_polygon_mipmap_inside(face, m, tex->getTexBound()); } - - CurrentShader->drawWireFrameTriangle(face[0] + 1, face[1] + 1, face[2] + 1); + + CurrentShader->drawWireFrameTriangle(face[0] + s4DVertex_proj(0), face[1] + s4DVertex_proj(0), face[2] + s4DVertex_proj(0)); vertex_from_clipper = 1; } @@ -2351,23 +2295,23 @@ void CBurningVideoDriver::drawVertexPrimitiveList(const void* vertices, u32 vert //! \param color: New color of the ambient light. void CBurningVideoDriver::setAmbientLight(const SColorf& color) { - EyeSpace.Global_AmbientLight.setColorf ( color ); + EyeSpace.Global_AmbientLight.setColorf(color); } //! adds a dynamic light s32 CBurningVideoDriver::addDynamicLight(const SLight& dl) { - (void) CNullDriver::addDynamicLight( dl ); + (void)CNullDriver::addDynamicLight(dl); SBurningShaderLight l; -// l.org = dl; + // l.org = dl; l.Type = dl.Type; l.LightIsOn = true; - l.AmbientColor.setColorf ( dl.AmbientColor ); - l.DiffuseColor.setColorf ( dl.DiffuseColor ); - l.SpecularColor.setColorf ( dl.SpecularColor ); + l.AmbientColor.setColorf(dl.AmbientColor); + l.DiffuseColor.setColorf(dl.DiffuseColor); + l.SpecularColor.setColorf(dl.SpecularColor); //should always be valid? sVec4 nDirection; @@ -2377,77 +2321,77 @@ s32 CBurningVideoDriver::addDynamicLight(const SLight& dl) nDirection.normalize_dir_xyz(); - switch ( dl.Type ) + switch (dl.Type) { - case ELT_DIRECTIONAL: - l.pos.x = dl.Position.X; - l.pos.y = dl.Position.Y; - l.pos.z = dl.Position.Z; - l.pos.w = 0.f; + case ELT_DIRECTIONAL: + l.pos.x = dl.Position.X; + l.pos.y = dl.Position.Y; + l.pos.z = dl.Position.Z; + l.pos.w = 0.f; - l.constantAttenuation = 1.f; - l.linearAttenuation = 0.f; - l.quadraticAttenuation = 0.f; + l.constantAttenuation = 1.f; + l.linearAttenuation = 0.f; + l.quadraticAttenuation = 0.f; - l.spotDirection.x = -nDirection.x; - l.spotDirection.y = -nDirection.y; - l.spotDirection.z = -nDirection.z; - l.spotDirection.w = 0.f; - l.spotCosCutoff = -1.f; - l.spotCosInnerCutoff = 1.f; - l.spotExponent = 0.f; - break; + l.spotDirection.x = -nDirection.x; + l.spotDirection.y = -nDirection.y; + l.spotDirection.z = -nDirection.z; + l.spotDirection.w = 0.f; + l.spotCosCutoff = -1.f; + l.spotCosInnerCutoff = 1.f; + l.spotExponent = 0.f; + break; - case ELT_POINT: - l.pos.x = dl.Position.X; - l.pos.y = dl.Position.Y; - l.pos.z = dl.Position.Z; - l.pos.w = 1.f; + case ELT_POINT: + l.pos.x = dl.Position.X; + l.pos.y = dl.Position.Y; + l.pos.z = dl.Position.Z; + l.pos.w = 1.f; - l.constantAttenuation = dl.Attenuation.X; - l.linearAttenuation = dl.Attenuation.Y; - l.quadraticAttenuation = dl.Attenuation.Z; + l.constantAttenuation = dl.Attenuation.X; + l.linearAttenuation = dl.Attenuation.Y; + l.quadraticAttenuation = dl.Attenuation.Z; - l.spotDirection.x = -nDirection.x; - l.spotDirection.y = -nDirection.y; - l.spotDirection.z = -nDirection.z; - l.spotDirection.w = 0.f; - l.spotCosCutoff = -1.f; - l.spotCosInnerCutoff = 1.f; - l.spotExponent = 0.f; - break; + l.spotDirection.x = -nDirection.x; + l.spotDirection.y = -nDirection.y; + l.spotDirection.z = -nDirection.z; + l.spotDirection.w = 0.f; + l.spotCosCutoff = -1.f; + l.spotCosInnerCutoff = 1.f; + l.spotExponent = 0.f; + break; - case ELT_SPOT: - l.pos.x = dl.Position.X; - l.pos.y = dl.Position.Y; - l.pos.z = dl.Position.Z; - l.pos.w = 1.f; + case ELT_SPOT: + l.pos.x = dl.Position.X; + l.pos.y = dl.Position.Y; + l.pos.z = dl.Position.Z; + l.pos.w = 1.f; - l.constantAttenuation = dl.Attenuation.X; - l.linearAttenuation = dl.Attenuation.Y; - l.quadraticAttenuation = dl.Attenuation.Z; + l.constantAttenuation = dl.Attenuation.X; + l.linearAttenuation = dl.Attenuation.Y; + l.quadraticAttenuation = dl.Attenuation.Z; - l.spotDirection.x = nDirection.x; - l.spotDirection.y = nDirection.y; - l.spotDirection.z = nDirection.z; - l.spotDirection.w = 0.0f; - l.spotCosCutoff = cosf(dl.OuterCone * 2.0f * core::DEGTORAD * 0.5f); - l.spotCosInnerCutoff = cosf(dl.InnerCone * 2.0f * core::DEGTORAD * 0.5f); - l.spotExponent = dl.Falloff; - break; - default: - break; + l.spotDirection.x = nDirection.x; + l.spotDirection.y = nDirection.y; + l.spotDirection.z = nDirection.z; + l.spotDirection.w = 0.0f; + l.spotCosCutoff = cosf(dl.OuterCone * 2.0f * core::DEGTORAD * 0.5f); + l.spotCosInnerCutoff = cosf(dl.InnerCone * 2.0f * core::DEGTORAD * 0.5f); + l.spotExponent = dl.Falloff; + break; + default: + break; } //which means ETS_VIEW - setTransform(ETS_WORLD,irr::core::IdentityMatrix); + setTransform(ETS_WORLD, irr::core::IdentityMatrix); transform_calc(ETS_MODEL_VIEW); const core::matrix4* matrix = Transformation[TransformationStack]; - transformVec4Vec4(matrix[ETS_MODEL_VIEW], &l.pos4.x, &l.pos.x ); - rotateVec3Vec4(matrix[ETS_MODEL_VIEW], &l.spotDirection4.x, &l.spotDirection.x ); + transformVec4Vec4(matrix[ETS_MODEL_VIEW], &l.pos4.x, &l.pos.x); + rotateVec3Vec4(matrix[ETS_MODEL_VIEW], &l.spotDirection4.x, &l.spotDirection.x); - EyeSpace.Light.push_back ( l ); + EyeSpace.Light.push_back(l); return EyeSpace.Light.size() - 1; } @@ -2455,7 +2399,7 @@ s32 CBurningVideoDriver::addDynamicLight(const SLight& dl) //! Turns a dynamic light on or off void CBurningVideoDriver::turnLightOn(s32 lightIndex, bool turnOn) { - if((u32)lightIndex < EyeSpace.Light.size()) + if ((u32)lightIndex < EyeSpace.Light.size()) { EyeSpace.Light[lightIndex].LightIsOn = turnOn; } @@ -2464,7 +2408,7 @@ void CBurningVideoDriver::turnLightOn(s32 lightIndex, bool turnOn) //! deletes all dynamic lights there are void CBurningVideoDriver::deleteAllDynamicLights() { - EyeSpace.reset (); + EyeSpace.reset(); CNullDriver::deleteAllDynamicLights(); } @@ -2479,14 +2423,14 @@ u32 CBurningVideoDriver::getMaximalDynamicLightAmount() const //! sets a material void CBurningVideoDriver::setMaterial(const SMaterial& material) { -// ---------- Override + // ---------- Override Material.org = material; OverrideMaterial.apply(Material.org); const SMaterial& in = Material.org; -// ---------- Notify Shader - // unset old material + // ---------- Notify Shader + // unset old material u32 mi; mi = (u32)Material.lastMaterial.MaterialType; if (mi != material.MaterialType && mi < MaterialRenderers.size()) @@ -2515,27 +2459,27 @@ void CBurningVideoDriver::setMaterial(const SMaterial& material) #ifdef SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM for (u32 m = 0; m < BURNING_MATERIAL_MAX_TEXTURES /*&& m < vSize[VertexCache.vType].TexSize*/; ++m) { - setTransform((E_TRANSFORMATION_STATE) (ETS_TEXTURE_0 + m),in.getTextureMatrix(m)); - flag[ETS_TEXTURE_0+m] &= ~ETF_TEXGEN_MASK; + setTransform((E_TRANSFORMATION_STATE)(ETS_TEXTURE_0 + m), in.getTextureMatrix(m)); + flag[ETS_TEXTURE_0 + m] &= ~ETF_TEXGEN_MASK; } #endif #ifdef SOFTWARE_DRIVER_2_LIGHTING - Material.AmbientColor.setA8R8G8B8( in.AmbientColor.color ); - Material.DiffuseColor.setA8R8G8B8( in.ColorMaterial ? 0xFFFFFFFF : in.DiffuseColor.color ); - Material.EmissiveColor.setA8R8G8B8(in.EmissiveColor.color ); - Material.SpecularColor.setA8R8G8B8( in.SpecularColor.color ); + Material.AmbientColor.setA8R8G8B8(in.AmbientColor.color); + Material.DiffuseColor.setA8R8G8B8(in.ColorMaterial ? 0xFFFFFFFF : in.DiffuseColor.color); + Material.EmissiveColor.setA8R8G8B8(in.EmissiveColor.color); + Material.SpecularColor.setA8R8G8B8(in.SpecularColor.color); burning_setbit(EyeSpace.TL_Flag, in.Lighting, TL_LIGHT); - burning_setbit( EyeSpace.TL_Flag, (in.Shininess != 0.f) & (in.SpecularColor.color & 0x00ffffff), TL_SPECULAR ); - burning_setbit( EyeSpace.TL_Flag, in.FogEnable, TL_FOG ); - burning_setbit( EyeSpace.TL_Flag, in.NormalizeNormals, TL_NORMALIZE_NORMALS ); + burning_setbit(EyeSpace.TL_Flag, (in.Shininess != 0.f) && (in.SpecularColor.color & 0x00ffffff), TL_SPECULAR); + burning_setbit(EyeSpace.TL_Flag, in.FogEnable, TL_FOG); + burning_setbit(EyeSpace.TL_Flag, in.NormalizeNormals, TL_NORMALIZE_NORMALS); //if (EyeSpace.Flags & SPECULAR ) EyeSpace.Flags |= NORMALIZE_NORMALS; #endif - //--------------- setCurrentShader +//--------------- setCurrentShader ITexture* texture0 = in.getTexture(0); ITexture* texture1 = in.getTexture(1); @@ -2660,7 +2604,7 @@ void CBurningVideoDriver::setMaterial(const SMaterial& material) { shader = Material.depth_test ? ETR_GOURAUD : shader == ETR_TEXTURE_GOURAUD_VERTEX_ALPHA ? - ETR_GOURAUD_ALPHA_NOZ: // 2D Gradient + ETR_GOURAUD_ALPHA_NOZ : // 2D Gradient ETR_GOURAUD_NOZ; shader = ETR_COLOR; @@ -2693,17 +2637,17 @@ void CBurningVideoDriver::setMaterial(const SMaterial& material) CurrentShader->setTLFlag(EyeSpace.TL_Flag); if (EyeSpace.TL_Flag & TL_FOG) CurrentShader->setFog(FogColor); if (EyeSpace.TL_Flag & TL_SCISSOR) CurrentShader->setScissor(Scissor); - CurrentShader->setRenderTarget(RenderTargetSurface, ViewPort); + CurrentShader->setRenderTarget(RenderTargetSurface, ViewPort, Interlaced); CurrentShader->OnSetMaterial(Material); CurrentShader->pushEdgeTest(in.Wireframe, in.PointCloud, 0); } -/* - mi = (u32)Material.org.MaterialType; - if (mi < MaterialRenderers.size()) - MaterialRenderers[mi].Renderer->OnRender(this, (video::E_VERTEX_TYPE)VertexCache.vType); -*/ + /* + mi = (u32)Material.org.MaterialType; + if (mi < MaterialRenderers.size()) + MaterialRenderers[mi].Renderer->OnRender(this, (video::E_VERTEX_TYPE)VertexCache.vType); + */ } @@ -2713,7 +2657,7 @@ void CBurningVideoDriver::setFog(SColor color, E_FOG_TYPE fogType, f32 start, { CNullDriver::setFog(color, fogType, start, end, density, pixelFog, rangeFog); - EyeSpace.fog_scale = reciprocal_zero2(FogEnd - FogStart); + EyeSpace.fog_scale = reciprocal_zero(FogEnd - FogStart); } @@ -2724,7 +2668,7 @@ void CBurningVideoDriver::setFog(SColor color, E_FOG_TYPE fogType, f32 start, /*! applies lighting model */ -void CBurningVideoDriver::lightVertex_eye(s4DVertex *dest, u32 vertexargb) +void CBurningVideoDriver::lightVertex_eye(s4DVertex* dest, u32 vertexargb) { //gl_FrontLightModelProduct.sceneColor = gl_FrontMaterial.emission + gl_FrontMaterial.ambient * gl_LightModel.ambient @@ -2807,7 +2751,7 @@ void CBurningVideoDriver::lightVertex_eye(s4DVertex *dest, u32 vertexargb) //specular += light.SpecularColor * pow(max(dot(Eyespace.normal,lighthalf),0,Material.org.Shininess)*attenuation specular.mad_rgb(light.SpecularColor, - powf_limit(EyeSpace.normal.dot_xyz(lightHalf), Material.org.Shininess)*attenuation + powf_limit(EyeSpace.normal.dot_xyz(lightHalf), Material.org.Shininess) * attenuation ); break; @@ -2855,7 +2799,7 @@ void CBurningVideoDriver::lightVertex_eye(s4DVertex *dest, u32 vertexargb) //specular += light.SpecularColor * pow(max(dot(Eyespace.normal,lighthalf),0,Material.org.Shininess)*attenuation specular.mad_rgb(light.SpecularColor, - powf_limit(EyeSpace.normal.dot_xyz(lightHalf), Material.org.Shininess)*attenuation + powf_limit(EyeSpace.normal.dot_xyz(lightHalf), Material.org.Shininess) * attenuation ); break; @@ -2886,17 +2830,17 @@ void CBurningVideoDriver::lightVertex_eye(s4DVertex *dest, u32 vertexargb) specular.sat_xyz(dest->Color[1], Material.SpecularColor); } else - if ( !(EyeSpace.TL_Flag & TL_LIGHT0_IS_NORMAL_MAP) && - (VertexCache.vSize[VertexCache.vType].Format & VERTEX4D_FORMAT_MASK_LIGHT) - ) - { - specular.sat_xyz(dest->LightTangent[0], Material.SpecularColor); - } - else + if (!(EyeSpace.TL_Flag & TL_LIGHT0_IS_NORMAL_MAP) && + (VertexCache.vSize[VertexCache.vType].Format & VERTEX4D_FORMAT_MASK_LIGHT) + ) + { + specular.sat_xyz(dest->LightTangent[0], Material.SpecularColor); + } + else #endif - { - dColor.mad_rgbv(specular, Material.SpecularColor); - } + { + dColor.mad_rgbv(specular, Material.SpecularColor); + } dColor.mad_rgbv(ambient, Material.AmbientColor); @@ -2908,7 +2852,7 @@ void CBurningVideoDriver::lightVertex_eye(s4DVertex *dest, u32 vertexargb) } #endif - +/* CImage* getImage(const video::ITexture* texture) { if (!texture) return 0; @@ -2928,7 +2872,7 @@ CImage* getImage(const video::ITexture* texture) } return img; } - +*/ /* draw2DImage with single color scales into destination quad & cliprect(more like viewport) draw2DImage with 4 color scales on destination and cliprect is scissor @@ -3008,84 +2952,6 @@ void CBurningVideoDriver::draw2DRectangle(const core::rect& position, - - -#if 0 -void transform_for_BlitJob2D( SBlitJob& out, - const S3DVertex quad2DVertices[4], const core::dimension2d& renderTargetSize, - CBurningVideoDriver* driver -) -{ - //assume. z = 0.f, w = 1.f - //MVP 2D - core::matrix4 m; - m.buildProjectionMatrixOrthoLH(f32(renderTargetSize.Width), f32(-(s32)(renderTargetSize.Height)), -1.0f, 1.0f); - m.setTranslation(core::vector3df(-1.f, 1.f, 0)); - - //setTransform(ETS_WORLD, m); - //m.setTranslation(core::vector3df(0.375f, 0.375f, 0.0f)); - //setTransform(ETS_VIEW, m); - - s4DVertexPair v[4*sizeof_s4DVertexPairRel]; - for (int i = 0; i < 4; ++i) - { - m.transformVect(&v[s4DVertex_ofs(i)].Pos.x, quad2DVertices[i].Pos); - v[s4DVertex_ofs(i)].Tex[0].x = quad2DVertices[i].TCoords.X; - v[s4DVertex_ofs(i)].Tex[0].y = quad2DVertices[i].TCoords.Y; - v[s4DVertex_ofs(i)].Color[0].setA8R8G8B8(quad2DVertices[i].Color.color); - v[s4DVertex_ofs(i)].flag = VERTEX4D_FORMAT_TEXTURE_1 | VERTEX4D_FORMAT_COLOR_1; - v[s4DVertex_ofs(i)].flag |= clipToFrustumTest(v + i); - } - - size_t vOut = driver->clipToFrustum(4); - - struct s2DVertex - { - union - { - struct { - f32 x, y; - f32 u, v; - f32 a, r, g, b; - }; - f32 attr[8]; - }; - - // f = a * t + b * ( 1 - t ) - void interpolate(const s2DVertex& b, const s2DVertex& a, const f32 t) - { - for (int i = 0; i < 8; ++i) - { - attr[i] = b.attr[i] + ((a.attr[i] - b.attr[i]) * t); - } - } - - }; - - // 0 5 - f32 m2[2]; - m2[0] = renderTargetSize.Width ? 2.f / renderTargetSize.Width : 0.f; - m2[1] = renderTargetSize.Height ? -2.f / renderTargetSize.Height : 0.f; - - s2DVertex p[4]; - for (int i = 0; i < 4; ++i) - { - p[i].x = quad2DVertices[i].Pos.X*m2[0] - 1.f; - p[i].y = quad2DVertices[i].Pos.Y*m2[1] + 1.f; - p[i].u = quad2DVertices[i].TCoords.X; - p[i].v = quad2DVertices[i].TCoords.Y; - - p[i].a = quad2DVertices[i].Color.getAlpha() * (1.f / 255.f); - p[i].r = quad2DVertices[i].Color.getRed() * (1.f / 255.f); - p[i].g = quad2DVertices[i].Color.getBlue() * (1.f / 255.f); - p[i].b = quad2DVertices[i].Color.getGreen() * (1.f / 255.f); - - } - -} -#endif - - //! Enable the 2d override material void CBurningVideoDriver::enableMaterial2D(bool enable) { @@ -3109,7 +2975,7 @@ size_t compare_2d_material(const SMaterial& a, const SMaterial& b) return flag; } -void CBurningVideoDriver::setRenderStates2DMode(const video::SColor& color, video::ITexture* texture, bool useAlphaChannelOfTexture) +void CBurningVideoDriver::setRenderStates2DMode(const video::SColor& color, const video::ITexture* texture, bool useAlphaChannelOfTexture) { //save current 3D Material //Material.save3D = Material.org; @@ -3142,7 +3008,7 @@ void CBurningVideoDriver::setRenderStates2DMode(const video::SColor& color, vide bool mip = false; const SMaterial& currentMaterial = (!OverrideMaterial2DEnabled) ? InitMaterial2D : OverrideMaterial2D; - mip = currentMaterial.TextureLayer[0].BilinearFilter; + mip = currentMaterial.TextureLayer[0].Texture && currentMaterial.TextureLayer[0].BilinearFilter; Material.mat2D.setFlag(video::EMF_BILINEAR_FILTER, mip); @@ -3162,22 +3028,25 @@ void CBurningVideoDriver::setRenderStates2DMode(const video::SColor& color, vide m.makeIdentity(); setTransform(ETS_WORLD, m); - if ( mip ) m.setTranslation(core::vector3df(0.375f, 0.375f, 0.0f)); + if (mip) + m.setTranslation(core::vector3df(IRRLICHT_2D_TEXEL_OFFSET, IRRLICHT_2D_TEXEL_OFFSET, 0.0f)); setTransform(ETS_VIEW, m); - buildNDCToDCMatrix(Transformation_ETS_CLIPSCALE[TransformationStack], ViewPort, mip ? -0.187f : 0.f); - + //Tweak 2D Pixel Center for openGL compatibility (guessing) + //buildNDCToDCMatrix(Transformation_ETS_CLIPSCALE[TransformationStack], ViewPort, mip ? (IRRLICHT_2D_TEXEL_OFFSET) * 0.5f : 0.f); } //compare - if (compare_2d_material(Material.org,Material.mat2D)) + if (compare_2d_material(Material.org, Material.mat2D)) { setMaterial(Material.mat2D); } if (CurrentShader) { CurrentShader->setPrimitiveColor(color.color); + CurrentShader->setTLFlag(EyeSpace.TL_Flag); + if (EyeSpace.TL_Flag & TL_SCISSOR) CurrentShader->setScissor(Scissor); } } @@ -3283,10 +3152,7 @@ void CBurningVideoDriver::draw2DImage(const video::ITexture* texture, const core Quad2DVertices[2].TCoords = core::vector2df(tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); Quad2DVertices[3].TCoords = core::vector2df(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); - //SBlitJob job; - //transform_for_BlitJob2D(job, Quad2DVertices, renderTargetSize,this); - - setRenderStates2DMode(color, (video::ITexture*) texture, useAlphaChannelOfTexture); + setRenderStates2DMode(color, texture, useAlphaChannelOfTexture); drawVertexPrimitiveList(Quad2DVertices, 4, quad_triangle_indexList, 2, @@ -3309,7 +3175,7 @@ void CBurningVideoDriver::draw2DImage(const video::ITexture* texture, const core sourceRect.UpperLeftCorner.X * invW, sourceRect.UpperLeftCorner.Y * invH, sourceRect.LowerRightCorner.X * invW, - sourceRect.LowerRightCorner.Y *invH); + sourceRect.LowerRightCorner.Y * invH); const video::SColor temp[4] = { @@ -3338,8 +3204,6 @@ void CBurningVideoDriver::draw2DImage(const video::ITexture* texture, const core Quad2DVertices[3].TCoords = core::vector2df(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); - const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); - if (clipRect) { if (!clipRect->isValid()) @@ -3347,29 +3211,25 @@ void CBurningVideoDriver::draw2DImage(const video::ITexture* texture, const core //glEnable(GL_SCISSOR_TEST); EyeSpace.TL_Flag |= TL_SCISSOR; - setScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y, + setScissor(clipRect->UpperLeftCorner.X, clipRect->UpperLeftCorner.Y,//renderTargetSize.Height - clipRect->LowerRightCorner.Y clipRect->getWidth(), clipRect->getHeight()); } video::SColor alphaTest; alphaTest.color = useColor[0].color & useColor[0].color & useColor[0].color & useColor[0].color; - //SBlitJob job; - //transform_for_BlitJob2D(job, Quad2DVertices, renderTargetSize, this); - setRenderStates2DMode(alphaTest, (video::ITexture*) texture, useAlphaChannelOfTexture); + setRenderStates2DMode(alphaTest,texture, useAlphaChannelOfTexture); drawVertexPrimitiveList(Quad2DVertices, 4, quad_triangle_indexList, 2, EVT_STANDARD, scene::EPT_TRIANGLES, EIT_16BIT); - if (clipRect) EyeSpace.TL_Flag &= ~TL_SCISSOR; setRenderStates3DMode(); - } @@ -3427,15 +3287,15 @@ void CBurningVideoDriver::draw2DRectangle(const core::rect& position, //! Draws a 2d line. void CBurningVideoDriver::draw2DLine(const core::position2d& start, - const core::position2d& end, - SColor color) + const core::position2d& end, + SColor color) { - drawLine(RenderTargetSurface, start, end, color ); + drawLine(RenderTargetSurface, start, end, color); } //! Draws a pixel -void CBurningVideoDriver::drawPixel(u32 x, u32 y, const SColor & color) +void CBurningVideoDriver::drawPixel(u32 x, u32 y, const SColor& color) { RenderTargetSurface->setPixel(x, y, color, true); } @@ -3447,13 +3307,13 @@ void CBurningVideoDriver::OnResize(const core::dimension2d& size) { // make sure width and height are multiples of 2 core::dimension2d realSize(size); -/* - if (realSize.Width % 2) - realSize.Width += 1; + /* + if (realSize.Width % 2) + realSize.Width += 1; - if (realSize.Height % 2) - realSize.Height += 1; -*/ + if (realSize.Height % 2) + realSize.Height += 1; + */ if (ScreenSize != realSize) { if (ViewPort.getWidth() == (s32)ScreenSize.Width && @@ -3471,10 +3331,10 @@ void CBurningVideoDriver::OnResize(const core::dimension2d& size) if (BackBuffer) BackBuffer->drop(); - BackBuffer = new CImage(BURNINGSHADER_COLOR_FORMAT, realSize); + BackBuffer = new CImage(SOFTWARE_DRIVER_2_RENDERTARGET_COLOR_FORMAT, realSize); if (resetRT) - setRenderTargetImage(BackBuffer); + setRenderTargetImage2(BackBuffer); } } @@ -3482,10 +3342,11 @@ void CBurningVideoDriver::OnResize(const core::dimension2d& size) //! returns the current render target size const core::dimension2d& CBurningVideoDriver::getCurrentRenderTargetSize() const { - return RenderTargetSize; + return (RenderTargetSurface == BackBuffer) ? ScreenSize : RenderTargetSize; } + //! Draws a 3d line. void CBurningVideoDriver::draw3DLine(const core::vector3df& start, const core::vector3df& end, SColor color_start) @@ -3499,56 +3360,53 @@ void CBurningVideoDriver::draw3DLine(const core::vector3df& start, transform_calc(ETS_PROJ_MODEL_VIEW); const core::matrix4* matrix = Transformation[TransformationStack]; - matrix[ETS_PROJ_MODEL_VIEW].transformVect ( &v[0].Pos.x, start ); - matrix[ETS_PROJ_MODEL_VIEW].transformVect ( &v[2].Pos.x, end ); + matrix[ETS_PROJ_MODEL_VIEW].transformVect(&v[s4DVertex_ofs(0)].Pos.x, start); + matrix[ETS_PROJ_MODEL_VIEW].transformVect(&v[s4DVertex_ofs(1)].Pos.x, end); #if BURNING_MATERIAL_MAX_COLORS > 0 - v[0].Color[0].setA8R8G8B8 ( color_start.color ); - v[2].Color[0].setA8R8G8B8 ( color_end.color ); + v[s4DVertex_ofs(0)].Color[0].setA8R8G8B8(color_start.color); + v[s4DVertex_ofs(1)].Color[0].setA8R8G8B8(color_end.color); #endif - u32 i; - for (i = 0; i < 4; i += sizeof_s4DVertexPairRel) + size_t has_vertex_run; + for (has_vertex_run = 0; has_vertex_run < VertexCache.primitiveHasVertex; has_vertex_run += 1) { - v[i + 0].flag = (u32)(VertexCache.vSize[VertexCache.vType].Format); - v[i + 1].flag = v[i + 0].flag; + v[s4DVertex_ofs(has_vertex_run)].flag = (u32)(VertexCache.vSize[VertexCache.vType].Format); + v[s4DVertex_proj(has_vertex_run)].flag = v[s4DVertex_ofs(has_vertex_run)].flag; } - - size_t g; + size_t vOut; // vertices count per line - vOut = clipToFrustum (VertexCache.primitiveHasVertex); - if ( vOut < VertexCache.primitiveHasVertex) + vOut = clipToFrustum(VertexCache.primitiveHasVertex); + if (vOut < VertexCache.primitiveHasVertex) return; - vOut *= sizeof_s4DVertexPairRel; - // to DC Space, project homogenous vertex - ndc_2_dc_and_project ( v + 1, v, vOut ); + ndc_2_dc_and_project(v + s4DVertex_proj(0), v+ s4DVertex_ofs(0), s4DVertex_ofs(vOut)); // unproject vertex color #if 0 #if BURNING_MATERIAL_MAX_COLORS > 0 - for ( g = 0; g != vOut; g+= 2 ) + for (g = 0; g != vOut; g += 2) { - v[ g + 1].Color[0].setA8R8G8B8 ( color.color ); + v[g + 1].Color[0].setA8R8G8B8(color.color); } #endif #endif - IBurningShader * shader = 0; - if ( CurrentShader && CurrentShader->canWireFrame() ) shader = CurrentShader; - else shader = BurningShader [ ETR_TEXTURE_GOURAUD_WIRE ]; - shader = BurningShader [ ETR_TEXTURE_GOURAUD_WIRE ]; + IBurningShader* shader = 0; + if (CurrentShader && CurrentShader->canWireFrame()) shader = CurrentShader; + else shader = BurningShader[ETR_TEXTURE_GOURAUD_WIRE]; + shader = BurningShader[ETR_TEXTURE_GOURAUD_WIRE]; - shader->pushEdgeTest(1,0,1); - shader->setRenderTarget(RenderTargetSurface, ViewPort); + shader->pushEdgeTest(1, 0, 1); + shader->setRenderTarget(RenderTargetSurface, ViewPort, Interlaced); - for ( g = 0; g <= vOut - 4; g += sizeof_s4DVertexPairRel) + for (has_vertex_run = 0; (has_vertex_run + VertexCache.primitiveHasVertex) <= vOut; has_vertex_run += 1) { - shader->drawLine ( v + 1 + g, v + 1 + g + sizeof_s4DVertexPairRel); + shader->drawLine(v + s4DVertex_proj(has_vertex_run), v + s4DVertex_proj(has_vertex_run+1)); } shader->popEdgeTest(); @@ -3561,15 +3419,15 @@ void CBurningVideoDriver::draw3DLine(const core::vector3df& start, const wchar_t* CBurningVideoDriver::getName() const { #ifdef BURNINGVIDEO_RENDERER_BEAUTIFUL - return L"Burning's Video 0.51 beautiful"; + return L"Burning's Video 0.52 beautiful"; #elif defined ( BURNINGVIDEO_RENDERER_ULTRA_FAST ) - return L"Burning's Video 0.51 ultra fast"; + return L"Burning's Video 0.52 ultra fast"; #elif defined ( BURNINGVIDEO_RENDERER_FAST ) - return L"Burning's Video 0.51 fast"; + return L"Burning's Video 0.52 fast"; #elif defined ( BURNINGVIDEO_RENDERER_CE ) - return L"Burning's Video 0.51 CE"; + return L"Burning's Video 0.52 CE"; #else - return L"Burning's Video 0.51"; + return L"Burning's Video 0.52"; #endif } @@ -3590,16 +3448,22 @@ E_DRIVER_TYPE CBurningVideoDriver::getDriverType() const //! returns color format ECOLOR_FORMAT CBurningVideoDriver::getColorFormat() const { - return BURNINGSHADER_COLOR_FORMAT; + return BackBuffer ? BackBuffer->getColorFormat() : CNullDriver::getColorFormat(); } //! Creates a render target texture. ITexture* CBurningVideoDriver::addRenderTargetTexture(const core::dimension2d& size, - const io::path& name, const ECOLOR_FORMAT format) + const io::path& name, const ECOLOR_FORMAT format +#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) + , const bool useStencil +#endif +) { - IImage* img = createImage(BURNINGSHADER_COLOR_FORMAT, size); - ITexture* tex = new CSoftwareTexture2(img, name, CSoftwareTexture2::IS_RENDERTARGET,this); + //IImage* img = createImage(SOFTWARE_DRIVER_2_RENDERTARGET_COLOR_FORMAT, size); + //empty proxy image + IImage* img = createImageFromData(format, size, 0, true, false); + ITexture* tex = new CSoftwareTexture2(img, name, CSoftwareTexture2::IS_RENDERTARGET /*| CSoftwareTexture2::GEN_MIPMAP */, this); img->drop(); addTexture(tex); tex->drop(); @@ -3608,14 +3472,9 @@ ITexture* CBurningVideoDriver::addRenderTargetTexture(const core::dimension2dfill(color); - - if ((flag & ECBF_DEPTH) && DepthBuffer) - DepthBuffer->clear(depth); - - if ((flag & ECBF_STENCIL) && StencilBuffer) - StencilBuffer->clear(stencil); + if ((flag & ECBF_COLOR) && RenderTargetSurface) image_fill(RenderTargetSurface, color, Interlaced); + if ((flag & ECBF_DEPTH) && DepthBuffer) DepthBuffer->clear(depth, Interlaced); + if ((flag & ECBF_STENCIL) && StencilBuffer) StencilBuffer->clear(stencil, Interlaced); } #if 0 @@ -3657,8 +3516,12 @@ IImage* CBurningVideoDriver::createScreenShot(video::ECOLOR_FORMAT format, video ITexture* CBurningVideoDriver::createDeviceDependentTexture(const io::path& name, IImage* image) { u32 flags = - ((TextureCreationFlags & ETCF_CREATE_MIP_MAPS) ? CSoftwareTexture2::GEN_MIPMAP : 0) + ((TextureCreationFlags & ETCF_CREATE_MIP_MAPS) ? CSoftwareTexture2::GEN_MIPMAP : 0) +#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) + | CSoftwareTexture2::GEN_MIPMAP_AUTO +#else | ((TextureCreationFlags & ETCF_AUTO_GENERATE_MIP_MAPS) ? CSoftwareTexture2::GEN_MIPMAP_AUTO : 0) +#endif | ((TextureCreationFlags & ETCF_ALLOW_NON_POWER_2) ? CSoftwareTexture2::ALLOW_NPOT : 0) #if defined(IRRLICHT_sRGB) | ((TextureCreationFlags & ETCF_IMAGE_IS_LINEAR) ? CSoftwareTexture2::IMAGE_IS_LINEAR : 0) @@ -3700,8 +3563,8 @@ void CBurningVideoDriver::drawStencilShadowVolume(const core::arraysetRenderTarget(RenderTargetSurface, ViewPort); - CurrentShader->pushEdgeTest(Material.org.Wireframe, 0,0); + CurrentShader->setRenderTarget(RenderTargetSurface, ViewPort, Interlaced); + CurrentShader->pushEdgeTest(Material.org.Wireframe, 0, 0); //setMaterial EyeSpace.TL_Flag &= ~(TL_TEXTURE_TRANSFORM | TL_LIGHT0_IS_NORMAL_MAP); @@ -3717,15 +3580,15 @@ void CBurningVideoDriver::drawStencilShadowVolume(const core::arraysetStencilOp( StencilOp_KEEP, StencilOp_INCR, StencilOp_KEEP); - drawVertexPrimitiveList (triangles.const_pointer(), count, 0, count/3, (video::E_VERTEX_TYPE) E4VT_SHADOW, scene::EPT_TRIANGLES, (video::E_INDEX_TYPE) E4IT_NONE); + CurrentShader->setStencilOp(StencilOp_KEEP, StencilOp_INCR, StencilOp_KEEP); + drawVertexPrimitiveList(triangles.const_pointer(), count, 0, count / 3, (video::E_VERTEX_TYPE) E4VT_SHADOW, scene::EPT_TRIANGLES, (video::E_INDEX_TYPE) E4IT_NONE); Material.org.BackfaceCulling = true; Material.org.FrontfaceCulling = false; Material.CullFlag = CULL_BACK | CULL_INVISIBLE; - CurrentShader->setStencilOp( StencilOp_KEEP, StencilOp_DECR, StencilOp_KEEP); - drawVertexPrimitiveList (triangles.const_pointer(), count, 0, count/3, (video::E_VERTEX_TYPE) E4VT_SHADOW, scene::EPT_TRIANGLES, (video::E_INDEX_TYPE) E4IT_NONE); + CurrentShader->setStencilOp(StencilOp_KEEP, StencilOp_DECR, StencilOp_KEEP); + drawVertexPrimitiveList(triangles.const_pointer(), count, 0, count / 3, (video::E_VERTEX_TYPE) E4VT_SHADOW, scene::EPT_TRIANGLES, (video::E_INDEX_TYPE) E4IT_NONE); } else // zpass { @@ -3733,7 +3596,7 @@ void CBurningVideoDriver::drawStencilShadowVolume(const core::arraysetStencilOp( StencilOp_KEEP, StencilOp_KEEP, StencilOp_INCR); + CurrentShader->setStencilOp(StencilOp_KEEP, StencilOp_KEEP, StencilOp_INCR); drawVertexPrimitiveList(triangles.const_pointer(), count, 0, count / 3, (video::E_VERTEX_TYPE) E4VT_SHADOW, scene::EPT_TRIANGLES, (video::E_INDEX_TYPE) E4IT_NONE); Material.org.BackfaceCulling = false; @@ -3755,59 +3618,62 @@ void CBurningVideoDriver::drawStencilShadow(bool clearStencilBuffer, video::SCol { if (!StencilBuffer) return; + // draw a shadow rectangle covering the entire screen using stencil buffer const u32 h = RenderTargetSurface->getDimension().Height; const u32 w = RenderTargetSurface->getDimension().Width; - tVideoSample *dst; - const tStencilSample* stencil; -#if defined(SOFTWARE_DRIVER_2_32BIT) - const u32 alpha = extractAlpha(leftUpEdge.color); - const u32 src = leftUpEdge.color; -#else - const u16 alpha = extractAlpha( leftUpEdge.color ) >> 3; - const u32 src = video::A8R8G8B8toA1R5G5B5( leftUpEdge.color ); -#endif + const bool bit32 = RenderTargetSurface->getColorFormat() == ECF_A8R8G8B8; + const tVideoSample alpha = extractAlpha(leftUpEdge.color) >> (bit32 ? 0 : 3); + const tVideoSample src = bit32 ? leftUpEdge.color : video::A8R8G8B8toA1R5G5B5(leftUpEdge.color); - - for ( u32 y = 0; y < h; ++y ) + interlace_scanline_data line; + for (line.y = 0; line.y < h; line.y += SOFTWARE_DRIVER_2_STEP_Y) { - dst = (tVideoSample*)RenderTargetSurface->getData() + ( y * w ); - stencil = (tStencilSample*)StencilBuffer->lock() + (y * w); - - for ( u32 x = 0; x < w; ++x ) + interlace_scanline { - if ( stencil[x] ) + tVideoSample * dst = (tVideoSample*)RenderTargetSurface->getData() + (line.y * w); + const tStencilSample* stencil = (tStencilSample*)StencilBuffer->lock() + (line.y * w); + + if (bit32) { -#if defined(SOFTWARE_DRIVER_2_32BIT) - dst[x] = PixelBlend32 ( dst[x], src,alpha ); -#else - dst[x] = PixelBlend16( dst[x], src, alpha ); -#endif + for (u32 x = 0; x < w; x += SOFTWARE_DRIVER_2_STEP_X) + { + if (stencil[x]) dst[x] = PixelBlend32(dst[x], src, alpha); + } } + else + { + for (u32 x = 0; x < w; x += SOFTWARE_DRIVER_2_STEP_X) + { + if (stencil[x]) dst[x] = PixelBlend16(dst[x], src, alpha); + } + } + } } - if ( clearStencilBuffer ) - StencilBuffer->clear(0); + if (clearStencilBuffer) + StencilBuffer->clear(0, Interlaced); } core::dimension2du CBurningVideoDriver::getMaxTextureSize() const { - return core::dimension2du(SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE ? SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE : 1 << 20, - SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE ? SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE : 1 << 20); + return core::dimension2du(SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE, SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE); } bool CBurningVideoDriver::queryTextureFormat(ECOLOR_FORMAT format) const { - return format == BURNINGSHADER_COLOR_FORMAT; + return format == SOFTWARE_DRIVER_2_RENDERTARGET_COLOR_FORMAT || format == SOFTWARE_DRIVER_2_TEXTURE_COLOR_FORMAT; } +#if !defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) bool CBurningVideoDriver::needsTransparentRenderPass(const irr::video::SMaterial& material) const { return CNullDriver::needsTransparentRenderPass(material) || material.isAlphaBlendOperation(); // || material.isTransparent(); } +#endif s32 CBurningVideoDriver::addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram, @@ -3847,7 +3713,7 @@ s32 CBurningVideoDriver::addHighLevelShaderMaterial( IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData - ) +) { s32 materialID = -1; @@ -3949,11 +3815,11 @@ namespace video //! creates a video driver IVideoDriver* createBurningVideoDriver(const irr::SIrrlichtCreationParameters& params, io::IFileSystem* io, video::IImagePresenter* presenter) { - #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ - return new CBurningVideoDriver(params, io, presenter); - #else - return 0; - #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return new CBurningVideoDriver(params, io, presenter); +#else + return 0; +#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ } diff --git a/source/Irrlicht/CSoftwareDriver2.h b/source/Irrlicht/CSoftwareDriver2.h index 803deae6..4c87bf3f 100644 --- a/source/Irrlicht/CSoftwareDriver2.h +++ b/source/Irrlicht/CSoftwareDriver2.h @@ -50,6 +50,18 @@ namespace video virtual bool beginScene(u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil, const SExposedVideoData& videoData, core::rect* sourceRect) _IRR_OVERRIDE_; +#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) + virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color, + const SExposedVideoData& videoData, core::rect* sourceRect) + { + u16 flag = 0; + if (backBuffer) flag |= ECBF_COLOR; + if (zBuffer) flag |= ECBF_DEPTH; + return beginScene(flag, color, 1.f, 0, videoData, sourceRect); + } + virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer, bool clearZBuffer, SColor color); +#endif + virtual bool endScene() _IRR_OVERRIDE_; //! Only used by the internal engine. Used to notify the driver that @@ -152,7 +164,12 @@ namespace video //! Creates a render target texture. virtual ITexture* addRenderTargetTexture(const core::dimension2d& size, - const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN) _IRR_OVERRIDE_; + const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN +#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) + , const bool useStencil = false +#endif + ) _IRR_OVERRIDE_; + virtual void clearBuffers(u16 flag, SColor color, f32 depth, u8 stencil) _IRR_OVERRIDE_; @@ -190,8 +207,10 @@ namespace video //! Check if the driver supports creating textures with the given color format virtual bool queryTextureFormat(ECOLOR_FORMAT format) const _IRR_OVERRIDE_; +#if !defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) //! Used by some SceneNodes to check if a material should be rendered in the transparent render pass virtual bool needsTransparentRenderPass(const irr::video::SMaterial& material) const _IRR_OVERRIDE_; +#endif IDepthBuffer * getDepthBuffer () { return DepthBuffer; } IStencilBuffer * getStencilBuffer () { return StencilBuffer; } @@ -252,6 +271,33 @@ namespace video virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) _IRR_OVERRIDE_; +#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) + virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count) + { + return setVertexShaderConstant(getVertexShaderConstantID(name), floats, count); + } + virtual bool setVertexShaderConstant(const c8* name, const bool* bools, int count) + { + return setVertexShaderConstant(getVertexShaderConstantID(name), (const s32*)bools, count); + } + virtual bool setVertexShaderConstant(const c8* name, const s32* ints, int count) + { + return setVertexShaderConstant(getVertexShaderConstantID(name), ints, count); + } + + virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count) + { + return setPixelShaderConstant(getPixelShaderConstantID(name), floats, count); + } + virtual bool setPixelShaderConstant(const c8* name, const bool* bools, int count) + { + return setPixelShaderConstant(getPixelShaderConstantID(name), (const s32*)bools, count); + } + virtual bool setPixelShaderConstant(const c8* name, const s32* ints, int count) + { + return setPixelShaderConstant(getPixelShaderConstantID(name), ints, count); + } +#endif //! Get pointer to the IVideoDriver interface /** \return Pointer to the IVideoDriver interface */ virtual IVideoDriver* getVideoDriver() _IRR_OVERRIDE_; @@ -261,7 +307,7 @@ namespace video void saveBuffer(); //! sets a render target - void setRenderTargetImage(video::CImage* image); + void setRenderTargetImage2(video::IImage* color, video::IImage* depth=0, video::IImage* stencil=0); //! sets the current Texture //bool setTexture(u32 stage, video::ITexture* texture); @@ -278,6 +324,7 @@ namespace video video::ITexture* RenderTargetTexture; video::IImage* RenderTargetSurface; core::dimension2d RenderTargetSize; + sVec4 RatioRenderTargetScreen; // Smaller Render Target IBurningShader* CurrentShader; IBurningShader* BurningShader[ETR2_COUNT]; @@ -302,6 +349,8 @@ namespace video ETS_COUNT_BURNING = 16 }; + // align manually to 16 byte start address + //u8 _pack_0[8]; enum E_TRANSFORMATION_FLAG { ETF_VALID = 1, @@ -311,12 +360,12 @@ namespace video ETF_TEXGEN_WRAP = 16, ETF_TEXGEN_MASK = ETF_TEXGEN_CAMERA_SPHERE | ETF_TEXGEN_CAMERA_REFLECTION | ETF_TEXGEN_WRAP }; - core::matrix4 Transformation[2][ETS_COUNT_BURNING]; - size_t TransformationFlag[2][ETS_COUNT_BURNING]; // E_TRANSFORMATION_FLAG - size_t TransformationStack; // 0 .. 3D , 1 .. 2D + core::matrix4 ALIGN(16) Transformation[2][ETS_COUNT_BURNING]; + size_t TransformationFlag[2][ETS_COUNT_BURNING]; // E_TRANSFORMATION_FLAG + - void setRenderStates2DMode(const video::SColor& color,video::ITexture* texture,bool useAlphaChannelOfTexture); + void setRenderStates2DMode(const video::SColor& color,const video::ITexture* texture,bool useAlphaChannelOfTexture); void setRenderStates3DMode(); //ETS_CLIPSCALE, // moved outside to stay at 16 matrices @@ -366,7 +415,7 @@ namespace video //const is misleading. **v is const that true, but not *v.. f32 screenarea_inside (const s4DVertexPair* burning_restrict const face[] ) const; - s32 lodFactor_inside ( const s4DVertexPair* burning_restrict const face[], const size_t tex, f32 dc_area, f32 lod_bias ) const; + s32 lodFactor_inside ( const s4DVertexPair* burning_restrict const face[], const size_t tex, const f32 dc_area, const f32 lod_bias ) const; void select_polygon_mipmap_inside ( s4DVertex* burning_restrict face[], const size_t tex, const CSoftwareTexture2_Bound& b ) const; void getCameraPosWorldSpace(); @@ -377,6 +426,20 @@ namespace video //! Built-in 2D quad for 2D rendering. S3DVertex Quad2DVertices[4]; + interlaced_control Interlaced; + +#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) + core::array RenderTargets; + + inline bool getWriteZBuffer(const SMaterial& material) const + { + return material.ZWriteEnable && (AllowZWriteOnTransparent || !material.isTransparent()); + } + virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const io::path& name, void* mipmapData = 0) + { + return createDeviceDependentTexture(name, surface); + } +#endif }; diff --git a/source/Irrlicht/CSoftwareTexture2.cpp b/source/Irrlicht/CSoftwareTexture2.cpp index 29febe1e..2da1baa7 100644 --- a/source/Irrlicht/CSoftwareTexture2.cpp +++ b/source/Irrlicht/CSoftwareTexture2.cpp @@ -20,6 +20,30 @@ namespace video //! stretches srcRect src to dstRect dst, applying a sliding window box filter in linear color space (sRGB->linear->sRGB) void Resample_subSampling(eBlitter op, video::IImage* dst, const core::rect* dstRect, const video::IImage* src, const core::rect* srcRect, size_t flags); +//nearest pow of 2 ( 257 will be 256 not 512 ) +static inline core::dimension2d getOptimalSize(const core::dimension2d& original, const u32 allowNonPowerOfTwo, const u32 maxSize) +{ + u32 w, h; + if (allowNonPowerOfTwo) + { + w = original.Width; + h = original.Height; + } + else + { + w = 1; + while (w * 2 < original.Width) w *= 2; + if (w * 2 - original.Width < original.Width - w) w *= 2; + + h = 1; + while (h * 2 < original.Height) h *= 2; + if (h * 2 - original.Height < original.Height - h) h *= 2; + } + if (maxSize && w > maxSize) w = maxSize; + if (maxSize && h > maxSize) h = maxSize; + return core::dimension2d(w, h); +} + //! constructor CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name, u32 flags, CBurningVideoDriver* driver) : ITexture(name @@ -27,24 +51,24 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name, u32 fl , ETT_2D #endif ) - ,MipMapLOD(0), Flags(flags), Driver(driver) + , MipMapLOD(0), Flags(flags), Driver(driver) { - #ifdef _DEBUG +#ifdef _DEBUG setDebugName("CSoftwareTexture2"); - #endif +#endif -#ifndef SOFTWARE_DRIVER_2_MIPMAPPING - Flags &= ~(GEN_MIPMAP| GEN_MIPMAP_AUTO); +#if SOFTWARE_DRIVER_2_MIPMAPPING_MAX <= 1 + Flags &= ~(GEN_MIPMAP | GEN_MIPMAP_AUTO); #endif //set baseclass properties DriverType = EDT_BURNINGSVIDEO; - ColorFormat = BURNINGSHADER_COLOR_FORMAT; + ColorFormat = (Flags & IS_RENDERTARGET) ? SOFTWARE_DRIVER_2_RENDERTARGET_COLOR_FORMAT : SOFTWARE_DRIVER_2_TEXTURE_COLOR_FORMAT; IsRenderTarget = (Flags & IS_RENDERTARGET) != 0; HasMipMaps = (Flags & GEN_MIPMAP) != 0; MipMap0_Area[0] = 1; MipMap0_Area[1] = 1; - LodBIAS = 0.75f; - for ( size_t i = 0; i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i ) MipMap[i] = 0; + LodBIAS = 1.f; + for (size_t i = 0; i < array_size(MipMap); ++i) MipMap[i] = 0; if (!image) return; OriginalSize = image->getDimension(); @@ -52,7 +76,7 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name, u32 fl #if defined(IRRLICHT_sRGB) - if ( Flags & IMAGE_IS_LINEAR ) image->set_sRGB(0); + if (Flags & IMAGE_IS_LINEAR) image->set_sRGB(0); #else //guessing linear image if (name.find("light") >= 0 || @@ -72,47 +96,65 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name, u32 fl //visual studio code warning u32 maxTexSize = SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE; - core::dimension2d optSize( OriginalSize.getOptimalSize( + +#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) + if (IsRenderTarget && name.find("RaceGUI::markers") >= 0) + { + maxTexSize = 0; + } +#endif + /* + core::dimension2d optSize(OriginalSize.getOptimalSize( (Flags & ALLOW_NPOT) ? 0 : 1, // requirePowerOfTwo false, // requireSquare - (Flags & ALLOW_NPOT) ? 1 : maxTexSize == 0, // larger + (Flags & ALLOW_NPOT) ? 1 : maxTexSize == SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE, // larger (Flags & ALLOW_NPOT) ? 0 : maxTexSize // maxValue ) - ); - + ); + */ + core::dimension2d optSize(getOptimalSize(OriginalSize, Flags & ALLOW_NPOT, maxTexSize)); if (OriginalSize == optSize) { - MipMap[0] = new CImage(BURNINGSHADER_COLOR_FORMAT, image->getDimension()); + MipMap[0] = new CImage(ColorFormat, image->getDimension()); #if defined(IRRLICHT_sRGB) - MipMap[0]->set_sRGB( (Flags & TEXTURE_IS_LINEAR ) ? 0 : image->get_sRGB() ); + MipMap[0]->set_sRGB((Flags & TEXTURE_IS_LINEAR) ? 0 : image->get_sRGB()); #endif - if (!isCompressed) + if (!isCompressed && image->getData()) image->copyTo(MipMap[0]); } else { - char buf[256]; - core::stringw showName ( name ); - snprintf_irr ( buf, sizeof(buf), "Burningvideo: Warning Texture %ls reformat %ux%u,%d -> %ux%u,%d", - showName.c_str(), - OriginalSize.Width, OriginalSize.Height, OriginalColorFormat, - optSize.Width, optSize.Height,BURNINGSHADER_COLOR_FORMAT - ); - - os::Printer::log ( buf, ELL_WARNING ); - MipMap[0] = new CImage(BURNINGSHADER_COLOR_FORMAT, optSize); + MipMap[0] = new CImage(ColorFormat, optSize); #if defined(IRRLICHT_sRGB) - MipMap[0]->set_sRGB( (Flags & TEXTURE_IS_LINEAR ) ? 0 : image->get_sRGB() ); + MipMap[0]->set_sRGB((Flags & TEXTURE_IS_LINEAR) ? 0 : image->get_sRGB()); #endif if (!isCompressed) { //image->copyToScalingBoxFilter ( MipMap[0],0, false ); - Resample_subSampling(BLITTER_TEXTURE,MipMap[0],0,image,0, Flags); + Resample_subSampling(BLITTER_TEXTURE, MipMap[0], 0, image, 0, Flags); } // if Original Size is used for calculation ( 2D position, font) it will be wrong //OriginalSize = optSize; } + // Show Information about resizing + if (OriginalSize != optSize || + ( OriginalColorFormat != ColorFormat && + !((OriginalColorFormat == ECF_R8G8B8 || OriginalColorFormat == ECF_A1R5G5B5) && ColorFormat == ECF_A8R8G8B8) + ) + ) + { + char buf[256]; + core::stringw showName(name); + snprintf_irr(buf, sizeof(buf), "Burningvideo: Texture '%ls' reformat %ux%u,%s -> %ux%u,%s", + showName.c_str(), + OriginalSize.Width, OriginalSize.Height, ColorFormatNames[OriginalColorFormat], + optSize.Width, optSize.Height, ColorFormatNames[ColorFormat] + ); + os::Printer::log(buf, ELL_DEBUG); + } + + //select highest mipmap 0 regenerateMipMapLevels(image->getMipMapsData()); } @@ -121,9 +163,9 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name, u32 fl //! destructor CSoftwareTexture2::~CSoftwareTexture2() { - for ( size_t i = 0; i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i ) + for (size_t i = 0; i < array_size(MipMap); ++i) { - if ( MipMap[i] ) + if (MipMap[i]) { MipMap[i]->drop(); MipMap[i] = 0; @@ -132,7 +174,6 @@ CSoftwareTexture2::~CSoftwareTexture2() } - //! Regenerates the mip map levels of the texture. Useful after locking and //! modifying the texture #if !defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) @@ -141,12 +182,12 @@ void CSoftwareTexture2::regenerateMipMapLevels(void* data, u32 layer) void CSoftwareTexture2::regenerateMipMapLevels(void* data) #endif { - int i; + size_t i; // release - for ( i = 1; i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i ) + for (i = 1; i < array_size(MipMap); ++i) { - if ( MipMap[i] ) + if (MipMap[i]) { MipMap[i]->drop(); MipMap[i] = 0; @@ -155,10 +196,10 @@ void CSoftwareTexture2::regenerateMipMapLevels(void* data) core::dimension2d newSize; - if (HasMipMaps && ( (Flags & GEN_MIPMAP_AUTO) || 0 == data ) ) + if (HasMipMaps && ((Flags & GEN_MIPMAP_AUTO) || 0 == data)) { //need memory also if autogen mipmap disabled - for (i = 1; i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i) + for (i = 1; i < array_size(MipMap); ++i) { const core::dimension2du& upperDim = MipMap[i - 1]->getDimension(); //isotropic @@ -167,7 +208,7 @@ void CSoftwareTexture2::regenerateMipMapLevels(void* data) if (upperDim == newSize) break; - MipMap[i] = new CImage(BURNINGSHADER_COLOR_FORMAT, newSize); + MipMap[i] = new CImage(ColorFormat, newSize); #if defined(IRRLICHT_sRGB) MipMap[i]->set_sRGB(MipMap[i - 1]->get_sRGB()); #endif @@ -192,13 +233,13 @@ void CSoftwareTexture2::regenerateMipMapLevels(void* data) if (origSize.Height > 1) origSize.Height >>= 1; mip_end += IImage::getDataSizeFromFormat(OriginalColorFormat, origSize.Width, origSize.Height); i += 1; - } while ((origSize.Width != 1 || origSize.Height != 1) && i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX); + } while ((origSize.Width != 1 || origSize.Height != 1) && i < array_size(MipMap)); //TODO: this is not true - LodBIAS = i*0.75f; + LodBIAS = i * 2.f; origSize = OriginalSize; - for (i = 1; i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX && mip_current < mip_end; ++i) + for (i = 1; i < array_size(MipMap) && mip_current < mip_end; ++i) { const core::dimension2du& upperDim = MipMap[i - 1]->getDimension(); //isotropic @@ -210,10 +251,10 @@ void CSoftwareTexture2::regenerateMipMapLevels(void* data) if (origSize.Width > 1) origSize.Width >>= 1; if (origSize.Height > 1) origSize.Height >>= 1; - if (OriginalColorFormat != BURNINGSHADER_COLOR_FORMAT) + if (OriginalColorFormat != ColorFormat) { IImage* tmpImage = new CImage(OriginalColorFormat, origSize, mip_current, true, false); - MipMap[i] = new CImage(BURNINGSHADER_COLOR_FORMAT, newSize); + MipMap[i] = new CImage(ColorFormat, newSize); if (origSize == newSize) tmpImage->copyTo(MipMap[i]); else @@ -223,11 +264,11 @@ void CSoftwareTexture2::regenerateMipMapLevels(void* data) else { if (origSize == newSize) - MipMap[i] = new CImage(BURNINGSHADER_COLOR_FORMAT, newSize, mip_current, false); + MipMap[i] = new CImage(ColorFormat, newSize, mip_current, false); else { - MipMap[i] = new CImage(BURNINGSHADER_COLOR_FORMAT, newSize); - IImage* tmpImage = new CImage(BURNINGSHADER_COLOR_FORMAT, origSize, mip_current, true, false); + MipMap[i] = new CImage(ColorFormat, newSize); + IImage* tmpImage = new CImage(ColorFormat, origSize, mip_current, true, false); tmpImage->copyToScalingBoxFilter(MipMap[i]); tmpImage->drop(); } @@ -238,33 +279,33 @@ void CSoftwareTexture2::regenerateMipMapLevels(void* data) //visualize mipmap - for (i=1; i < 0 && i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i) + for (i = 1; i < 0 && i < array_size(MipMap); ++i) { -/* static u32 color[] = { - 0x30bf7f00,0x3040bf00,0x30bf00bf,0x3000bf00, - 0x300080bf,0x30bf4000,0x300040bf,0x307f00bf, - 0x30bf0000,0x3000bfbf,0x304000bf,0x307fbf00, - 0x8000bf7f,0x80bf0040,0x80bfbf00,0x800000bf - }; -*/ - static u32 color[] = { - 0xFFFFFFFF,0xFFFF0000,0xFF00FF00,0xFF0000FF, - 0xFFFFFF00,0xFF00FFFF,0xFFFF00FF,0xFF0000FF, - 0xFF0000FF,0xFF0000FF,0xFF0000FF,0xFF0000FF, - 0xFF0000FF,0xFF0000FF,0xFF0000FF,0xFFFF00FF + 0xFFFF0000, + 0xFFFF0000,0xFF00FF00,0xFF0000FF, + 0xFFFFFF00,0xFF00FFFF,0xFFFF00FF, + 0xFFff6600,0xFF00ff66,0xFF6600FF, + 0xFF66ff00,0xFF0066ff,0xFFff0066, + 0xFF33ff00,0xFF0033ff,0xFF3300ff, + 0xFF0000FF,0xFF0000FF,0xFF0000FF }; - if ( MipMap[i] ) + if (MipMap[i]) { - core::rect p (core::position2di(0,0),MipMap[i]->getDimension()); + int border = 0; + const core::dimension2du& d = MipMap[i]->getDimension(); + core::rect p(0, 0, d.Width, d.Height); SColor c((color[i & 15] & 0x00FFFFFF) | 0xFF000000); - Blit(BLITTER_TEXTURE_ALPHA_COLOR_BLEND, MipMap[i], 0, 0, MipMap[i], &p, c.color); + + core::rect dclip(border, border, d.Width - border, d.Height - border); + + Blit(BLITTER_TEXTURE_ALPHA_COLOR_BLEND, MipMap[i], &dclip, 0, MipMap[i], &p, c.color); } } //save mipmap chain - if ( 0 ) + if (0) { char buf[256]; const char* name = getName().getPath().c_str(); @@ -273,15 +314,15 @@ void CSoftwareTexture2::regenerateMipMapLevels(void* data) i = 0; while (name[i]) { - if (name[i] == '/' || name[i] == '\\') filename = i + 1; + if (name[i] == '/' || name[i] == '\\') filename = (s32)i + 1; //if (name[i] == '.') ext = i; i += 1; } - for (i = 0; i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i) + for (i = 0; i < array_size(MipMap); ++i) { if (MipMap[i]) { - snprintf_irr(buf, sizeof(buf),"mip/%s_%02d.png", name + filename,i); + snprintf_irr(buf, sizeof(buf), "mip/%s_%02d.png", name + filename, (s32)i); Driver->writeImageToFile(MipMap[i], buf); } } @@ -300,12 +341,16 @@ void CSoftwareTexture2::calcDerivative() MipMap0_Area[0] = dim.Width; MipMap0_Area[1] = dim.Height; // screensize of a triangle + //TA: try to mimic openGL mipmap. ( don't do this!) + //if (MipMap0_Area[0] < 32) MipMap0_Area[0] = 32; + //if (MipMap0_Area[1] < 32) MipMap0_Area[1] = 32; + Size = dim; // MipMap[MipMapLOD]->getDimension(); Pitch = MipMap[MipMapLOD]->getPitch(); } //preCalc mipmap texel center boundaries - for ( s32 i = 0; i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i ) + for (size_t i = 0; i < array_size(MipMap); ++i) { CSoftwareTexture2_Bound& b = TexBound[i]; if (MipMap[i]) @@ -335,7 +380,7 @@ void CSoftwareTexture2::calcDerivative() CSoftwareRenderTarget2::CSoftwareRenderTarget2(CBurningVideoDriver* driver) : Driver(driver) #if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) -, IRenderTarget(0) + , IRenderTarget(0) #endif { DriverType = EDT_BURNINGSVIDEO; @@ -378,12 +423,6 @@ void CSoftwareRenderTarget2::setTexture(const core::array& texture, I } } -ITexture* CSoftwareRenderTarget2::getTexture() const -{ - return Texture[0]; -} - - static const float srgb_8bit_to_linear_float[1 << 8] = { 0.0f, 3.03527e-4f, 6.07054e-4f, 9.10581e-4f, @@ -474,7 +513,7 @@ u32 linear_to_srgb_8bit(const float v) ieee754 c; c.f = v; const size_t x = c.u; - const u32 *table = (u32*)srgb_8bit_to_linear_float; + const u32* table = (u32*)srgb_8bit_to_linear_float; u32 y = 0; y += table[y + 128] <= x ? 128 : 0; y += table[y + 64] <= x ? 64 : 0; @@ -497,7 +536,7 @@ struct absrect2 s32 y1; }; -static inline int clipTest(absrect2 &o, const core::rect* a, const absrect2& b) +static inline int clipTest(absrect2& o, const core::rect* a, const absrect2& b) { if (a == 0) { @@ -522,19 +561,19 @@ static inline int clipTest(absrect2 &o, const core::rect* a, const absrect2 //! stretches srcRect src to dstRect dst, applying a sliding window box filter in linear color space (sRGB->linear->sRGB) // todo: texture jumps (mip selection problem) void Resample_subSampling(eBlitter op, video::IImage* dst, const core::rect* dstRect, - const video::IImage* src, const core::rect* srcRect,size_t flags) + const video::IImage* src, const core::rect* srcRect, size_t flags) { + u8* dstData = (u8*)dst->getData(); const absrect2 dst_clip = { 0,0,(s32)dst->getDimension().Width,(s32)dst->getDimension().Height }; absrect2 dc; - if (clipTest(dc, dstRect, dst_clip)) return; + if (clipTest(dc, dstRect, dst_clip) || !dstData) return; const video::ECOLOR_FORMAT dstFormat = dst->getColorFormat(); - u8* dstData = (u8*)dst->getData(); + const u8* srcData = (u8*)src->getData(); const absrect2 src_clip = { 0,0,(s32)src->getDimension().Width,(s32)src->getDimension().Height }; absrect2 sc; - if (clipTest(sc, srcRect, src_clip)) return; + if (clipTest(sc, srcRect, src_clip) || !srcData) return; const video::ECOLOR_FORMAT srcFormat = src->getColorFormat(); - const u8* srcData = (u8*)src->getData(); #if defined(IRRLICHT_sRGB) const int dst_sRGB = dst->get_sRGB(); @@ -560,14 +599,14 @@ void Resample_subSampling(eBlitter op, video::IImage* dst, const core::rect for (int dy = dc.y0; dy < dc.y1; ++dy) { f[1] = f[3]; - f[3] = sc.y0 + (dy + 1 - dc.y0)*scale[1]; + f[3] = sc.y0 + (dy + 1 - dc.y0) * scale[1]; if (f[3] >= sc.y1) f[3] = sc.y1 - 0.001f; //todo:1.f/dim should be enough f[2] = (float)sc.x0; for (int dx = dc.x0; dx < dc.x1; ++dx) { f[0] = f[2]; - f[2] = sc.x0 + (dx + 1 - dc.x0)*scale[0]; + f[2] = sc.x0 + (dx + 1 - dc.x0) * scale[0]; if (f[2] >= sc.x1) f[2] = sc.x1 - 0.001f; //accumulate linear color @@ -599,12 +638,12 @@ void Resample_subSampling(eBlitter op, video::IImage* dst, const core::rect switch (srcFormat) { - case video::ECF_A1R5G5B5: sbgra = video::A1R5G5B5toA8R8G8B8(*(u16*)(srcData + (fy*src_clip.x1) * 2 + (fx * 2))); break; - case video::ECF_R5G6B5: sbgra = video::R5G6B5toA8R8G8B8(*(u16*)(srcData + (fy*src_clip.x1) * 2 + (fx * 2))); break; - case video::ECF_A8R8G8B8: sbgra = *(u32*)(srcData + (fy*src_clip.x1) * 4 + (fx * 4)); break; + case video::ECF_A1R5G5B5: sbgra = video::A1R5G5B5toA8R8G8B8(*(u16*)(srcData + (fy * src_clip.x1) * 2 + (fx * 2))); break; + case video::ECF_R5G6B5: sbgra = video::R5G6B5toA8R8G8B8(*(u16*)(srcData + (fy * src_clip.x1) * 2 + (fx * 2))); break; + case video::ECF_A8R8G8B8: sbgra = *(u32*)(srcData + (fy * src_clip.x1) * 4 + (fx * 4)); break; case video::ECF_R8G8B8: { - const u8* p = srcData + (fy*src_clip.x1) * 3 + (fx * 3); + const u8* p = srcData + (fy * src_clip.x1) * 3 + (fx * 3); sbgra = 0xFF000000 | p[0] << 16 | p[1] << 8 | p[2]; } break; default: break; @@ -650,16 +689,16 @@ void Resample_subSampling(eBlitter op, video::IImage* dst, const core::rect } switch (dstFormat) { - case video::ECF_A8R8G8B8: *(u32*)(dstData + (dy*dst_clip.x1) * 4 + (dx * 4)) = sbgra; break; + case video::ECF_A8R8G8B8: *(u32*)(dstData + (dy * dst_clip.x1) * 4 + (dx * 4)) = sbgra; break; case video::ECF_R8G8B8: { - u8* p = dstData + (dy*dst_clip.x1) * 3 + (dx * 3); + u8* p = dstData + (dy * dst_clip.x1) * 3 + (dx * 3); p[2] = (sbgra) & 0xFF; p[1] = (sbgra >> 8) & 0xFF; p[0] = (sbgra >> 16) & 0xFF; } break; - case video::ECF_A1R5G5B5: *(u16*)(dstData + (dy*dst_clip.x1) * 2 + (dx * 2)) = video::A8R8G8B8toA1R5G5B5(sbgra); break; - case video::ECF_R5G6B5: *(u16*)(dstData + (dy*dst_clip.x1) * 2 + (dx * 2)) = video::A8R8G8B8toR5G6B5(sbgra); break; + case video::ECF_A1R5G5B5: *(u16*)(dstData + (dy * dst_clip.x1) * 2 + (dx * 2)) = video::A8R8G8B8toA1R5G5B5(sbgra); break; + case video::ECF_R5G6B5: *(u16*)(dstData + (dy * dst_clip.x1) * 2 + (dx * 2)) = video::A8R8G8B8toR5G6B5(sbgra); break; default: break; } diff --git a/source/Irrlicht/CSoftwareTexture2.h b/source/Irrlicht/CSoftwareTexture2.h index 4f6be486..37bd1c7d 100644 --- a/source/Irrlicht/CSoftwareTexture2.h +++ b/source/Irrlicht/CSoftwareTexture2.h @@ -8,7 +8,11 @@ #include "SoftwareDriver2_compile_config.h" #include "ITexture.h" +#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) +#include "IVideoDriver.h" +#else #include "IRenderTarget.h" +#endif #include "CImage.h" namespace irr @@ -51,14 +55,18 @@ public: u32 getMipmapLevel(s32 newLevel) const { if ( newLevel < 0 ) newLevel = 0; - else if ( newLevel >= SOFTWARE_DRIVER_2_MIPMAPPING_MAX ) newLevel = SOFTWARE_DRIVER_2_MIPMAPPING_MAX - 1; + else if ( newLevel >= (s32)array_size(MipMap)) newLevel = array_size(MipMap) - 1; while ( newLevel > 0 && MipMap[newLevel] == 0 ) newLevel -= 1; return newLevel; } //! lock function +#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) + virtual void* lock(E_TEXTURE_LOCK_MODE mode, u32 mipmapLevel) +#else virtual void* lock(E_TEXTURE_LOCK_MODE mode, u32 mipmapLevel, u32 layer, E_TEXTURE_LOCK_FLAGS lockFlags = ETLF_FLIP_Y_UP_RTT) _IRR_OVERRIDE_ +#endif { if (Flags & GEN_MIPMAP) { @@ -75,18 +83,20 @@ public: virtual void unlock() _IRR_OVERRIDE_ { } - +/* //! compare the area drawn with the area of the texture f32 getLODFactor( const f32 texArea ) const { return MipMap0_Area[0]* MipMap0_Area[1] * 0.5f * texArea; //return MipMap[0]->getImageDataSizeInPixels () * texArea; } +*/ const u32* getMipMap0_Area() const { return MipMap0_Area; } + f32 get_lod_bias() const { return LodBIAS; } //! returns unoptimized surface (misleading name. burning can scale down originalimage) virtual CImage* getImage() const @@ -106,9 +116,33 @@ public: return TexBound[MipMapLOD]; } +#if !defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) virtual void regenerateMipMapLevels(void* data = 0, u32 layer = 0) _IRR_OVERRIDE_; +#else + virtual void regenerateMipMapLevels(void* data = 0); +#endif + + +#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) + const core::dimension2d& getOriginalSize() const { return OriginalSize; }; + const core::dimension2d& getSize() const { return Size; }; + E_DRIVER_TYPE getDriverType() const { return DriverType; }; + ECOLOR_FORMAT getColorFormat() const { return ColorFormat; }; + ECOLOR_FORMAT getOriginalColorFormat() const { return OriginalColorFormat; }; + u32 getPitch() const { return Pitch; }; + bool hasMipMaps() const { return HasMipMaps; } + bool isRenderTarget() const { return IsRenderTarget; } + + core::dimension2d OriginalSize; + core::dimension2d Size; + E_DRIVER_TYPE DriverType; + ECOLOR_FORMAT OriginalColorFormat; + ECOLOR_FORMAT ColorFormat; + u32 Pitch; + bool HasMipMaps; + bool IsRenderTarget; +#endif - f32 get_lod_bias() const { return LodBIAS; } private: void calcDerivative(); @@ -120,7 +154,7 @@ private: CImage* MipMap[SOFTWARE_DRIVER_2_MIPMAPPING_MAX]; CSoftwareTexture2_Bound TexBound[SOFTWARE_DRIVER_2_MIPMAPPING_MAX]; u32 MipMap0_Area[2]; - f32 LodBIAS; + f32 LodBIAS; // Tweak mipmap selection }; /*! @@ -134,7 +168,10 @@ public: virtual void setTexture(const core::array& texture, ITexture* depthStencil, const core::array& cubeSurfaces) _IRR_OVERRIDE_; - ITexture* getTexture() const; +#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) + E_DRIVER_TYPE DriverType; + core::array Texture; +#endif protected: CBurningVideoDriver* Driver; diff --git a/source/Irrlicht/CTRGouraud2.cpp b/source/Irrlicht/CTRGouraud2.cpp index d0488b57..5558f061 100644 --- a/source/Irrlicht/CTRGouraud2.cpp +++ b/source/Irrlicht/CTRGouraud2.cpp @@ -87,7 +87,7 @@ public: //virtual bool canWireFrame () { return true; } protected: - virtual void scanline_bilinear (); + virtual void fragmentShader(); }; @@ -104,7 +104,7 @@ CTRGouraud2::CTRGouraud2(CBurningVideoDriver* driver) /*! */ -void CTRGouraud2::scanline_bilinear () +void CTRGouraud2::fragmentShader() { tVideoSample *dst; @@ -143,7 +143,7 @@ void CTRGouraud2::scanline_bilinear () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -196,10 +196,11 @@ void CTRGouraud2::scanline_bilinear () #endif - for ( s32 i = 0; i <= dx; ++i ) + for ( s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { //if test active only first pixel - if ( (0 == EdgeTestPass) & i ) break; + if ((0 == EdgeTestPass) & (i > line.x_edgetest)) break; + #ifdef CMP_Z if ( line.z[0] < z[i] ) #endif @@ -384,8 +385,9 @@ void CTRGouraud2::drawTriangle(const s4DVertex* burning_restrict a, const s4DVer #endif + line.x_edgetest = fill_convention_edge(scan.slopeX[scan.left]); // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -416,7 +418,7 @@ void CTRGouraud2::drawTriangle(const s4DVertex* burning_restrict a, const s4DVer #endif // render a scanline - scanline_bilinear (); + interlace_scanline fragmentShader(); if ( EdgeTestPass & edge_test_first_line ) break; scan.x[0] += scan.slopeX[0]; @@ -511,7 +513,6 @@ void CTRGouraud2::drawTriangle(const s4DVertex* burning_restrict a, const s4DVer yEnd = fill_convention_right( c->Pos.y ); #ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - b->Pos.y; // correct to pixel center @@ -545,8 +546,9 @@ void CTRGouraud2::drawTriangle(const s4DVertex* burning_restrict a, const s4DVer #endif + line.x_edgetest = fill_convention_edge(scan.slopeX[scan.left]); // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -577,7 +579,7 @@ void CTRGouraud2::drawTriangle(const s4DVertex* burning_restrict a, const s4DVer #endif // render a scanline - scanline_bilinear (); + interlace_scanline fragmentShader(); if ( EdgeTestPass & edge_test_first_line ) break; scan.x[0] += scan.slopeX[0]; diff --git a/source/Irrlicht/CTRGouraudAlpha2.cpp b/source/Irrlicht/CTRGouraudAlpha2.cpp index dd425f8b..7fc27e30 100644 --- a/source/Irrlicht/CTRGouraudAlpha2.cpp +++ b/source/Irrlicht/CTRGouraudAlpha2.cpp @@ -88,7 +88,7 @@ public: private: - void scanline_bilinear (); + void fragmentShader(); }; @@ -105,7 +105,7 @@ CTRGouraudAlpha2::CTRGouraudAlpha2(CBurningVideoDriver* driver) /*! */ -void CTRGouraudAlpha2::scanline_bilinear () +void CTRGouraudAlpha2::fragmentShader() { tVideoSample *dst; @@ -148,7 +148,7 @@ void CTRGouraudAlpha2::scanline_bilinear () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -204,7 +204,7 @@ void CTRGouraudAlpha2::scanline_bilinear () tFixPoint r2, g2, b2; #endif - for ( s32 i = 0; i <= dx; ++i ) + for ( s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_Z if ( line.z[0] < z[i] ) @@ -270,9 +270,9 @@ void CTRGouraudAlpha2::drawTriangle(const s4DVertex* burning_restrict a, const s const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; @@ -397,7 +397,7 @@ void CTRGouraudAlpha2::drawTriangle(const s4DVertex* burning_restrict a, const s #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -428,7 +428,7 @@ void CTRGouraudAlpha2::drawTriangle(const s4DVertex* burning_restrict a, const s #endif // render a scanline - scanline_bilinear ( ); + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; @@ -522,7 +522,6 @@ void CTRGouraudAlpha2::drawTriangle(const s4DVertex* burning_restrict a, const s yEnd = fill_convention_right( c->Pos.y ); #ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - b->Pos.y; // correct to pixel center @@ -557,7 +556,7 @@ void CTRGouraudAlpha2::drawTriangle(const s4DVertex* burning_restrict a, const s #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -588,7 +587,7 @@ void CTRGouraudAlpha2::drawTriangle(const s4DVertex* burning_restrict a, const s #endif // render a scanline - scanline_bilinear ( ); + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; diff --git a/source/Irrlicht/CTRGouraudAlphaNoZ2.cpp b/source/Irrlicht/CTRGouraudAlphaNoZ2.cpp index d921cb03..08b798a8 100644 --- a/source/Irrlicht/CTRGouraudAlphaNoZ2.cpp +++ b/source/Irrlicht/CTRGouraudAlphaNoZ2.cpp @@ -88,7 +88,7 @@ public: private: - void scanline_bilinear (); + void fragmentShader(); }; //! constructor @@ -104,7 +104,7 @@ CTRGouraudAlphaNoZ2::CTRGouraudAlphaNoZ2(CBurningVideoDriver* driver) /*! */ -void CTRGouraudAlphaNoZ2::scanline_bilinear () +void CTRGouraudAlphaNoZ2::fragmentShader() { tVideoSample *dst; @@ -144,7 +144,7 @@ void CTRGouraudAlphaNoZ2::scanline_bilinear () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -201,7 +201,7 @@ void CTRGouraudAlphaNoZ2::scanline_bilinear () tFixPoint r2, g2, b2; #endif - for ( s32 i = 0; i <= dx; ++i ) + for ( s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_Z if ( line.z[0] < z[i] ) @@ -271,9 +271,9 @@ void CTRGouraudAlphaNoZ2::drawTriangle(const s4DVertex* burning_restrict a, cons const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; @@ -397,7 +397,7 @@ void CTRGouraudAlphaNoZ2::drawTriangle(const s4DVertex* burning_restrict a, cons #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -428,7 +428,7 @@ void CTRGouraudAlphaNoZ2::drawTriangle(const s4DVertex* burning_restrict a, cons #endif // render a scanline - scanline_bilinear (); + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; @@ -557,7 +557,7 @@ void CTRGouraudAlphaNoZ2::drawTriangle(const s4DVertex* burning_restrict a, cons #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -588,7 +588,7 @@ void CTRGouraudAlphaNoZ2::drawTriangle(const s4DVertex* burning_restrict a, cons #endif // render a scanline - scanline_bilinear (); + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; diff --git a/source/Irrlicht/CTRGouraudNoZ2.cpp b/source/Irrlicht/CTRGouraudNoZ2.cpp index 2e0bc393..b7201832 100644 --- a/source/Irrlicht/CTRGouraudNoZ2.cpp +++ b/source/Irrlicht/CTRGouraudNoZ2.cpp @@ -87,7 +87,7 @@ public: virtual bool canWireFrame () { return true; } protected: - virtual void scanline_bilinear (); + virtual void fragmentShader(); }; //! constructor @@ -103,7 +103,7 @@ CTRGouraudNoZ2::CTRGouraudNoZ2(CBurningVideoDriver* driver) /*! */ -void CTRGouraudNoZ2::scanline_bilinear () +void CTRGouraudNoZ2::fragmentShader() { tVideoSample *dst; @@ -142,7 +142,7 @@ void CTRGouraudNoZ2::scanline_bilinear () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -195,9 +195,9 @@ void CTRGouraudNoZ2::scanline_bilinear () #endif - for ( s32 i = 0; i <= dx; ++i ) + for ( s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { - if ( (0 == EdgeTestPass) & i ) break; + if ((0 == EdgeTestPass) & (i > line.x_edgetest)) break; #ifdef CMP_Z if ( line.z[0] < z[i] ) @@ -383,8 +383,10 @@ void CTRGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, const s4D #endif + line.x_edgetest = fill_convention_edge(scan.slopeX[scan.left]); + // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -415,7 +417,7 @@ void CTRGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, const s4D #endif // render a scanline - scanline_bilinear (); + interlace_scanline fragmentShader(); if ( EdgeTestPass & edge_test_first_line ) break; scan.x[0] += scan.slopeX[0]; @@ -509,7 +511,6 @@ void CTRGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, const s4D yEnd = fill_convention_right( c->Pos.y ); #ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - b->Pos.y; // correct to pixel center @@ -542,9 +543,10 @@ void CTRGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, const s4D #endif #endif + line.x_edgetest = fill_convention_edge(scan.slopeX[scan.left]); // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -575,7 +577,7 @@ void CTRGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, const s4D #endif // render a scanline - scanline_bilinear (); + interlace_scanline fragmentShader(); if ( EdgeTestPass & edge_test_first_line ) break; scan.x[0] += scan.slopeX[0]; diff --git a/source/Irrlicht/CTRNormalMap.cpp b/source/Irrlicht/CTRNormalMap.cpp index 5df81c7a..5b16d083 100644 --- a/source/Irrlicht/CTRNormalMap.cpp +++ b/source/Irrlicht/CTRNormalMap.cpp @@ -164,7 +164,7 @@ void CTRNormalMap::fragmentShader() return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -254,7 +254,7 @@ void CTRNormalMap::fragmentShader() #endif - for ( s32 i = 0; i <= dx; i++ ) + for ( s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_Z if ( line.z[0] < z[i] ) @@ -400,9 +400,9 @@ void CTRNormalMap::drawTriangle(const s4DVertex* burning_restrict a, const s4DVe const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; @@ -572,7 +572,7 @@ void CTRNormalMap::drawTriangle(const s4DVertex* burning_restrict a, const s4DVe #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -618,7 +618,7 @@ void CTRNormalMap::drawTriangle(const s4DVertex* burning_restrict a, const s4DVe #endif // render a scanline - fragmentShader (); + interlace_scanline fragmentShader (); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; @@ -751,7 +751,6 @@ void CTRNormalMap::drawTriangle(const s4DVertex* burning_restrict a, const s4DVe yEnd = fill_convention_right( c->Pos.y ); #ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - b->Pos.y; // correct to pixel center @@ -801,7 +800,7 @@ void CTRNormalMap::drawTriangle(const s4DVertex* burning_restrict a, const s4DVe #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -847,7 +846,7 @@ void CTRNormalMap::drawTriangle(const s4DVertex* burning_restrict a, const s4DVe #endif // render a scanline - fragmentShader(); + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; diff --git a/source/Irrlicht/CTRStencilShadow.cpp b/source/Irrlicht/CTRStencilShadow.cpp index 82b5ed3d..81e64d63 100644 --- a/source/Irrlicht/CTRStencilShadow.cpp +++ b/source/Irrlicht/CTRStencilShadow.cpp @@ -139,7 +139,7 @@ void CTRStencilShadow::fragmentShader() SOFTWARE_DRIVER_2_CLIPCHECK; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -174,7 +174,7 @@ void CTRStencilShadow::fragmentShader() #endif s32 i; - for (i = 0; i <= dx; i++) + for (i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_Z if (line.z[0] < z[i]) @@ -226,9 +226,9 @@ void CTRStencilShadow::drawTriangle(const s4DVertex* burning_restrict a, const s const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; @@ -382,7 +382,7 @@ void CTRStencilShadow::drawTriangle(const s4DVertex* burning_restrict a, const s #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -423,7 +423,7 @@ void CTRStencilShadow::drawTriangle(const s4DVertex* burning_restrict a, const s #endif // render a scanline - fragmentShader (); + interlace_scanline fragmentShader (); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; @@ -545,7 +545,6 @@ void CTRStencilShadow::drawTriangle(const s4DVertex* burning_restrict a, const s yEnd = fill_convention_right( c->Pos.y ); #ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - b->Pos.y; // correct to pixel center @@ -590,7 +589,7 @@ void CTRStencilShadow::drawTriangle(const s4DVertex* burning_restrict a, const s #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -631,7 +630,7 @@ void CTRStencilShadow::drawTriangle(const s4DVertex* burning_restrict a, const s #endif // render a scanline - fragmentShader (); + interlace_scanline fragmentShader (); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; diff --git a/source/Irrlicht/CTRTextureBlend.cpp b/source/Irrlicht/CTRTextureBlend.cpp index da178eb1..8d22291c 100644 --- a/source/Irrlicht/CTRTextureBlend.cpp +++ b/source/Irrlicht/CTRTextureBlend.cpp @@ -87,22 +87,6 @@ namespace video virtual void drawTriangle(const s4DVertex* burning_restrict a, const s4DVertex* burning_restrict b, const s4DVertex* burning_restrict c) _IRR_OVERRIDE_; virtual void OnSetMaterial(const SBurningShaderMaterial& material) _IRR_OVERRIDE_; -#if defined(PATCH_SUPERTUX_8_0_1) - - virtual void setZCompareFunc(u32 func) - { - depth_func = (E_COMPARISON_FUNC)func; - } - virtual void setParam(u32 index, f32 value) - { - SBurningShaderMaterial material; - material.org.ZBuffer = depth_func; - material.org.MaterialTypeParam = value; - OnSetMaterial(material); - } - -#endif - private: // fragment shader typedef void (CTRTextureBlend::*tFragmentShader) (); @@ -269,7 +253,7 @@ void CTRTextureBlend::fragment_dst_color_src_alpha () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -325,7 +309,7 @@ void CTRTextureBlend::fragment_dst_color_src_alpha () { default: case ECFN_LESSEQUAL: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] >= z[i] ) @@ -368,7 +352,7 @@ void CTRTextureBlend::fragment_dst_color_src_alpha () break; case 2: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] == z[i] ) @@ -454,7 +438,7 @@ void CTRTextureBlend::fragment_src_color_src_alpha () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -514,7 +498,7 @@ void CTRTextureBlend::fragment_src_color_src_alpha () { default: case ECFN_LESSEQUAL: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] >= z[i] ) @@ -561,7 +545,7 @@ void CTRTextureBlend::fragment_src_color_src_alpha () break; case 2: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] == z[i] ) @@ -649,7 +633,7 @@ void CTRTextureBlend::fragment_one_one_minus_src_alpha() return; // slopes - const f32 invDeltaX = reciprocal_zero2 ( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -707,7 +691,7 @@ void CTRTextureBlend::fragment_one_one_minus_src_alpha() { default: case ECFN_LESSEQUAL: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] >= z[i] ) @@ -757,7 +741,7 @@ void CTRTextureBlend::fragment_one_one_minus_src_alpha() break; case 2: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] == z[i] ) @@ -850,7 +834,7 @@ void CTRTextureBlend::fragment_one_minus_dst_alpha_one () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -908,7 +892,7 @@ void CTRTextureBlend::fragment_one_minus_dst_alpha_one () { default: case ECFN_LESSEQUAL: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] >= z[i] ) @@ -957,7 +941,7 @@ void CTRTextureBlend::fragment_one_minus_dst_alpha_one () break; case 2: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] == z[i] ) @@ -1050,7 +1034,7 @@ void CTRTextureBlend::fragment_src_alpha_one () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -1108,7 +1092,7 @@ void CTRTextureBlend::fragment_src_alpha_one () { default: case ECFN_LESSEQUAL: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] >= z[i] ) @@ -1174,7 +1158,7 @@ void CTRTextureBlend::fragment_src_alpha_one () break; case 2: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] == z[i] ) @@ -1280,7 +1264,7 @@ void CTRTextureBlend::fragment_src_alpha_one_minus_src_alpha() return; // slopes - const f32 invDeltaX = reciprocal_zero2(line.x[1] - line.x[0]); + const f32 invDeltaX = fill_step_x(line.x[1] - line.x[0]); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -1337,7 +1321,7 @@ void CTRTextureBlend::fragment_src_alpha_one_minus_src_alpha() { default: case ECFN_LESSEQUAL: - for (i = 0; i <= dx; ++i) + for (i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if (line.w[0] >= z[i]) @@ -1434,7 +1418,7 @@ void CTRTextureBlend::fragment_dst_color_one_minus_dst_alpha () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -1492,7 +1476,7 @@ void CTRTextureBlend::fragment_dst_color_one_minus_dst_alpha () { default: case ECFN_LESSEQUAL: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] >= z[i] ) @@ -1541,7 +1525,7 @@ void CTRTextureBlend::fragment_dst_color_one_minus_dst_alpha () break; case 2: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] == z[i] ) @@ -1633,7 +1617,7 @@ void CTRTextureBlend::fragment_dst_color_zero () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -1691,7 +1675,7 @@ void CTRTextureBlend::fragment_dst_color_zero () { default: case ECFN_LESSEQUAL: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] >= z[i] ) @@ -1739,7 +1723,7 @@ void CTRTextureBlend::fragment_dst_color_zero () break; case 2: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] == z[i] ) @@ -1830,7 +1814,7 @@ void CTRTextureBlend::fragment_dst_color_one () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -1888,7 +1872,7 @@ void CTRTextureBlend::fragment_dst_color_one () { default: case ECFN_LESSEQUAL: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] >= z[i] ) @@ -1937,7 +1921,7 @@ void CTRTextureBlend::fragment_dst_color_one () break; case 2: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] == z[i] ) @@ -2030,7 +2014,7 @@ void CTRTextureBlend::fragment_zero_one_minus_scr_color () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -2088,7 +2072,7 @@ void CTRTextureBlend::fragment_zero_one_minus_scr_color () { default: case ECFN_LESSEQUAL: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] >= z[i] ) @@ -2137,7 +2121,7 @@ void CTRTextureBlend::fragment_zero_one_minus_scr_color () break; case 2: - for ( i = 0; i <= dx; ++i ) + for ( i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_W if ( line.w[0] == z[i] ) @@ -2202,9 +2186,9 @@ void CTRTextureBlend::drawTriangle(const s4DVertex* burning_restrict a, const s4 const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; @@ -2328,7 +2312,7 @@ void CTRTextureBlend::drawTriangle(const s4DVertex* burning_restrict a, const s4 #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -2359,7 +2343,7 @@ void CTRTextureBlend::drawTriangle(const s4DVertex* burning_restrict a, const s4 #endif // render a scanline - (this->*fragmentShader) (); + interlace_scanline (this->*fragmentShader) (); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; @@ -2453,7 +2437,6 @@ void CTRTextureBlend::drawTriangle(const s4DVertex* burning_restrict a, const s4 yEnd = fill_convention_right( c->Pos.y ); #ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - b->Pos.y; // correct to pixel center @@ -2488,7 +2471,7 @@ void CTRTextureBlend::drawTriangle(const s4DVertex* burning_restrict a, const s4 #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -2519,7 +2502,7 @@ void CTRTextureBlend::drawTriangle(const s4DVertex* burning_restrict a, const s4 #endif // render a scanline - (this->*fragmentShader) (); + interlace_scanline (this->*fragmentShader) (); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; diff --git a/source/Irrlicht/CTRTextureDetailMap2.cpp b/source/Irrlicht/CTRTextureDetailMap2.cpp index 3e75c2d9..78896647 100644 --- a/source/Irrlicht/CTRTextureDetailMap2.cpp +++ b/source/Irrlicht/CTRTextureDetailMap2.cpp @@ -88,7 +88,7 @@ public: virtual bool canWireFrame () { return true; } protected: - virtual void scanline_bilinear (); + virtual void fragmentShader(); }; @@ -105,7 +105,7 @@ CTRTextureDetailMap2::CTRTextureDetailMap2(CBurningVideoDriver* driver) /*! */ -void CTRTextureDetailMap2::scanline_bilinear () +void CTRTextureDetailMap2::fragmentShader() { tVideoSample *dst; @@ -140,12 +140,11 @@ void CTRTextureDetailMap2::scanline_bilinear () xEnd = fill_convention_right( line.x[1] ); dx = xEnd - xStart; - if ( dx < 0 ) return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -200,9 +199,9 @@ void CTRTextureDetailMap2::scanline_bilinear () tFixPoint r2, g2, b2; - for ( s32 i = 0; i <= dx; ++i ) + for ( s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { - if ( (0 == EdgeTestPass) & i ) break; + if ( (0 == EdgeTestPass) & (i > line.x_edgetest)) break; #ifdef CMP_Z if ( line.z[0] < z[i] ) @@ -326,7 +325,7 @@ void CTRTextureDetailMap2::drawTriangle(const s4DVertex* burning_restrict a, con #endif // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) + if (F32_GREATER_0(scan.invDeltaY[1]) ) { // calculate slopes for top edge scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; @@ -394,9 +393,10 @@ void CTRTextureDetailMap2::drawTriangle(const s4DVertex* burning_restrict a, con #endif #endif + line.x_edgetest = fill_convention_edge(scan.slopeX[scan.left]); // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -427,7 +427,8 @@ void CTRTextureDetailMap2::drawTriangle(const s4DVertex* burning_restrict a, con #endif // render a scanline - scanline_bilinear (); + interlace_scanline fragmentShader(); + if (EdgeTestPass & edge_test_first_line) break; scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; @@ -461,10 +462,10 @@ void CTRTextureDetailMap2::drawTriangle(const s4DVertex* burning_restrict a, con } // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) + if (F32_GREATER_0(scan.invDeltaY[2]) ) { // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) + if(F32_GREATER_0(scan.invDeltaY[1]) ) { temp[0] = b->Pos.y - a->Pos.y; // dy @@ -521,7 +522,6 @@ void CTRTextureDetailMap2::drawTriangle(const s4DVertex* burning_restrict a, con yEnd = fill_convention_right( c->Pos.y ); #ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - b->Pos.y; // correct to pixel center @@ -555,8 +555,10 @@ void CTRTextureDetailMap2::drawTriangle(const s4DVertex* burning_restrict a, con #endif + line.x_edgetest = fill_convention_edge(scan.slopeX[scan.left]); + // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -587,7 +589,8 @@ void CTRTextureDetailMap2::drawTriangle(const s4DVertex* burning_restrict a, con #endif // render a scanline - scanline_bilinear (); + interlace_scanline fragmentShader(); + if (EdgeTestPass & edge_test_first_line) break; scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; diff --git a/source/Irrlicht/CTRTextureGouraud2.cpp b/source/Irrlicht/CTRTextureGouraud2.cpp index ef864606..1cd7bd18 100644 --- a/source/Irrlicht/CTRTextureGouraud2.cpp +++ b/source/Irrlicht/CTRTextureGouraud2.cpp @@ -167,7 +167,7 @@ void CTRTextureGouraud2::fragmentShader () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -254,10 +254,10 @@ void CTRTextureGouraud2::fragmentShader () u32 dIndex = ( line.y & 3 ) << 2; #endif - for ( s32 i = 0; i <= dx; ++i ) + for ( s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { //if test active only first pixel - if ( (0 == EdgeTestPass) & i ) break; + if ((0 == EdgeTestPass) & (i > line.x_edgetest)) break; #ifdef CMP_Z if ( line.z[0] < z[i] ) @@ -382,9 +382,9 @@ void CTRTextureGouraud2::drawTriangle(const s4DVertex* burning_restrict a, const const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; @@ -551,9 +551,10 @@ void CTRTextureGouraud2::drawTriangle(const s4DVertex* burning_restrict a, const #endif #endif + line.x_edgetest = fill_convention_edge(scan.slopeX[scan.left]); // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -599,7 +600,7 @@ void CTRTextureGouraud2::drawTriangle(const s4DVertex* burning_restrict a, const #endif // render a scanline - fragmentShader (); + interlace_scanline fragmentShader (); if ( EdgeTestPass & edge_test_first_line ) break; @@ -734,7 +735,6 @@ void CTRTextureGouraud2::drawTriangle(const s4DVertex* burning_restrict a, const yEnd = fill_convention_right( c->Pos.y ); #ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - b->Pos.y; // correct to pixel center @@ -761,7 +761,7 @@ void CTRTextureGouraud2::drawTriangle(const s4DVertex* burning_restrict a, const scan.c[1][1] += scan.slopeC[1][1] * subPixel; #endif -#ifdef IPOL_C1 +#ifdef IPOL_C2 scan.c[2][0] += scan.slopeC[2][0] * subPixel; scan.c[2][1] += scan.slopeC[2][1] * subPixel; #endif @@ -782,9 +782,10 @@ void CTRTextureGouraud2::drawTriangle(const s4DVertex* burning_restrict a, const #endif #endif + line.x_edgetest = fill_convention_edge(scan.slopeX[scan.left]); // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -830,7 +831,7 @@ void CTRTextureGouraud2::drawTriangle(const s4DVertex* burning_restrict a, const #endif // render a scanline - fragmentShader (); + interlace_scanline fragmentShader (); if ( EdgeTestPass & edge_test_first_line ) break; diff --git a/source/Irrlicht/CTRTextureGouraudAdd2.cpp b/source/Irrlicht/CTRTextureGouraudAdd2.cpp index 040c83de..340cef59 100644 --- a/source/Irrlicht/CTRTextureGouraudAdd2.cpp +++ b/source/Irrlicht/CTRTextureGouraudAdd2.cpp @@ -88,7 +88,7 @@ public: private: - void scanline_bilinear (); + void fragmentShader(); }; //! constructor @@ -104,7 +104,7 @@ CTRTextureGouraudAdd2::CTRTextureGouraudAdd2(CBurningVideoDriver* driver) /*! */ -void CTRTextureGouraudAdd2::scanline_bilinear () +void CTRTextureGouraudAdd2::fragmentShader() { tVideoSample *dst; @@ -144,7 +144,7 @@ void CTRTextureGouraudAdd2::scanline_bilinear () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -203,7 +203,7 @@ void CTRTextureGouraudAdd2::scanline_bilinear () #endif - for ( s32 i = 0; i <= dx; ++i ) + for ( s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_Z if ( line.z[0] < z[i] ) @@ -280,9 +280,9 @@ void CTRTextureGouraudAdd2::drawTriangle(const s4DVertex* burning_restrict a, co const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); // find if the major edge is left or right aligned f32 temp[4]; @@ -403,7 +403,7 @@ void CTRTextureGouraudAdd2::drawTriangle(const s4DVertex* burning_restrict a, co #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -434,7 +434,7 @@ void CTRTextureGouraudAdd2::drawTriangle(const s4DVertex* burning_restrict a, co #endif // render a scanline - scanline_bilinear (); + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; @@ -563,7 +563,7 @@ void CTRTextureGouraudAdd2::drawTriangle(const s4DVertex* burning_restrict a, co #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -594,7 +594,7 @@ void CTRTextureGouraudAdd2::drawTriangle(const s4DVertex* burning_restrict a, co #endif // render a scanline - scanline_bilinear (); + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; diff --git a/source/Irrlicht/CTRTextureGouraudAddNoZ2.cpp b/source/Irrlicht/CTRTextureGouraudAddNoZ2.cpp index 4a619530..0a880deb 100644 --- a/source/Irrlicht/CTRTextureGouraudAddNoZ2.cpp +++ b/source/Irrlicht/CTRTextureGouraudAddNoZ2.cpp @@ -143,7 +143,7 @@ void CTRTextureGouraudAddNoZ2::fragmentShader() return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -200,7 +200,7 @@ void CTRTextureGouraudAddNoZ2::fragmentShader() tFixPoint r2, g2, b2; #endif - for ( s32 i = 0; i <= dx; ++i ) + for ( s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_Z if ( line.z[0] < z[i] ) @@ -275,9 +275,9 @@ void CTRTextureGouraudAddNoZ2::drawTriangle(const s4DVertex* burning_restrict a, const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; @@ -401,7 +401,7 @@ void CTRTextureGouraudAddNoZ2::drawTriangle(const s4DVertex* burning_restrict a, #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -432,7 +432,7 @@ void CTRTextureGouraudAddNoZ2::drawTriangle(const s4DVertex* burning_restrict a, #endif // render a scanline - fragmentShader(); + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; @@ -526,7 +526,6 @@ void CTRTextureGouraudAddNoZ2::drawTriangle(const s4DVertex* burning_restrict a, yEnd = fill_convention_right( c->Pos.y ); #ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - b->Pos.y; // correct to pixel center @@ -561,7 +560,7 @@ void CTRTextureGouraudAddNoZ2::drawTriangle(const s4DVertex* burning_restrict a, #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -592,7 +591,7 @@ void CTRTextureGouraudAddNoZ2::drawTriangle(const s4DVertex* burning_restrict a, #endif // render a scanline - fragmentShader( ); + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; diff --git a/source/Irrlicht/CTRTextureGouraudAlpha.cpp b/source/Irrlicht/CTRTextureGouraudAlpha.cpp index 6e922359..995251bf 100644 --- a/source/Irrlicht/CTRTextureGouraudAlpha.cpp +++ b/source/Irrlicht/CTRTextureGouraudAlpha.cpp @@ -88,7 +88,7 @@ public: virtual void OnSetMaterial(const SBurningShaderMaterial& material) _IRR_OVERRIDE_; private: - void scanline_bilinear (); + void fragmentShader(); }; @@ -115,7 +115,7 @@ void CTRTextureGouraudAlpha2::OnSetMaterial(const SBurningShaderMaterial& materi /*! */ -void CTRTextureGouraudAlpha2::scanline_bilinear () +void CTRTextureGouraudAlpha2::fragmentShader() { tVideoSample *dst; @@ -155,7 +155,7 @@ void CTRTextureGouraudAlpha2::scanline_bilinear () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -213,7 +213,7 @@ void CTRTextureGouraudAlpha2::scanline_bilinear () #endif #endif - for ( s32 i = 0; i <= dx; ++i ) + for ( s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_Z if ( line.z[0] < z[i] ) @@ -337,9 +337,9 @@ void CTRTextureGouraudAlpha2::drawTriangle(const s4DVertex* burning_restrict a, const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; @@ -463,7 +463,7 @@ void CTRTextureGouraudAlpha2::drawTriangle(const s4DVertex* burning_restrict a, #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -494,7 +494,7 @@ void CTRTextureGouraudAlpha2::drawTriangle(const s4DVertex* burning_restrict a, #endif // render a scanline - scanline_bilinear ( ); + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; @@ -588,7 +588,6 @@ void CTRTextureGouraudAlpha2::drawTriangle(const s4DVertex* burning_restrict a, yEnd = fill_convention_right( c->Pos.y ); #ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - b->Pos.y; // correct to pixel center @@ -623,7 +622,7 @@ void CTRTextureGouraudAlpha2::drawTriangle(const s4DVertex* burning_restrict a, #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -654,7 +653,7 @@ void CTRTextureGouraudAlpha2::drawTriangle(const s4DVertex* burning_restrict a, #endif // render a scanline - scanline_bilinear ( ); + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; diff --git a/source/Irrlicht/CTRTextureGouraudAlphaNoZ.cpp b/source/Irrlicht/CTRTextureGouraudAlphaNoZ.cpp index 6a550334..2d7b9165 100644 --- a/source/Irrlicht/CTRTextureGouraudAlphaNoZ.cpp +++ b/source/Irrlicht/CTRTextureGouraudAlphaNoZ.cpp @@ -93,20 +93,6 @@ public: virtual void drawTriangle(const s4DVertex* burning_restrict a, const s4DVertex* burning_restrict b, const s4DVertex* burning_restrict c) _IRR_OVERRIDE_; virtual void OnSetMaterial(const SBurningShaderMaterial& material) _IRR_OVERRIDE_; -#if defined(PATCH_SUPERTUX_8_0_1) - SBurningShaderMaterial Material; - - virtual void setMaterial(const SBurningShaderMaterial &material) - { - Material = material; - } - - virtual void setParam(u32 index, f32 value) - { - OnSetMaterial(Material); -} -#endif - private: // fragment shader @@ -198,7 +184,7 @@ void CTRTextureGouraudAlphaNoZ::fragment_linear() return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -268,7 +254,7 @@ void CTRTextureGouraudAlphaNoZ::fragment_linear() tFixPoint a3,r3, g3, b3; #endif - for ( s32 i = 0; i <= dx; ++i ) + for ( s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_Z if ( line.z[0] < z[i] ) @@ -276,7 +262,7 @@ void CTRTextureGouraudAlphaNoZ::fragment_linear() #ifdef CMP_W if ( line.w[0] >= z[i] ) #endif - + scissor_test_x { #if defined(BURNINGVIDEO_RENDERER_FAST) && COLOR_MAX==0xff @@ -418,7 +404,7 @@ void CTRTextureGouraudAlphaNoZ::fragment_linear_test() return; // slopes - const f32 invDeltaX = reciprocal_zero2(line.x[1] - line.x[0]); + const f32 invDeltaX = fill_step_x(line.x[1] - line.x[0]); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -488,91 +474,91 @@ void CTRTextureGouraudAlphaNoZ::fragment_linear_test() tFixPoint a3, r3, g3, b3; #endif - for (s32 i = 0; i <= dx; ++i) + for (s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_Z if (line.z[0] < z[i]) #endif #ifdef CMP_W - if (line.w[0] >= z[i]) + if (line.w[0] >= z[i]) #endif - - { + scissor_test_x + { #if defined(BURNINGVIDEO_RENDERER_FAST) && COLOR_MAX==0xff - const tFixPointu d = dithermask[dIndex | (i) & 3]; + const tFixPointu d = dithermask[dIndex | (i) & 3]; #ifdef INVERSE_W - inversew = fix_inverse32(line.w[0]); + inversew = fix_inverse32(line.w[0]); #endif - u32 argb = getTexel_plain(&IT[0], d + tofix(line.t[0][0].x, inversew), - d + tofix(line.t[0][0].y, inversew) - ); + u32 argb = getTexel_plain(&IT[0], d + tofix(line.t[0][0].x, inversew), + d + tofix(line.t[0][0].y, inversew) + ); - const tFixPoint alpha = (argb >> 24); - if (alpha > AlphaRef) - { + const tFixPoint alpha = (argb >> 24); + if (alpha > AlphaRef) + { #ifdef WRITE_Z - z[i] = line.z[0]; + z[i] = line.z[0]; #endif #ifdef WRITE_W - z[i] = line.w[0]; + z[i] = line.w[0]; #endif - dst[i] = PixelBlend32(dst[i], argb, alpha); - } + dst[i] = PixelBlend32(dst[i], argb, alpha); + } #else #ifdef INVERSE_W - inversew = fix_inverse32(line.w[0]); + inversew = fix_inverse32(line.w[0]); #endif - getSample_texture(a0, r0, g0, b0, - &IT[0], - tofix(line.t[0][0].x, inversew), - tofix(line.t[0][0].y, inversew) - ); + getSample_texture(a0, r0, g0, b0, + &IT[0], + tofix(line.t[0][0].x, inversew), + tofix(line.t[0][0].y, inversew) + ); - if (a0 > AlphaRef) - { + if (a0 > AlphaRef) + { #ifdef WRITE_Z - z[i] = line.z[0]; + z[i] = line.z[0]; #endif #ifdef WRITE_W - z[i] = line.w[0]; + z[i] = line.w[0]; #endif #ifdef IPOL_C0 - vec4_to_fix(a2, r2, g2, b2, line.c[0][0], inversew); + vec4_to_fix(a2, r2, g2, b2, line.c[0][0], inversew); - a0 = imulFix(a0, a2); //2D uses vertexalpha*texelalpha - r0 = imulFix(r0, r2); - g0 = imulFix(g0, g2); - b0 = imulFix(b0, b2); + a0 = imulFix(a0, a2); //2D uses vertexalpha*texelalpha + r0 = imulFix(r0, r2); + g0 = imulFix(g0, g2); + b0 = imulFix(b0, b2); - color_to_fix(r1, g1, b1, dst[i]); + color_to_fix(r1, g1, b1, dst[i]); - fix_color_norm(a0); + fix_color_norm(a0); - r2 = r1 + imulFix(a0, r0 - r1); - g2 = g1 + imulFix(a0, g0 - g1); - b2 = b1 + imulFix(a0, b0 - b1); - dst[i] = fix4_to_sample(a0, r2, g2, b2); + r2 = r1 + imulFix(a0, r0 - r1); + g2 = g1 + imulFix(a0, g0 - g1); + b2 = b1 + imulFix(a0, b0 - b1); + dst[i] = fix4_to_sample(a0, r2, g2, b2); #else - dst[i] = PixelBlend32(dst[i], - fix_to_sample(r0, g0, b0), - fixPointu_to_u32(a0) - ); -#endif - - } + dst[i] = PixelBlend32(dst[i], + fix_to_sample(r0, g0, b0), + fixPointu_to_u32(a0) + ); #endif } +#endif + + } #ifdef IPOL_Z line.z[0] += slopeZ; @@ -639,7 +625,7 @@ void CTRTextureGouraudAlphaNoZ::fragment_point_noz() return; // slopes - const f32 invDeltaX = reciprocal_zero2(line.x[1] - line.x[0]); + const f32 invDeltaX = fill_step_x(line.x[1] - line.x[0]); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -708,15 +694,15 @@ void CTRTextureGouraudAlphaNoZ::fragment_point_noz() #ifdef IPOL_C1 tFixPoint a3, r3, g3, b3; #endif - for (s32 i = 0; i <= dx; ++i) + for (s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_Z - if (line.z[0] < z[i]) + //if (line.z[0] < z[i]) #endif #ifdef CMP_W // if (line.w[0] >= z[i]) #endif - + scissor_test_x { #if defined(BURNINGVIDEO_RENDERER_FAST) && COLOR_MAX==0xff @@ -827,9 +813,9 @@ void CTRTextureGouraudAlphaNoZ::drawTriangle(const s4DVertex* burning_restrict a const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; @@ -968,7 +954,7 @@ void CTRTextureGouraudAlphaNoZ::drawTriangle(const s4DVertex* burning_restrict a #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -1004,6 +990,8 @@ void CTRTextureGouraudAlphaNoZ::drawTriangle(const s4DVertex* burning_restrict a #endif // render a scanline + interlace_scanline + scissor_test_y (this->*fragmentShader) (); scan.x[0] += scan.slopeX[0]; @@ -1112,7 +1100,6 @@ void CTRTextureGouraudAlphaNoZ::drawTriangle(const s4DVertex* burning_restrict a yEnd = fill_convention_right( c->Pos.y ); #ifdef SUBTEXEL - subPixel = ( (f32) yStart ) - b->Pos.y; // correct to pixel center @@ -1152,7 +1139,7 @@ void CTRTextureGouraudAlphaNoZ::drawTriangle(const s4DVertex* burning_restrict a #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -1188,6 +1175,8 @@ void CTRTextureGouraudAlphaNoZ::drawTriangle(const s4DVertex* burning_restrict a #endif // render a scanline + interlace_scanline + scissor_test_y (this->*fragmentShader) (); scan.x[0] += scan.slopeX[0]; diff --git a/source/Irrlicht/CTRTextureGouraudNoZ2.cpp b/source/Irrlicht/CTRTextureGouraudNoZ2.cpp index c2b4625d..b287e47b 100644 --- a/source/Irrlicht/CTRTextureGouraudNoZ2.cpp +++ b/source/Irrlicht/CTRTextureGouraudNoZ2.cpp @@ -89,11 +89,16 @@ public: //! draws an indexed triangle list virtual void drawTriangle(const s4DVertex* burning_restrict a, const s4DVertex* burning_restrict b, const s4DVertex* burning_restrict c) _IRR_OVERRIDE_; - + virtual void OnSetMaterial(const SBurningShaderMaterial& material) _IRR_OVERRIDE_; private: - void scanline_bilinear (); + // fragment shader + typedef void (CTRTextureGouraudNoZ2::* tFragmentShader) (); + void fragment_bilinear(); + void fragment_no_filter(); + + tFragmentShader fragmentShader; }; //! constructor @@ -103,13 +108,32 @@ CTRTextureGouraudNoZ2::CTRTextureGouraudNoZ2(CBurningVideoDriver* driver) #ifdef _DEBUG setDebugName("CTRTextureGouraudNoZ2"); #endif + + fragmentShader = &CTRTextureGouraudNoZ2::fragment_bilinear; } - - /*! */ -void CTRTextureGouraudNoZ2::scanline_bilinear ( ) +void CTRTextureGouraudNoZ2::OnSetMaterial(const SBurningShaderMaterial& material) +{ + + if (material.org.TextureLayer[0].BilinearFilter || + material.org.TextureLayer[0].TrilinearFilter || + material.org.TextureLayer[0].AnisotropicFilter + ) + { + fragmentShader = &CTRTextureGouraudNoZ2::fragment_bilinear; + } + else + { + fragmentShader = &CTRTextureGouraudNoZ2::fragment_no_filter; + } + +} + +/*! +*/ +void CTRTextureGouraudNoZ2::fragment_bilinear() { tVideoSample *dst; @@ -149,7 +173,7 @@ void CTRTextureGouraudNoZ2::scanline_bilinear ( ) return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -168,7 +192,7 @@ void CTRTextureGouraudNoZ2::scanline_bilinear ( ) #endif #ifdef SUBTEXEL - subPixel = ( (f32) xStart ) - line.x[0]; + subPixel = ((f32) xStart) - line.x[0]; #ifdef IPOL_Z line.z[0] += slopeZ * subPixel; #endif @@ -200,7 +224,7 @@ void CTRTextureGouraudNoZ2::scanline_bilinear ( ) tFixPoint ty0; tFixPoint r0, g0, b0; - for ( s32 i = 0; i <= dx; ++i ) + for ( s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_Z if ( line.z[0] < z[i] ) @@ -208,7 +232,7 @@ void CTRTextureGouraudNoZ2::scanline_bilinear ( ) #ifdef CMP_W if ( line.w[0] >= z[i] ) #endif - + scissor_test_x { #ifdef INVERSE_W inversew = fix_inverse32 ( line.w[0] ); @@ -248,6 +272,146 @@ void CTRTextureGouraudNoZ2::scanline_bilinear ( ) } +/*! +*/ +void CTRTextureGouraudNoZ2::fragment_no_filter() +{ + tVideoSample* dst; + +#ifdef USE_ZBUFFER + fp24* z; +#endif + + s32 xStart; + s32 xEnd; + s32 dx; + + +#ifdef SUBTEXEL + f32 subPixel; +#endif + +#ifdef IPOL_Z + f32 slopeZ; +#endif +#ifdef IPOL_W + fp24 slopeW; +#endif +#ifdef IPOL_C0 + sVec4 slopeC; +#endif +#ifdef IPOL_T0 + sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; +#endif + + // apply top-left fill-convention, left + xStart = fill_convention_left(line.x[0]); + xEnd = fill_convention_right(line.x[1]); + + dx = xEnd - xStart; + if (dx < 0) + return; + + // slopes + const f32 invDeltaX = fill_step_x(line.x[1] - line.x[0]); + +#ifdef IPOL_Z + slopeZ = (line.z[1] - line.z[0]) * invDeltaX; +#endif +#ifdef IPOL_W + slopeW = (line.w[1] - line.w[0]) * invDeltaX; +#endif +#ifdef IPOL_C0 + slopeC = (line.c[1] - line.c[0]) * invDeltaX; +#endif +#ifdef IPOL_T0 + slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; +#endif +#ifdef IPOL_T1 + slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; +#endif + +#ifdef SUBTEXEL + subPixel = ((f32)xStart) - line.x[0]; +#ifdef IPOL_Z + line.z[0] += slopeZ * subPixel; +#endif +#ifdef IPOL_W + line.w[0] += slopeW * subPixel; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC * subPixel; +#endif +#ifdef IPOL_T0 + line.t[0][0] += slopeT[0] * subPixel; +#endif +#ifdef IPOL_T1 + line.t[1][0] += slopeT[1] * subPixel; +#endif +#endif + + SOFTWARE_DRIVER_2_CLIPCHECK; + dst = (tVideoSample*)RenderTarget->getData() + (line.y * RenderTarget->getDimension().Width) + xStart; + +#ifdef USE_ZBUFFER + z = (fp24*)DepthBuffer->lock() + (line.y * RenderTarget->getDimension().Width) + xStart; +#endif + + + f32 inversew = FIX_POINT_F32_MUL; + + tFixPoint tx0; + tFixPoint ty0; + //tFixPoint r0, g0, b0; + + for (s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) + { +#ifdef CMP_Z + if (line.z[0] < z[i]) +#endif +#ifdef CMP_W + if (line.w[0] >= z[i]) +#endif + //scissor_test_x + { + #ifdef INVERSE_W + inversew = fix_inverse32(line.w[0]); + #endif + tx0 = tofix(line.t[0][0].x,inversew); + ty0 = tofix(line.t[0][0].y,inversew); + //skybox + dst[i] = getTexel_plain(&IT[0], tx0, ty0); + + //getSample_texture ( r0, g0, b0, IT+0, tx0, ty0 ); + //dst[i] = fix_to_sample( r0, g0, b0 ); + + #ifdef WRITE_Z + z[i] = line.z[0]; + #endif + #ifdef WRITE_W + z[i] = line.w[0]; + #endif + } + +#ifdef IPOL_Z + line.z[0] += slopeZ; +#endif +#ifdef IPOL_W + line.w[0] += slopeW; +#endif +#ifdef IPOL_C0 + line.c[0] += slopeC; +#endif +#ifdef IPOL_T0 + line.t[0][0] += slopeT[0]; +#endif +#ifdef IPOL_T1 + line.t[1][0] += slopeT[1]; +#endif + } + +} + void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, const s4DVertex* burning_restrict b, const s4DVertex* burning_restrict c) { // sort on height, y @@ -258,10 +422,11 @@ void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, co const f32 ca = c->Pos.y - a->Pos.y; const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; + // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; @@ -315,7 +480,7 @@ void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, co #endif // rasterize upper sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[1] ) + if (F32_GREATER_0(scan.invDeltaY[1]) ) { // calculate slopes for top edge scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; @@ -385,7 +550,7 @@ void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, co #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -415,8 +580,11 @@ void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, co line.t[1][scan.right] = scan.t[1][1]; #endif + // render a scanline - scanline_bilinear ( ); + interlace_scanline + scissor_test_y + (this->*fragmentShader) (); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; @@ -450,10 +618,10 @@ void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, co } // rasterize lower sub-triangle - if ( (f32) 0.0 != scan.invDeltaY[2] ) + if (F32_GREATER_0(scan.invDeltaY[2]) ) { // advance to middle point - if( (f32) 0.0 != scan.invDeltaY[1] ) + if(F32_GREATER_0(scan.invDeltaY[1]) ) { temp[0] = b->Pos.y - a->Pos.y; // dy @@ -545,7 +713,7 @@ void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, co #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -576,7 +744,9 @@ void CTRTextureGouraudNoZ2::drawTriangle(const s4DVertex* burning_restrict a, co #endif // render a scanline - scanline_bilinear (); + interlace_scanline + scissor_test_y + (this->*fragmentShader) (); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; diff --git a/source/Irrlicht/CTRTextureGouraudVertexAlpha2.cpp b/source/Irrlicht/CTRTextureGouraudVertexAlpha2.cpp index 4b9c4c20..b9ff381e 100644 --- a/source/Irrlicht/CTRTextureGouraudVertexAlpha2.cpp +++ b/source/Irrlicht/CTRTextureGouraudVertexAlpha2.cpp @@ -93,7 +93,7 @@ public: private: - void scanline_bilinear (); + void fragmentShader(); }; @@ -110,7 +110,7 @@ CTRTextureVertexAlpha2::CTRTextureVertexAlpha2(CBurningVideoDriver* driver) /*! */ -void CTRTextureVertexAlpha2::scanline_bilinear ( ) +void CTRTextureVertexAlpha2::fragmentShader( ) { tVideoSample *dst; @@ -150,7 +150,7 @@ void CTRTextureVertexAlpha2::scanline_bilinear ( ) return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -219,7 +219,7 @@ void CTRTextureVertexAlpha2::scanline_bilinear ( ) #endif - for ( s32 i = 0; i <= dx; ++i ) + for ( s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_Z if ( line.z[0] < z[i] ) @@ -332,9 +332,9 @@ void CTRTextureVertexAlpha2::drawTriangle(const s4DVertex* burning_restrict a, c const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; @@ -473,7 +473,7 @@ void CTRTextureVertexAlpha2::drawTriangle(const s4DVertex* burning_restrict a, c #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -509,7 +509,7 @@ void CTRTextureVertexAlpha2::drawTriangle(const s4DVertex* burning_restrict a, c #endif // render a scanline - scanline_bilinear (); + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; @@ -656,7 +656,7 @@ void CTRTextureVertexAlpha2::drawTriangle(const s4DVertex* burning_restrict a, c #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -692,7 +692,7 @@ void CTRTextureVertexAlpha2::drawTriangle(const s4DVertex* burning_restrict a, c #endif // render a scanline - scanline_bilinear (); + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; diff --git a/source/Irrlicht/CTRTextureLightMap2_Add.cpp b/source/Irrlicht/CTRTextureLightMap2_Add.cpp index 11d430bf..61497d3b 100644 --- a/source/Irrlicht/CTRTextureLightMap2_Add.cpp +++ b/source/Irrlicht/CTRTextureLightMap2_Add.cpp @@ -86,7 +86,7 @@ public: private: - void scanline_bilinear (); + void fragmentShader(); }; @@ -103,7 +103,7 @@ CTRTextureLightMap2_Add::CTRTextureLightMap2_Add(CBurningVideoDriver* driver) /*! */ -REALINLINE void CTRTextureLightMap2_Add::scanline_bilinear () +REALINLINE void CTRTextureLightMap2_Add::fragmentShader() { tVideoSample *dst; @@ -143,7 +143,7 @@ REALINLINE void CTRTextureLightMap2_Add::scanline_bilinear () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -199,7 +199,7 @@ REALINLINE void CTRTextureLightMap2_Add::scanline_bilinear () #endif - for ( s32 i = 0; i <= dx; i++ ) + for ( s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_Z if ( line.z[0] < z[i] ) @@ -274,9 +274,9 @@ void CTRTextureLightMap2_Add::drawTriangle(const s4DVertex* burning_restrict a, const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; @@ -400,7 +400,7 @@ void CTRTextureLightMap2_Add::drawTriangle(const s4DVertex* burning_restrict a, #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -431,7 +431,7 @@ void CTRTextureLightMap2_Add::drawTriangle(const s4DVertex* burning_restrict a, #endif // render a scanline - scanline_bilinear (); + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; @@ -560,7 +560,7 @@ void CTRTextureLightMap2_Add::drawTriangle(const s4DVertex* burning_restrict a, #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -591,7 +591,7 @@ void CTRTextureLightMap2_Add::drawTriangle(const s4DVertex* burning_restrict a, #endif // render a scanline - scanline_bilinear (); + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; diff --git a/source/Irrlicht/CTRTextureLightMap2_M1.cpp b/source/Irrlicht/CTRTextureLightMap2_M1.cpp index 1295d3c7..b8d0893f 100644 --- a/source/Irrlicht/CTRTextureLightMap2_M1.cpp +++ b/source/Irrlicht/CTRTextureLightMap2_M1.cpp @@ -121,7 +121,7 @@ REALINLINE void CTRTextureLightMap2_M1::scanline_bilinear2 () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); // search z-buffer for first not occulled pixel z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; @@ -193,7 +193,7 @@ REALINLINE void CTRTextureLightMap2_M1::scanline_bilinear2 () #endif - for ( ;i <= dx; i++ ) + for ( ;i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef IPOL_W if ( line.w[0] >= z[i] ) @@ -255,9 +255,9 @@ void CTRTextureLightMap2_M1::drawTriangle(const s4DVertex* burning_restrict a, c const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; @@ -381,7 +381,7 @@ void CTRTextureLightMap2_M1::drawTriangle(const s4DVertex* burning_restrict a, c #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -542,7 +542,7 @@ void CTRTextureLightMap2_M1::drawTriangle(const s4DVertex* burning_restrict a, c #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; diff --git a/source/Irrlicht/CTRTextureLightMap2_M2.cpp b/source/Irrlicht/CTRTextureLightMap2_M2.cpp index 5976cfb8..19d051f3 100644 --- a/source/Irrlicht/CTRTextureLightMap2_M2.cpp +++ b/source/Irrlicht/CTRTextureLightMap2_M2.cpp @@ -121,7 +121,7 @@ REALINLINE void CTRTextureLightMap2_M2::scanline_bilinear2 () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); // search z-buffer for first not occulled pixel z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; @@ -254,9 +254,9 @@ void CTRTextureLightMap2_M2::drawTriangle(const s4DVertex* burning_restrict a, c const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; @@ -380,7 +380,7 @@ void CTRTextureLightMap2_M2::drawTriangle(const s4DVertex* burning_restrict a, c #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -411,7 +411,7 @@ void CTRTextureLightMap2_M2::drawTriangle(const s4DVertex* burning_restrict a, c #endif // render a scanline - scanline_bilinear2 (); + interlace_scanline scanline_bilinear2 (); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; @@ -541,7 +541,7 @@ void CTRTextureLightMap2_M2::drawTriangle(const s4DVertex* burning_restrict a, c #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -572,7 +572,7 @@ void CTRTextureLightMap2_M2::drawTriangle(const s4DVertex* burning_restrict a, c #endif // render a scanline - scanline_bilinear2 (); + interlace_scanline scanline_bilinear2 (); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; diff --git a/source/Irrlicht/CTRTextureLightMap2_M4.cpp b/source/Irrlicht/CTRTextureLightMap2_M4.cpp index b33a0e0c..a78b1e3e 100644 --- a/source/Irrlicht/CTRTextureLightMap2_M4.cpp +++ b/source/Irrlicht/CTRTextureLightMap2_M4.cpp @@ -93,10 +93,10 @@ private: void scanline_bilinear2_mag (); void scanline_bilinear2_min (); #else - #define scanline_bilinear2_mag scanline_bilinear + #define scanline_bilinear2_mag fragmentShader #endif - void scanline_bilinear (); + void fragmentShader(); }; @@ -130,7 +130,7 @@ void CTRTextureLightMap2_M4::scanline_bilinear2_mag () SOFTWARE_DRIVER_2_CLIPCHECK; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); // search z-buffer for first not occulled pixel i = ( line.y * RenderTarget->getDimension().Width ) + xStart; @@ -202,7 +202,7 @@ void CTRTextureLightMap2_M4::scanline_bilinear2_mag () #endif - for ( ;i <= dx; i++ ) + for ( ;i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef IPOL_W if ( line.w[0] >= z[i] ) @@ -271,7 +271,7 @@ void CTRTextureLightMap2_M4::scanline_bilinear2_min () SOFTWARE_DRIVER_2_CLIPCHECK; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); // search z-buffer for first not occulled pixel z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; @@ -334,7 +334,7 @@ void CTRTextureLightMap2_M4::scanline_bilinear2_min () tFixPoint r1, g1, b1; - for ( ;i <= dx; i++ ) + for ( ;i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef IPOL_W if ( line.w[0] >= z[i] ) @@ -393,9 +393,9 @@ void CTRTextureLightMap2_M4::drawTriangle_Min ( const s4DVertex* burning_restric const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; @@ -519,7 +519,7 @@ void CTRTextureLightMap2_M4::drawTriangle_Min ( const s4DVertex* burning_restric #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -550,7 +550,7 @@ void CTRTextureLightMap2_M4::drawTriangle_Min ( const s4DVertex* burning_restric #endif // render a scanline - scanline_bilinear2_min (); + interlace_scanline scanline_bilinear2_min (); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; @@ -680,7 +680,7 @@ void CTRTextureLightMap2_M4::drawTriangle_Min ( const s4DVertex* burning_restric #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -711,7 +711,7 @@ void CTRTextureLightMap2_M4::drawTriangle_Min ( const s4DVertex* burning_restric #endif // render a scanline - scanline_bilinear2_min (); + interlace_scanline scanline_bilinear2_min (); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; @@ -769,9 +769,9 @@ void CTRTextureLightMap2_M4::drawTriangle(const s4DVertex* burning_restrict a, c return; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); //if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) // return; @@ -896,7 +896,7 @@ void CTRTextureLightMap2_M4::drawTriangle(const s4DVertex* burning_restrict a, c #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -927,7 +927,7 @@ void CTRTextureLightMap2_M4::drawTriangle(const s4DVertex* burning_restrict a, c #endif // render a scanline - scanline_bilinear2_mag (); + interlace_scanline scanline_bilinear2_mag (); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; @@ -1057,7 +1057,7 @@ void CTRTextureLightMap2_M4::drawTriangle(const s4DVertex* burning_restrict a, c #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -1088,7 +1088,7 @@ void CTRTextureLightMap2_M4::drawTriangle(const s4DVertex* burning_restrict a, c #endif // render a scanline - scanline_bilinear2_mag (); + interlace_scanline scanline_bilinear2_mag (); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; diff --git a/source/Irrlicht/CTRTextureLightMapGouraud2_M4.cpp b/source/Irrlicht/CTRTextureLightMapGouraud2_M4.cpp index 55e7ffc0..08f5285d 100644 --- a/source/Irrlicht/CTRTextureLightMapGouraud2_M4.cpp +++ b/source/Irrlicht/CTRTextureLightMapGouraud2_M4.cpp @@ -86,7 +86,7 @@ public: private: - void scanline_bilinear (); + void fragmentShader(); }; @@ -103,7 +103,7 @@ CTRGTextureLightMap2_M4::CTRGTextureLightMap2_M4(CBurningVideoDriver* driver) /*! */ -void CTRGTextureLightMap2_M4::scanline_bilinear () +void CTRGTextureLightMap2_M4::fragmentShader() { tVideoSample *dst; @@ -143,7 +143,7 @@ void CTRGTextureLightMap2_M4::scanline_bilinear () return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -201,7 +201,7 @@ void CTRGTextureLightMap2_M4::scanline_bilinear () tFixPoint r3, g3, b3; #endif - for ( s32 i = 0; i <= dx; i++ ) + for ( s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X ) { #ifdef CMP_Z if ( line.z[0] < z[i] ) @@ -283,9 +283,9 @@ void CTRGTextureLightMap2_M4::drawTriangle(const s4DVertex* burning_restrict a, const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); if ( F32_LOWER_0 ( scan.invDeltaY[0] ) ) return; @@ -411,7 +411,7 @@ void CTRGTextureLightMap2_M4::drawTriangle(const s4DVertex* burning_restrict a, #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -442,7 +442,7 @@ void CTRGTextureLightMap2_M4::drawTriangle(const s4DVertex* burning_restrict a, #endif // render a scanline - scanline_bilinear (); + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; @@ -573,7 +573,7 @@ void CTRGTextureLightMap2_M4::drawTriangle(const s4DVertex* burning_restrict a, #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -604,7 +604,7 @@ void CTRGTextureLightMap2_M4::drawTriangle(const s4DVertex* burning_restrict a, #endif // render a scanline - scanline_bilinear (); + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; scan.x[1] += scan.slopeX[1]; diff --git a/source/Irrlicht/CTRTextureWire2.cpp b/source/Irrlicht/CTRTextureWire2.cpp index 61a42274..af81c4a4 100644 --- a/source/Irrlicht/CTRTextureWire2.cpp +++ b/source/Irrlicht/CTRTextureWire2.cpp @@ -91,7 +91,7 @@ public: virtual bool canPointCloud() _IRR_OVERRIDE_ { return true; } protected: - virtual void scanline_bilinear (); + virtual void fragmentShader(); void renderAlphaLine ( const s4DVertex *a,const s4DVertex *b ) const; void renderLine ( const s4DVertex *a,const s4DVertex *b, int renderZero = 0 ) const; @@ -114,7 +114,7 @@ CTRTextureWire2::CTRTextureWire2(CBurningVideoDriver* driver) */ void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b, int renderZero) const { - int pitch0 = RenderTarget->getDimension().Width << VIDEO_SAMPLE_GRANULARITY; + int pitch0 = RenderTarget->getDimension().Width << SOFTWARE_DRIVER_2_RENDERTARGET_GRANULARITY; #ifdef USE_ZBUFFER int pitch1 = RenderTarget->getDimension().Width << 2; #endif @@ -138,7 +138,7 @@ void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b, int re fp24 *z; #endif - int xInc0 = 1 << VIDEO_SAMPLE_GRANULARITY; + int xInc0 = 1 << SOFTWARE_DRIVER_2_RENDERTARGET_GRANULARITY; int yInc0 = pitch0; #ifdef USE_ZBUFFER @@ -148,7 +148,7 @@ void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b, int re if ( dx < 0 ) { - xInc0 = - ( 1 << VIDEO_SAMPLE_GRANULARITY); + xInc0 = - ( 1 << SOFTWARE_DRIVER_2_RENDERTARGET_GRANULARITY); #ifdef USE_ZBUFFER xInc1 = -4; #endif @@ -173,7 +173,7 @@ void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b, int re } SOFTWARE_DRIVER_2_CLIPCHECK_WIRE; - dst = (tVideoSample*) ( (u8*) RenderTarget->getData() + ( aposy * pitch0 ) + (aposx* (1<< VIDEO_SAMPLE_GRANULARITY) ) ); + dst = (tVideoSample*) ( (u8*) RenderTarget->getData() + ( aposy * pitch0 ) + (aposx* (1<< SOFTWARE_DRIVER_2_RENDERTARGET_GRANULARITY) ) ); #ifdef USE_ZBUFFER z = (fp24*) ( (u8*) (fp24*) DepthBuffer->lock() + ( aposy * pitch1 ) + (aposx << 2 ) ); #endif @@ -182,7 +182,7 @@ void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b, int re m = dy << 1; // slopes - const f32 invDeltaX = reciprocal_zero2( (f32)dx ); + const f32 invDeltaX = fill_step_x( (f32)dx ); #ifdef IPOL_Z f32 slopeZ = (b->Pos.z - a->Pos.z) * invDeltaX; @@ -283,7 +283,7 @@ void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b, int re } -void CTRTextureWire2::scanline_bilinear() +void CTRTextureWire2::fragmentShader() { } diff --git a/source/Irrlicht/CTR_transparent_reflection_2_layer.cpp b/source/Irrlicht/CTR_transparent_reflection_2_layer.cpp index 8fb92140..eccb6787 100644 --- a/source/Irrlicht/CTR_transparent_reflection_2_layer.cpp +++ b/source/Irrlicht/CTR_transparent_reflection_2_layer.cpp @@ -149,7 +149,7 @@ void CTR_transparent_reflection_2_layer::fragmentShader() return; // slopes - const f32 invDeltaX = reciprocal_zero2( line.x[1] - line.x[0] ); + const f32 invDeltaX = fill_step_x( line.x[1] - line.x[0] ); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -206,7 +206,7 @@ void CTR_transparent_reflection_2_layer::fragmentShader() switch(MaterialType) { default: case EMT_REFLECTION_2_LAYER: - for (s32 i = 0; i <= dx; ++i) + for (s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_Z if (line.z[0] < z[i]) @@ -263,7 +263,7 @@ void CTR_transparent_reflection_2_layer::fragmentShader() break; case EMT_TRANSPARENT_REFLECTION_2_LAYER: - for (s32 i = 0; i <= dx; ++i) + for (s32 i = 0; i <= dx; i += SOFTWARE_DRIVER_2_STEP_X) { #ifdef CMP_Z if (line.z[0] < z[i]) @@ -344,9 +344,9 @@ void CTR_transparent_reflection_2_layer::drawTriangle ( const s4DVertex* burning const f32 ba = b->Pos.y - a->Pos.y; const f32 cb = c->Pos.y - b->Pos.y; // calculate delta y of the edges - scan.invDeltaY[0] = reciprocal_zero( ca ); - scan.invDeltaY[1] = reciprocal_zero( ba ); - scan.invDeltaY[2] = reciprocal_zero( cb ); + scan.invDeltaY[0] = fill_step_y( ca ); + scan.invDeltaY[1] = fill_step_y( ba ); + scan.invDeltaY[2] = fill_step_y( cb ); if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) return; @@ -470,7 +470,7 @@ void CTR_transparent_reflection_2_layer::drawTriangle ( const s4DVertex* burning #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -501,6 +501,7 @@ void CTR_transparent_reflection_2_layer::drawTriangle ( const s4DVertex* burning #endif // render a scanline + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; @@ -630,7 +631,7 @@ void CTR_transparent_reflection_2_layer::drawTriangle ( const s4DVertex* burning #endif // rasterize the edge scanlines - for( line.y = yStart; line.y <= yEnd; ++line.y) + for( line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -661,6 +662,7 @@ void CTR_transparent_reflection_2_layer::drawTriangle ( const s4DVertex* burning #endif // render a scanline + interlace_scanline fragmentShader(); scan.x[0] += scan.slopeX[0]; diff --git a/source/Irrlicht/IBurningShader.cpp b/source/Irrlicht/IBurningShader.cpp index a375ef38..c7945e8c 100644 --- a/source/Irrlicht/IBurningShader.cpp +++ b/source/Irrlicht/IBurningShader.cpp @@ -12,29 +12,37 @@ namespace irr { - - namespace video { - const tFixPointu IBurningShader::dithermask[] = - { - 0x00,0x80,0x20,0xa0, - 0xc0,0x40,0xe0,0x60, - 0x30,0xb0,0x10,0x90, - 0xf0,0x70,0xd0,0x50 - }; +const tFixPointu IBurningShader::dithermask[] = +{ + 0x00,0x80,0x20,0xa0, + 0xc0,0x40,0xe0,0x60, + 0x30,0xb0,0x10,0x90, + 0xf0,0x70,0xd0,0x50 +}; void IBurningShader::constructor_IBurningShader(CBurningVideoDriver* driver) { - #ifdef _DEBUG +#ifdef _DEBUG setDebugName("IBurningShader"); - #endif +#endif + + if (((unsigned long long)&scan & 15) || ((unsigned long long)&line & 15)) + { + os::Printer::log("BurningVideo Shader not 16 byte aligned", ELL_ERROR); + _IRR_DEBUG_BREAK_IF(1); + } + + Interlaced.enable = 0; + Interlaced.bypass = 1; + Interlaced.nr = 0; EdgeTestPass = edge_test_pass; EdgeTestPass_stack = edge_test_pass; - for ( u32 i = 0; i < BURNING_MATERIAL_MAX_TEXTURES; ++i ) + for (u32 i = 0; i < BURNING_MATERIAL_MAX_TEXTURES; ++i) { IT[i].Texture = 0; } @@ -44,12 +52,12 @@ void IBurningShader::constructor_IBurningShader(CBurningVideoDriver* driver) RenderTarget = 0; ColorMask = COLOR_BRIGHT_WHITE; - DepthBuffer = (CDepthBuffer*) driver->getDepthBuffer (); - if ( DepthBuffer ) + DepthBuffer = (CDepthBuffer*)driver->getDepthBuffer(); + if (DepthBuffer) DepthBuffer->grab(); - Stencil = (CStencilBuffer*) driver->getStencilBuffer (); - if ( Stencil ) + Stencil = (CStencilBuffer*)driver->getStencilBuffer(); + if (Stencil) Stencil->grab(); stencilOp[0] = StencilOp_KEEP; @@ -76,7 +84,7 @@ IBurningShader::IBurningShader( const c8* pixelShaderProgram, const c8* pixelShaderEntryPointName, E_PIXEL_SHADER_TYPE psCompileTarget, - const c8* geometryShaderProgram , + const c8* geometryShaderProgram, const c8* geometryShaderEntryPointName, E_GEOMETRY_SHADER_TYPE gsCompileTarget, scene::E_PRIMITIVE_TYPE inType, @@ -109,9 +117,9 @@ IBurningShader::~IBurningShader() if (Stencil) Stencil->drop(); - for ( u32 i = 0; i != BURNING_MATERIAL_MAX_TEXTURES; ++i ) + for (u32 i = 0; i != BURNING_MATERIAL_MAX_TEXTURES; ++i) { - if ( IT[i].Texture ) + if (IT[i].Texture) IT[i].Texture->drop(); } @@ -121,12 +129,14 @@ IBurningShader::~IBurningShader() } //! sets a render target -void IBurningShader::setRenderTarget(video::IImage* surface, const core::rect& viewPort) +void IBurningShader::setRenderTarget(video::IImage* surface, const core::rect& viewPort, const interlaced_control interlaced) { + Interlaced = interlaced; + if (RenderTarget) RenderTarget->drop(); - RenderTarget = (video::CImage* ) surface; + RenderTarget = (video::CImage*) surface; if (RenderTarget) { @@ -138,16 +148,16 @@ void IBurningShader::setRenderTarget(video::IImage* surface, const core::rectTexture) + if (it->Texture) it->Texture->drop(); it->Texture = texture; - if ( it->Texture) + if (it->Texture) { it->Texture->grab(); @@ -156,48 +166,52 @@ void IBurningShader::setTextureParam( const size_t stage, video::CSoftwareTextur //only mipmap chain (means positive lodFactor) u32 existing_level = it->Texture->getMipmapLevel(lodFactor); - it->data = (tVideoSample*) it->Texture->lock(ETLM_READ_ONLY, existing_level, 0); +#if !defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) + it->data = (tVideoSample*)it->Texture->lock(ETLM_READ_ONLY, existing_level, 0); +#else + it->data = (tVideoSample*)it->Texture->lock(ETLM_READ_ONLY, existing_level); +#endif // prepare for optimal fixpoint - it->pitchlog2 = s32_log2_s32 ( it->Texture->getPitch() ); + it->pitchlog2 = s32_log2_s32(it->Texture->getPitch()); - const core::dimension2d &dim = it->Texture->getSize(); - it->textureXMask = s32_to_fixPoint ( dim.Width - 1 ) & FIX_POINT_UNSIGNED_MASK; - it->textureYMask = s32_to_fixPoint ( dim.Height - 1 ) & FIX_POINT_UNSIGNED_MASK; + const core::dimension2d& dim = it->Texture->getSize(); + it->textureXMask = s32_to_fixPoint(dim.Width - 1) & FIX_POINT_UNSIGNED_MASK; + it->textureYMask = s32_to_fixPoint(dim.Height - 1) & FIX_POINT_UNSIGNED_MASK; } } //emulate a line with degenerate triangle and special shader mode (not perfect...) -void IBurningShader::drawLine ( const s4DVertex *a,const s4DVertex *b) +void IBurningShader::drawLine(const s4DVertex* a, const s4DVertex* b) { sVec2 d; d.x = b->Pos.x - a->Pos.x; d.x *= d.x; d.y = b->Pos.y - a->Pos.y; d.y *= d.y; //if ( d.x * d.y < 0.001f ) return; - if ( a->Pos.x > b->Pos.x ) swapVertexPointer(&a, &b); + if (a->Pos.x > b->Pos.x) swapVertexPointer(&a, &b); s4DVertex c = *a; - const f32 w = (f32)RenderTarget->getDimension().Width-1; - const f32 h = (f32)RenderTarget->getDimension().Height-1; + const f32 w = (f32)RenderTarget->getDimension().Width - 1; + const f32 h = (f32)RenderTarget->getDimension().Height - 1; - if ( d.x < 2.f ) { c.Pos.x = b->Pos.x + 1.f + d.y; if ( c.Pos.x > w ) c.Pos.x = w; } + if (d.x < 2.f) { c.Pos.x = b->Pos.x + 1.f + d.y; if (c.Pos.x > w) c.Pos.x = w; } else c.Pos.x = b->Pos.x; - if ( d.y < 2.f ) { c.Pos.y = b->Pos.y + 1.f; if ( c.Pos.y > h ) c.Pos.y = h; EdgeTestPass |= edge_test_first_line; } + if (d.y < 2.f) { c.Pos.y = b->Pos.y + 1.f; if (c.Pos.y > h) c.Pos.y = h; EdgeTestPass |= edge_test_first_line; } - drawTriangle ( a,b,&c ); + drawTriangle(a, b, &c); EdgeTestPass &= ~edge_test_first_line; } -void IBurningShader::drawPoint(const s4DVertex *a) +void IBurningShader::drawPoint(const s4DVertex* a) { } -void IBurningShader::drawWireFrameTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) +void IBurningShader::drawWireFrameTriangle(const s4DVertex* a, const s4DVertex* b, const s4DVertex* c) { - if ( EdgeTestPass & edge_test_pass ) drawTriangle(a, b, c); + if (EdgeTestPass & edge_test_pass) drawTriangle(a, b, c); else if (EdgeTestPass & edge_test_point) { drawPoint(a); @@ -256,7 +270,7 @@ void IBurningShader::setBasicRenderStates(const SMaterial& material, const SMate Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); } -s32 IBurningShader::getShaderConstantID(EBurningUniformFlags flags,const c8* name) +s32 IBurningShader::getShaderConstantID(EBurningUniformFlags flags, const c8* name) { if (!name || !name[0]) return -1; @@ -285,7 +299,7 @@ const char* tiny_itoa(s32 value, int base) b[p] = '\0'; do { - b[--p] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[value%base]; + b[--p] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[value % base]; value /= base; } while (value && p > 0); @@ -302,7 +316,7 @@ bool IBurningShader::setShaderConstantID(EBurningUniformFlags flags, s32 index, BurningUniform add; while ((u32)index >= UniformInfo.size()) { - tiny_strcpy(add.name, tiny_itoa(UniformInfo.size(),10)); + tiny_strcpy(add.name, tiny_itoa(UniformInfo.size(), 10)); add.type = flags; UniformInfo.push_back(add); } @@ -340,7 +354,7 @@ void IBurningShader::setVertexShaderConstant(const f32* data, s32 startRegister, c8 name[BL_ACTIVE_UNIFORM_MAX_LENGTH]; tiny_strcpy(name, tiny_itoa(startRegister, 10)); - setShaderConstantID(BL_VERTEX_FLOAT, getShaderConstantID(BL_VERTEX_PROGRAM,name), data, constantAmount); + setShaderConstantID(BL_VERTEX_FLOAT, getShaderConstantID(BL_VERTEX_PROGRAM, name), data, constantAmount); } void IBurningShader::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) diff --git a/source/Irrlicht/IBurningShader.h b/source/Irrlicht/IBurningShader.h index 8a9a8180..748a9a40 100644 --- a/source/Irrlicht/IBurningShader.h +++ b/source/Irrlicht/IBurningShader.h @@ -215,7 +215,6 @@ namespace video }; - class CBurningVideoDriver; class IBurningShader : public IMaterialRenderer, public IMaterialRendererServices { @@ -247,7 +246,7 @@ namespace video virtual ~IBurningShader(); //! sets a render target - virtual void setRenderTarget(video::IImage* surface, const core::rect& viewPort); + virtual void setRenderTarget(video::IImage* surface, const core::rect& viewPort, const interlaced_control interlaced); //! sets the Texture virtual void setTextureParam( const size_t stage, video::CSoftwareTexture2* texture, s32 lodFactor); @@ -299,14 +298,38 @@ namespace video virtual bool setPixelShaderConstant(s32 index, const u32* ints, int count) _IRR_OVERRIDE_; virtual IVideoDriver* getVideoDriver() _IRR_OVERRIDE_; +#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) + virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count) + { + return setVertexShaderConstant(getVertexShaderConstantID(name), floats, count); + } + virtual bool setVertexShaderConstant(const c8* name, const bool* bools, int count) + { + return setVertexShaderConstant(getVertexShaderConstantID(name), (const s32*)bools, count); + } + virtual bool setVertexShaderConstant(const c8* name, const s32* ints, int count) + { + return setVertexShaderConstant(getVertexShaderConstantID(name), ints, count); + } + + virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count) + { + return setPixelShaderConstant(getPixelShaderConstantID(name), floats, count); + } + virtual bool setPixelShaderConstant(const c8* name, const bool* bools, int count) + { + return setPixelShaderConstant(getPixelShaderConstantID(name), (const s32*)bools, count); + } + virtual bool setPixelShaderConstant(const c8* name, const s32* ints, int count) + { + return setPixelShaderConstant(getPixelShaderConstantID(name), ints, count); + } +#endif + //used if no color interpolation is defined void setPrimitiveColor(const video::SColor& color) { - #if BURNINGSHADER_COLOR_FORMAT == ECF_A8R8G8B8 - PrimitiveColor = color.color; - #else - PrimitiveColor = color.toA1R5G5B5(); - #endif + PrimitiveColor = color_to_sample(color); } void setTLFlag(size_t in /*eTransformLightFlags*/) { @@ -314,11 +337,7 @@ namespace video } void setFog(SColor color_fog) { -#if BURNINGSHADER_COLOR_FORMAT == ECF_A8R8G8B8 - fog_color_sample = color_fog.color; -#else - fog_color_sample = color_fog.toA1R5G5B5(); -#endif + fog_color_sample = color_to_sample(color_fog); color_to_fix(fog_color, fog_color_sample); } void setScissor(const AbsRectangle& scissor) @@ -349,14 +368,15 @@ namespace video static const tFixPointu dithermask[ 4 * 4]; //draw degenerate triangle as line (left edge) drawTriangle -> holes,drawLine dda/bresenham - int EdgeTestPass; //edge_test_flag - int EdgeTestPass_stack; + size_t EdgeTestPass; //edge_test_flag + size_t EdgeTestPass_stack; + interlaced_control Interlaced; // passed from driver eBurningStencilOp stencilOp[4]; tFixPoint AlphaRef; int RenderPass_ShaderIsTransparent; - sScanConvertData scan; + sScanConvertData ALIGN(16) scan; sScanLineData line; tVideoSample PrimitiveColor; //used if no color interpolation is defined @@ -365,6 +385,17 @@ namespace video tVideoSample fog_color_sample; AbsRectangle Scissor; + + inline tVideoSample color_to_sample(const video::SColor& color) const + { + //RenderTarget->getColorFormat() +#if SOFTWARE_DRIVER_2_RENDERTARGET_COLOR_FORMAT == ECF_A8R8G8B8 + return color.color; +#else + return color.toA1R5G5B5(); +#endif + } + }; diff --git a/source/Irrlicht/IDepthBuffer.h b/source/Irrlicht/IDepthBuffer.h index 89f604f3..996926c8 100644 --- a/source/Irrlicht/IDepthBuffer.h +++ b/source/Irrlicht/IDepthBuffer.h @@ -21,7 +21,7 @@ namespace video virtual ~IDepthBuffer() {}; //! clears the zbuffer - virtual void clear(f32 value) = 0; + virtual void clear(f32 value, const interlaced_control interlaced) = 0; //! sets the new size of the zbuffer virtual void setSize(const core::dimension2d& size) = 0; @@ -52,7 +52,7 @@ namespace video virtual ~IStencilBuffer() {}; //! clears the stencil buffer - virtual void clear(u8 value) = 0; + virtual void clear(u32 value, const interlaced_control interlaced) = 0; //! sets the new size of the zbuffer virtual void setSize(const core::dimension2d& size) = 0; diff --git a/source/Irrlicht/S4DVertex.h b/source/Irrlicht/S4DVertex.h index 92abbb26..667fd6d4 100644 --- a/source/Irrlicht/S4DVertex.h +++ b/source/Irrlicht/S4DVertex.h @@ -79,6 +79,13 @@ struct sVec2 #include "irrpack.h" +//! sVec2Pack is Irrlicht S3DVertex,S3DVertex2TCoords,S3DVertexTangents Texutre Coordinates. +// Start address is not 4 byte aligned +struct sVec2Pack +{ + f32 x, y; +}; + //! sVec3Pack used in BurningShader, packed direction struct sVec3Pack { @@ -529,7 +536,7 @@ typedef s4DVertex s4DVertexPair; struct SAligned4DVertex { SAligned4DVertex() - :data(0),mem(0), ElementSize(0) {} + :data(0),ElementSize(0),mem(0) {} virtual ~SAligned4DVertex () { @@ -553,8 +560,11 @@ struct SAligned4DVertex } s4DVertex* data; //align to 16 byte - u8* mem; size_t ElementSize; + +private: + + u8* mem; }; //#define memcpy_s4DVertexPair(dst,src) memcpy(dst,src,sizeof_s4DVertex * 2) @@ -732,7 +742,7 @@ struct sScanConvertData { u32 left; // major edge left/right u32 right; // !left - u32 _unused_pack[2]; + u8 _unused_pack[8]; f32 invDeltaY[4]; // inverse edge delta for screen space sorted triangle @@ -767,7 +777,7 @@ struct sScanConvertData struct sScanLineData { s32 y; // y position of scanline - u32 _unused_pack[1]; + u8 _unused_pack[4]; f32 x[2]; // x start, x end of scanline #if defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) || defined ( SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT ) @@ -776,7 +786,8 @@ struct sScanLineData f32 z[2]; // z start, z end of scanline #endif - u32 _unused_pack_1[2]; + s32 x_edgetest; // slope x + u8 _unused_pack_1[4]; #if BURNING_MATERIAL_MAX_COLORS > 0 sVec4 c[BURNING_MATERIAL_MAX_COLORS][2]; // color start, color end of scanline diff --git a/source/Irrlicht/SoftwareDriver2_compile_config.h b/source/Irrlicht/SoftwareDriver2_compile_config.h index 725ba1a9..897049ac 100644 --- a/source/Irrlicht/SoftwareDriver2_compile_config.h +++ b/source/Irrlicht/SoftwareDriver2_compile_config.h @@ -10,140 +10,167 @@ // Generic Render Flags for burning's video rasterizer // defined now in irrlicht compile config -#if defined(PATCH_SUPERTUX_8_0_1) - #undef BURNINGVIDEO_RENDERER_BEAUTIFUL +#if 1 && defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) +#undef BURNINGVIDEO_RENDERER_BEAUTIFUL + +#define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT +#define SOFTWARE_DRIVER_2_SUBTEXEL +#define SOFTWARE_DRIVER_2_BILINEAR +#define SOFTWARE_DRIVER_2_LIGHTING +#define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR +//#define SOFTWARE_DRIVER_2_USE_SEPARATE_SPECULAR_COLOR +#define SOFTWARE_DRIVER_2_USE_WBUFFER +#define SOFTWARE_DRIVER_2_32BIT +#define SOFTWARE_DRIVER_2_TEXTURE_COLOR_FORMAT ECF_A8R8G8B8 +#define SOFTWARE_DRIVER_2_RENDERTARGET_COLOR_FORMAT ECF_A8R8G8B8 +#define SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE 256 +#define SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM +#define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 8 +#define SOFTWARE_DRIVER_2_MIPMAPPING_MIN_SIZE 1 +#define SOFTWARE_DRIVER_2_SCANLINE_MAG_MIN +#define SOFTWARE_DRIVER_2_CLIPPING +#define SOFTWARE_DRIVER_2_2D_AS_3D +#define SOFTWARE_DRIVER_2_INTERLACED - //#define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #define SOFTWARE_DRIVER_2_SUBTEXEL - //#define SOFTWARE_DRIVER_2_BILINEAR - #define SOFTWARE_DRIVER_2_LIGHTING - #define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #define SOFTWARE_DRIVER_2_USE_SEPARATE_SPECULAR_COLOR - #define SOFTWARE_DRIVER_2_32BIT - #define SOFTWARE_DRIVER_2_MIPMAPPING - #define SOFTWARE_DRIVER_2_USE_WBUFFER - #define SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM - #define SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE 256 - #define SOFTWARE_DRIVER_2_SCANLINE_MAG_MIN - #define SOFTWARE_DRIVER_2_CLIPPING - #define SOFTWARE_DRIVER_2_2D_AS_2D #endif - #ifdef BURNINGVIDEO_RENDERER_BEAUTIFUL - #define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #define SOFTWARE_DRIVER_2_SUBTEXEL - #define SOFTWARE_DRIVER_2_BILINEAR - #define SOFTWARE_DRIVER_2_LIGHTING - #define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #define SOFTWARE_DRIVER_2_USE_SEPARATE_SPECULAR_COLOR - #define SOFTWARE_DRIVER_2_32BIT - #define SOFTWARE_DRIVER_2_MIPMAPPING - #define SOFTWARE_DRIVER_2_USE_WBUFFER - #define SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM - #define SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE 0 - #define SOFTWARE_DRIVER_2_SCANLINE_MAG_MIN - #define SOFTWARE_DRIVER_2_CLIPPING - #define SOFTWARE_DRIVER_2_2D_AS_3D +#define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT +#define SOFTWARE_DRIVER_2_SUBTEXEL +#define SOFTWARE_DRIVER_2_BILINEAR +#define SOFTWARE_DRIVER_2_LIGHTING +#define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR +#define SOFTWARE_DRIVER_2_USE_SEPARATE_SPECULAR_COLOR +#define SOFTWARE_DRIVER_2_USE_WBUFFER +#define SOFTWARE_DRIVER_2_32BIT +#define SOFTWARE_DRIVER_2_TEXTURE_COLOR_FORMAT ECF_A8R8G8B8 +#define SOFTWARE_DRIVER_2_RENDERTARGET_COLOR_FORMAT ECF_A8R8G8B8 +#define SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE 0x100000 +#define SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM +#define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 16 +#define SOFTWARE_DRIVER_2_MIPMAPPING_MIN_SIZE 1 +#define SOFTWARE_DRIVER_2_SCANLINE_MAG_MIN +#define SOFTWARE_DRIVER_2_CLIPPING +#define SOFTWARE_DRIVER_2_2D_AS_3D +#define SOFTWARE_DRIVER_2_INTERLACED #endif //! Set Flags for Windows Mobile #ifdef BURNINGVIDEO_RENDERER_CE - #define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #define SOFTWARE_DRIVER_2_SUBTEXEL - //#define SOFTWARE_DRIVER_2_BILINEAR - //#define SOFTWARE_DRIVER_2_LIGHTING - #define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - #define SOFTWARE_DRIVER_2_16BIT - #define SOFTWARE_DRIVER_2_MIPMAPPING - #define SOFTWARE_DRIVER_2_USE_WBUFFER - //#define SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM - #define SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE 64 - #define SOFTWARE_DRIVER_2_SCANLINE_MAG_MIN - //#define SOFTWARE_DRIVER_2_CLIPPING - #define SOFTWARE_DRIVER_2_2D_AS_2D +#define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT +#define SOFTWARE_DRIVER_2_SUBTEXEL +//#define SOFTWARE_DRIVER_2_BILINEAR +//#define SOFTWARE_DRIVER_2_LIGHTING +#define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR +#define SOFTWARE_DRIVER_2_USE_WBUFFER +#define SOFTWARE_DRIVER_2_16BIT +#define SOFTWARE_DRIVER_2_TEXTURE_COLOR_FORMAT ECF_A1R5G5B5 +#define SOFTWARE_DRIVER_2_RENDERTARGET_COLOR_FORMAT ECF_A1R5G5B5 +#define SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE 64 +//#define SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM +#define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 4 +#define SOFTWARE_DRIVER_2_MIPMAPPING_MIN_SIZE 8 +#define SOFTWARE_DRIVER_2_SCANLINE_MAG_MIN +//#define SOFTWARE_DRIVER_2_CLIPPING +#define SOFTWARE_DRIVER_2_2D_AS_2D #endif #ifdef BURNINGVIDEO_RENDERER_FAST - #define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - #define SOFTWARE_DRIVER_2_SUBTEXEL - //#define SOFTWARE_DRIVER_2_BILINEAR - //#define SOFTWARE_DRIVER_2_LIGHTING - #define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - //#define SOFTWARE_DRIVER_2_32BIT - #define SOFTWARE_DRIVER_2_16BIT - #define SOFTWARE_DRIVER_2_MIPMAPPING - #define SOFTWARE_DRIVER_2_USE_WBUFFER - #define SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE 256 - #define SOFTWARE_DRIVER_2_SCANLINE_MAG_MIN - #define SOFTWARE_DRIVER_2_CLIPPING - #define SOFTWARE_DRIVER_2_2D_AS_2D +#define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT +#define SOFTWARE_DRIVER_2_SUBTEXEL +//#define SOFTWARE_DRIVER_2_BILINEAR +//#define SOFTWARE_DRIVER_2_LIGHTING +#define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR +#define SOFTWARE_DRIVER_2_USE_WBUFFER +#define SOFTWARE_DRIVER_2_16BIT +#define SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE 256 +#define SOFTWARE_DRIVER_2_TEXTURE_COLOR_FORMAT ECF_A1R5G5B5 +#define SOFTWARE_DRIVER_2_RENDERTARGET_COLOR_FORMAT ECF_A1R5G5B5 +#define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 4 +#define SOFTWARE_DRIVER_2_MIPMAPPING_MIN_SIZE 8 +#define SOFTWARE_DRIVER_2_SCANLINE_MAG_MIN +#define SOFTWARE_DRIVER_2_CLIPPING +#define SOFTWARE_DRIVER_2_2D_AS_2D +#define SOFTWARE_DRIVER_2_INTERLACED #endif #ifdef BURNINGVIDEO_RENDERER_ULTRA_FAST - #define BURNINGVIDEO_RENDERER_FAST +#define BURNINGVIDEO_RENDERER_FAST - //#define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT - //#define SOFTWARE_DRIVER_2_SUBTEXEL - //#define SOFTWARE_DRIVER_2_BILINEAR - //#define SOFTWARE_DRIVER_2_LIGHTING - #define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR - //#define SOFTWARE_DRIVER_2_32BIT - #define SOFTWARE_DRIVER_2_16BIT - //#define SOFTWARE_DRIVER_2_MIPMAPPING - //#define SOFTWARE_DRIVER_2_USE_WBUFFER - //#define SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM - #define SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE 128 - #define SOFTWARE_DRIVER_2_SCANLINE_MAG_MIN - //#define SOFTWARE_DRIVER_2_CLIPPING - #define SOFTWARE_DRIVER_2_2D_AS_2D +//#define SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT +//#define SOFTWARE_DRIVER_2_SUBTEXEL +//#define SOFTWARE_DRIVER_2_BILINEAR +//#define SOFTWARE_DRIVER_2_LIGHTING +#define SOFTWARE_DRIVER_2_USE_VERTEX_COLOR +//#define SOFTWARE_DRIVER_2_USE_WBUFFER +#define SOFTWARE_DRIVER_2_16BIT +#define SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE 128 +#define SOFTWARE_DRIVER_2_TEXTURE_COLOR_FORMAT ECF_A1R5G5B5 +#define SOFTWARE_DRIVER_2_RENDERTARGET_COLOR_FORMAT ECF_A1R5G5B5 +//#define SOFTWARE_DRIVER_2_TEXTURE_TRANSFORM +#define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 1 +#define SOFTWARE_DRIVER_2_MIPMAPPING_MIN_SIZE 1 +#define SOFTWARE_DRIVER_2_SCANLINE_MAG_MIN +//#define SOFTWARE_DRIVER_2_CLIPPING +#define SOFTWARE_DRIVER_2_2D_AS_2D +#define SOFTWARE_DRIVER_2_INTERLACED #endif -// Derivate flags - -// texture format -#ifdef SOFTWARE_DRIVER_2_32BIT - #define BURNINGSHADER_COLOR_FORMAT ECF_A8R8G8B8 -#else - #define BURNINGSHADER_COLOR_FORMAT ECF_A1R5G5B5 -#endif - -// mip mapping - precalculated texture filter -#if defined ( SOFTWARE_DRIVER_2_MIPMAPPING ) - #if defined( BURNINGVIDEO_RENDERER_BEAUTIFUL ) - #define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 16 - #define SOFTWARE_DRIVER_2_MIPMAPPING_MIN_SIZE 1 - #elif defined ( BURNINGVIDEO_RENDERER_CE ) - #define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 4 - #define SOFTWARE_DRIVER_2_MIPMAPPING_MIN_SIZE 8 - #else - #define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 4 - #define SOFTWARE_DRIVER_2_MIPMAPPING_MIN_SIZE 8 - #endif -#else - #define SOFTWARE_DRIVER_2_MIPMAPPING_MAX 1 - #define SOFTWARE_DRIVER_2_MIPMAPPING_MIN_SIZE 1 -#endif - - #ifndef REALINLINE - #ifdef _MSC_VER - #define REALINLINE __forceinline - #else - #define REALINLINE inline - #endif +#ifdef _MSC_VER +#define REALINLINE __forceinline +#else +#define REALINLINE inline +#endif #endif +#define reciprocal_zero(x) ((x) != 0.f ? 1.f / (x):0.f) +#define reciprocal_one(x) ((x) != 0.f ? 1.f / (x):1.f) + +//Control Scanline output +#define SOFTWARE_DRIVER_2_STEP_X 1 +#define SOFTWARE_DRIVER_2_STEP_Y 1 // null check necessary (burningvideo only) -#define reciprocal_zero(x) ((x) != 0.f ? 1.f / (x):0.f) -static inline float reciprocal_zero2(float x) { return x != 0.f ? 1.f / x : 0.f; } -#define reciprocal_one(x) ((x) != 0.f ? 1.f / (x):1.f) +#define fill_step_y(y) ((y) != 0.f ? (float)1.f / (y):0.f) +static inline float fill_step_x(float x) { return x != 0.f ? (float)SOFTWARE_DRIVER_2_STEP_X / x : 0.f; } + +#define interlace_control_bit 1 +#define interlace_control_mask ((1<> (interlace_control_bit-1) ) & 1) == (Interlaced.nr & 1)) ) +//#define interlace_scanline +#else +#define interlace_scanline +#define interlace_scanline_enabled +#endif + +#define scissor_test_y if ((~TL_Flag & TL_SCISSOR) || ((line.y >= Scissor.y0) & (line.y <= Scissor.y1))) +#define scissor_test_x if ((~TL_Flag & TL_SCISSOR) || ((i+xStart >= Scissor.x0) & (i+xStart <= Scissor.x1))) #define fill_convention_left(x) (s32) ceilf(x) #define fill_convention_right(x) ((s32) ceilf(x))-1 #define fill_convention_none(x) (s32) (x) +#define fill_convention_edge(x) (s32) floorf(fabsf(x)+0.f) //#define fill_convention_left(x) 65536 - int(65536.0f - x) //#define fill_convention_right(x) 65535 - int(65536.0f - x) @@ -157,7 +184,7 @@ static inline float reciprocal_zero2(float x) { return x != 0.f ? 1.f / x : 0.f; inline float reciprocal_zero_no(const float x) { - if (x*x <= 0.00001f) __debugbreak(); + if (x * x <= 0.00001f) __debugbreak(); return 1.f / x; } #else @@ -183,49 +210,49 @@ enum edge_test_flag #define fix_color_norm(x) x = (x+1) >> COLOR_MAX_LOG2 //! from 1 bit to 5 bit -#ifdef SOFTWARE_DRIVER_2_32BIT - #define fix_alpha_color_max(x) +#if defined(SOFTWARE_DRIVER_2_32BIT) +#define fix_alpha_color_max(x) #else - #define fix_alpha_color_max(x) if (x) x = (x << COLOR_MAX_LOG2) - 1 +#define fix_alpha_color_max(x) if (x) x = (x << COLOR_MAX_LOG2) - 1 #endif // Check windows #if _WIN32 || _WIN64 #if _WIN64 - #define ENV64BIT +#define ENV64BIT #else - #define ENV32BIT +#define ENV32BIT #endif #endif // Check GCC #if __GNUC__ #if __x86_64__ || __ppc64__ - #define ENV64BIT +#define ENV64BIT #else - #define ENV32BIT +#define ENV32BIT #endif #endif #if defined(ENV64BIT) && defined(BURNINGVIDEO_RENDERER_BEAUTIFUL) - typedef float ipoltype; +typedef float ipoltype; #else - typedef float ipoltype; +typedef float ipoltype; #endif #define ipol_lower_equal_0(n) ((n) <= (ipoltype)0.0) #define ipol_greater_0(n) ((n) > (ipoltype)0.0) #if (_MSC_VER > 1700 ) - #define burning_restrict __restrict +#define burning_restrict __restrict #else - #define burning_restrict +#define burning_restrict #endif /* if (condition) state |= mask; else state &= ~mask; */ -static inline void burning_setbit(size_t &state, int condition, size_t mask) +static inline void burning_setbit(size_t& state, int condition, size_t mask) { if (condition) state |= mask; else state &= ~mask; @@ -234,7 +261,7 @@ static inline void burning_setbit(size_t &state, int condition, size_t mask) /* if (condition) state |= m; else state &= ~m; */ -REALINLINE void burning_setbit32(unsigned int &state, int condition, const unsigned int mask) +REALINLINE void burning_setbit32(unsigned int& state, int condition, const unsigned int mask) { // 0, or any positive to mask //s32 conmask = -condition >> 31; @@ -246,44 +273,46 @@ REALINLINE void burning_setbit32(unsigned int &state, int condition, const unsig #define burning_create(s) burning_create_indirect(s) -#if defined(PATCH_SUPERTUX_8_0_1) -#define getData lock +#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) #define snprintf_irr sprintf_s - -#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR -#ifdef SOFTWARE_DRIVER_2_USE_SEPARATE_SPECULAR_COLOR -#define BURNING_MATERIAL_MAX_COLORS 2 -#else -#define BURNING_MATERIAL_MAX_COLORS 1 -#endif -#else -#define BURNING_MATERIAL_MAX_COLORS 0 -#endif - -#ifndef _IRR_OVERRIDE_ -#define _IRR_OVERRIDE_ /**/ -#endif - -#define fix_to_color fix_to_sample -#define fix4_to_color fix4_to_sample -#define vec4_to_fix getSample_color -#define SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS 0 +#define EVDF_DEPTH_CLAMP 43 +#define E_CUBE_SURFACE int +#define ECFN_DISABLED 0 namespace irr { + namespace video { - REALINLINE void memcpy32_small(void * dest, const void *source, size_t bytesize) - { - size_t c = bytesize >> 2; - - do + //! Enum for the flags of clear buffer + enum E_CLEAR_BUFFER_FLAG { - ((unsigned int *)dest)[c - 1] = ((unsigned int *)source)[c - 1]; - } while (--c); + ECBF_NONE = 0, + ECBF_COLOR = 1, + ECBF_DEPTH = 2, + ECBF_STENCIL = 4, + ECBF_ALL = ECBF_COLOR | ECBF_DEPTH | ECBF_STENCIL + }; + //! For SMaterial.ZWriteEnable + enum E_ZWRITE + { + EZW_OFF = 0, + EZW_AUTO, + EZW_ON + }; } +} +#endif // PATCH_SUPERTUX_8_0_1_with_1_9_0 -} // namespace irr -#endif // #if defined(PATCH_SUPERTUX_8_0_1) +//! Size of a static C-style array. +#define array_size(_arr) ((sizeof(_arr)/sizeof(*_arr))) +//! Compiler Align +#if defined(_MSC_VER) +#define ALIGN(x) __declspec(align(x)) +#elif defined(__GNUC__) +#define ALIGN(x) __attribute__ ((aligned(x))) +#else +#define ALIGN(x) +#endif #endif // __S_VIDEO_2_SOFTWARE_COMPILE_CONFIG_H_INCLUDED__ diff --git a/source/Irrlicht/SoftwareDriver2_helper.h b/source/Irrlicht/SoftwareDriver2_helper.h index 433ea457..83168c94 100644 --- a/source/Irrlicht/SoftwareDriver2_helper.h +++ b/source/Irrlicht/SoftwareDriver2_helper.h @@ -22,7 +22,7 @@ namespace irr // supporting different packed pixel needs many defines... -#ifdef SOFTWARE_DRIVER_2_32BIT +#if defined(SOFTWARE_DRIVER_2_32BIT) typedef u32 tVideoSample; typedef u32 tStencilSample; @@ -40,8 +40,8 @@ namespace irr #define COLOR_MAX_LOG2 8 #define COLOR_BRIGHT_WHITE 0xFFFFFFFF - #define VIDEO_SAMPLE_GRANULARITY (unsigned)2 - + #define SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY (unsigned)2 + #define SOFTWARE_DRIVER_2_RENDERTARGET_GRANULARITY (unsigned)2 #else typedef u16 tVideoSample; typedef u8 tStencilSample; @@ -59,7 +59,8 @@ namespace irr #define COLOR_MAX 0x1F #define COLOR_MAX_LOG2 5 #define COLOR_BRIGHT_WHITE 0xFFFF - #define VIDEO_SAMPLE_GRANULARITY (unsigned)1 + #define SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY (unsigned)1 + #define SOFTWARE_DRIVER_2_RENDERTARGET_GRANULARITY (unsigned)1 #endif @@ -140,6 +141,19 @@ inline void memset16(void * dest, const u16 value, size_t bytesize) } } +//! memset interleaved +inline void memset32_interlaced(void* dest, const u32 value, size_t pitch,u32 height,const interlaced_control Interlaced) +{ + if (Interlaced.bypass) return memset32(dest, value, pitch * height); + + u8* dst = (u8*)dest; + interlace_scanline_data line; + for (line.y = 0; line.y < height; line.y += SOFTWARE_DRIVER_2_STEP_Y) + { + interlace_scanline_enabled memset32(dst, value, pitch); + dst += pitch; + } +} // byte-align structures #include "irrpack.h" @@ -577,7 +591,7 @@ REALINLINE tFixPoint imulFix2(const tFixPoint x, const tFixPoint y) */ REALINLINE tFixPoint imulFix_tex1(const tFixPoint x, const tFixPoint y) { -#ifdef SOFTWARE_DRIVER_2_32BIT +#if SOFTWARE_DRIVER_2_TEXTURE_COLOR_FORMAT == ECF_A8R8G8B8 return (((tFixPointu)x >> 2)*(((tFixPointu)y + FIX_POINT_ONE) >> 2)) >> (tFixPointu) (FIX_POINT_PRE + 4); #else return (x * (y+ FIX_POINT_ONE)) >> (FIX_POINT_PRE + 5); @@ -598,7 +612,7 @@ REALINLINE tFixPoint imulFix_tex2(const tFixPoint x, const tFixPoint y) REALINLINE tFixPoint imulFix_tex4(const tFixPoint x, const tFixPoint y) { -#ifdef SOFTWARE_DRIVER_2_32BIT +#if SOFTWARE_DRIVER_2_TEXTURE_COLOR_FORMAT == ECF_A8R8G8B8 tFixPoint a = (((tFixPointu)x >> 2)*(((tFixPointu)y + FIX_POINT_ONE) >> 2)) >> (tFixPointu)(FIX_POINT_PRE + 2); #else tFixPoint a = (x * (y + FIX_POINT_ONE)) >> (FIX_POINT_PRE + 3); @@ -608,17 +622,6 @@ REALINLINE tFixPoint imulFix_tex4(const tFixPoint x, const tFixPoint y) } -#if 0 -#define imulFix_tex1(x,y) ((((tFixPointu)x >> 2) * ((tFixPointu)y >> 2)) >> (tFixPointu)(FIX_POINT_PRE + 4)) -#define imulFix_tex2(x,y) ((((tFixPointu)x >> 2) * ((tFixPointu)y >> 2)) >> (tFixPointu)(FIX_POINT_PRE + 3)) - -#ifdef SOFTWARE_DRIVER_2_32BIT -#define imulFix_tex4(x,y) ( ( (tFixPointu) x >> 2 ) * ( (tFixPointu) y >> 2 ) ) >> (tFixPointu) ( FIX_POINT_PRE + 2 ) -#else -#define imulFix_tex4(x,y) ( x * y) >> ( FIX_POINT_PRE + ( VIDEO_SAMPLE_GRANULARITY * 3 ) ) -#endif -#endif - /*! clamp FixPoint to maxcolor in FixPoint, min(a,COLOR_MAX) */ @@ -831,7 +834,7 @@ static inline tVideoSample getTexel_plain ( const sInternalTexture* t, const tFi size_t ofs; ofs = ( ( ty & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; - ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); + ofs |= ( tx & t->textureXMask ) >> ( FIX_POINT_PRE - SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY ); // texel return *((tVideoSample*)( (u8*) t->data + ofs )); @@ -845,7 +848,7 @@ inline void getTexel_fix ( tFixPoint &r, tFixPoint &g, tFixPoint &b, size_t ofs; ofs = ( ((ty + FIX_POINT_ZERO_DOT_FIVE) & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; - ofs |= ((tx + FIX_POINT_ZERO_DOT_FIVE) & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); + ofs |= ((tx + FIX_POINT_ZERO_DOT_FIVE) & t->textureXMask ) >> ( FIX_POINT_PRE - SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY ); // texel tVideoSample t00; @@ -865,7 +868,7 @@ inline void getTexel_fix(tFixPoint &a, tFixPoint &r, tFixPoint &g, tFixPoint &b, size_t ofs; ofs = (((ty+ FIX_POINT_ZERO_DOT_FIVE) & t->textureYMask) >> FIX_POINT_PRE) << t->pitchlog2; - ofs |= ((tx+ FIX_POINT_ZERO_DOT_FIVE) & t->textureXMask) >> (FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY); + ofs |= ((tx+ FIX_POINT_ZERO_DOT_FIVE) & t->textureXMask) >> (FIX_POINT_PRE - SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY); // texel tVideoSample t00; @@ -886,7 +889,7 @@ static REALINLINE void getTexel_fix ( tFixPoint &a, size_t ofs; ofs = ( ((ty + FIX_POINT_ZERO_DOT_FIVE) & t->textureYMask ) >> FIX_POINT_PRE ) << t->pitchlog2; - ofs |= ((tx + FIX_POINT_ZERO_DOT_FIVE) & t->textureXMask ) >> ( FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY ); + ofs |= ((tx + FIX_POINT_ZERO_DOT_FIVE) & t->textureXMask ) >> ( FIX_POINT_PRE - SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY ); // texel tVideoSample t00; @@ -913,7 +916,7 @@ static REALINLINE void getSample_texture(tFixPoint &r, tFixPoint &g, tFixPoint & size_t ofs; ofs = (((ty + FIX_POINT_ZERO_DOT_FIVE) & t->textureYMask) >> FIX_POINT_PRE) << t->pitchlog2; - ofs += ((tx + FIX_POINT_ZERO_DOT_FIVE) & t->textureXMask) >> (FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY); + ofs += ((tx + FIX_POINT_ZERO_DOT_FIVE) & t->textureXMask) >> (FIX_POINT_PRE - SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY); // texel tVideoSample t00; @@ -937,8 +940,8 @@ static REALINLINE void getSample_texture(tFixPoint &r, tFixPoint &g, tFixPoint & //wraps positive (ignoring negative) o0 = (((ty)& t->textureYMask) >> FIX_POINT_PRE) << t->pitchlog2; o1 = (((ty + FIX_POINT_ONE) & t->textureYMask) >> FIX_POINT_PRE) << t->pitchlog2; - o2 = ((tx)& t->textureXMask) >> (FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY); - o3 = ((tx + FIX_POINT_ONE) & t->textureXMask) >> (FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY); + o2 = ((tx)& t->textureXMask) >> (FIX_POINT_PRE - SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY); + o3 = ((tx + FIX_POINT_ONE) & t->textureXMask) >> (FIX_POINT_PRE - SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY); t00 = *((tVideoSample*)((u8*)t->data + (o0 + o2))); r00 = (t00 & MASK_R) >> SHIFT_R; @@ -1001,7 +1004,7 @@ static REALINLINE void getSample_texture(tFixPoint &r, tFixPoint &g, tFixPoint & //nearest neighbor size_t ofs; ofs = (((ty + FIX_POINT_ZERO_DOT_FIVE) & tex->textureYMask) >> FIX_POINT_PRE) << tex->pitchlog2; - ofs += ((tx + FIX_POINT_ZERO_DOT_FIVE) & tex->textureXMask) >> (FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY); + ofs += ((tx + FIX_POINT_ZERO_DOT_FIVE) & tex->textureXMask) >> (FIX_POINT_PRE - SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY); tVideoSample t00; t00 = *((tVideoSample*)((u8*)tex->data + ofs)); @@ -1029,8 +1032,8 @@ static REALINLINE void getSample_texture(tFixPoint &r, tFixPoint &g, tFixPoint & size_t o0, o1, o2, o3; o0 = (((ty) & tex->textureYMask) >> FIX_POINT_PRE) << tex->pitchlog2; o1 = (((ty + FIX_POINT_ONE) & tex->textureYMask) >> FIX_POINT_PRE) << tex->pitchlog2; - o2 = ((tx)& tex->textureXMask) >> (unsigned)(FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY); - o3 = ((tx + FIX_POINT_ONE) & tex->textureXMask) >> (unsigned)(FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY); + o2 = ((tx)& tex->textureXMask) >> (unsigned)(FIX_POINT_PRE - SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY); + o3 = ((tx + FIX_POINT_ONE) & tex->textureXMask) >> (unsigned)(FIX_POINT_PRE - SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY); t[0] = *((tVideoSample*)((u8*)tex->data + (o0 + o2))); t[1] = *((tVideoSample*)((u8*)tex->data + (o0 + o3))); @@ -1072,8 +1075,8 @@ static REALINLINE void getSample_texture(tFixPoint &a, tFixPoint &r, tFixPoint & o0 = (((ty)& tex->textureYMask) >> FIX_POINT_PRE) << tex->pitchlog2; o1 = (((ty + FIX_POINT_ONE) & tex->textureYMask) >> FIX_POINT_PRE) << tex->pitchlog2; - o2 = ((tx)& tex->textureXMask) >> (FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY); - o3 = ((tx + FIX_POINT_ONE) & tex->textureXMask) >> (FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY); + o2 = ((tx)& tex->textureXMask) >> (FIX_POINT_PRE - SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY); + o3 = ((tx + FIX_POINT_ONE) & tex->textureXMask) >> (FIX_POINT_PRE - SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY); t00 = *((tVideoSample*)((u8*)tex->data + (o0 + o2))); a00 = (t00 & MASK_A) >> SHIFT_A; @@ -1144,7 +1147,7 @@ static REALINLINE void getSample_texture(tFixPoint &r, tFixPoint &g, tFixPoint & { size_t ofs; ofs = (((ty + FIX_POINT_ZERO_DOT_FIVE) & t->textureYMask) >> FIX_POINT_PRE) << t->pitchlog2; - ofs += ((tx + FIX_POINT_ZERO_DOT_FIVE) & t->textureXMask) >> (FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY); + ofs += ((tx + FIX_POINT_ZERO_DOT_FIVE) & t->textureXMask) >> (FIX_POINT_PRE - SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY); // texel const tVideoSample t00 = *((tVideoSample*)((u8*)t->data + ofs)); @@ -1160,7 +1163,7 @@ static REALINLINE void getSample_texture(tFixPoint &a, tFixPoint &r, tFixPoint & { size_t ofs; ofs = (((ty + FIX_POINT_ZERO_DOT_FIVE) & t->textureYMask) >> FIX_POINT_PRE) << t->pitchlog2; - ofs += ((tx + FIX_POINT_ZERO_DOT_FIVE) & t->textureXMask) >> (FIX_POINT_PRE - VIDEO_SAMPLE_GRANULARITY); + ofs += ((tx + FIX_POINT_ZERO_DOT_FIVE) & t->textureXMask) >> (FIX_POINT_PRE - SOFTWARE_DRIVER_2_TEXTURE_GRANULARITY); // texel const tVideoSample t00 = *((tVideoSample*)((u8*)t->data + ofs)); @@ -1233,8 +1236,6 @@ static inline int tiny_isequal(const char *s1, const char *s2, size_t n) } #define tiny_istoken(a, b) tiny_isequal(a,b,sizeof(a)-1) != 0 -//! Size of a static C-style array. -#define array_size(_arr) ((sizeof(_arr)/sizeof(*_arr))) } // end namespace irr diff --git a/source/Irrlicht/burning_shader_compile_fragment_start.h b/source/Irrlicht/burning_shader_compile_fragment_start.h index 64a84633..15306449 100644 --- a/source/Irrlicht/burning_shader_compile_fragment_start.h +++ b/source/Irrlicht/burning_shader_compile_fragment_start.h @@ -40,7 +40,7 @@ void burning_shader_class::burning_shader_fragment() return; // slopes - const f32 invDeltaX = reciprocal_zero2(line.x[1] - line.x[0]); + const f32 invDeltaX = fill_step_x(line.x[1] - line.x[0]); #ifdef IPOL_Z slopeZ = (line.z[1] - line.z[0]) * invDeltaX; @@ -96,9 +96,9 @@ void burning_shader_class::burning_shader_fragment() tFixPoint r1, g1, b1; #endif - for (s32 i = 0; i <= dx; ++i) + for (s32 i = 0; i <= dx; i+= SOFTWARE_DRIVER_2_STEP_X) { - if ((0 == EdgeTestPass) & i) break; + if ((0 == EdgeTestPass) & (i > line.x_edgetest)) break; #ifdef CMP_Z if (line.z[0] < z[i]) diff --git a/source/Irrlicht/burning_shader_compile_triangle.h b/source/Irrlicht/burning_shader_compile_triangle.h index aa588581..5594b989 100644 --- a/source/Irrlicht/burning_shader_compile_triangle.h +++ b/source/Irrlicht/burning_shader_compile_triangle.h @@ -139,8 +139,10 @@ void burning_shader_class::drawTriangle(const s4DVertex* burning_restrict a, con #endif + line.x_edgetest = fill_convention_edge(scan.slopeX[scan.left]); + // rasterize the edge scanlines - for (line.y = yStart; line.y <= yEnd; ++line.y) + for (line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -171,6 +173,7 @@ void burning_shader_class::drawTriangle(const s4DVertex* burning_restrict a, con #endif // render a scanline + interlace_scanline (this->*fragmentShader) (); if (EdgeTestPass & edge_test_first_line) break; @@ -265,7 +268,6 @@ void burning_shader_class::drawTriangle(const s4DVertex* burning_restrict a, con yEnd = fill_convention_right(c->Pos.y); #ifdef SUBTEXEL - subPixel = ((f32)yStart) - b->Pos.y; // correct to pixel center @@ -299,8 +301,10 @@ void burning_shader_class::drawTriangle(const s4DVertex* burning_restrict a, con #endif + line.x_edgetest = fill_convention_edge(scan.slopeX[scan.left]); + // rasterize the edge scanlines - for (line.y = yStart; line.y <= yEnd; ++line.y) + for (line.y = yStart; line.y <= yEnd; line.y += SOFTWARE_DRIVER_2_STEP_Y) { line.x[scan.left] = scan.x[0]; line.x[scan.right] = scan.x[1]; @@ -331,6 +335,7 @@ void burning_shader_class::drawTriangle(const s4DVertex* burning_restrict a, con #endif // render a scanline + interlace_scanline (this->*fragmentShader) (); if (EdgeTestPass & edge_test_first_line) break; diff --git a/source/Irrlicht/libpng/AUTHORS b/source/Irrlicht/libpng/AUTHORS new file mode 100644 index 00000000..aa940bd1 --- /dev/null +++ b/source/Irrlicht/libpng/AUTHORS @@ -0,0 +1,45 @@ +PNG REFERENCE LIBRARY AUTHORS +============================= + +This is the list of PNG Reference Library ("libpng") Contributing +Authors, for copyright and licensing purposes. + + * Andreas Dilger + * Cosmin Truta + * Dave Martindale + * Eric S. Raymond + * Gilles Vollant + * Glenn Randers-Pehrson + * Greg Roelofs + * Guy Eric Schalnat + * James Yu + * John Bowler + * Kevin Bracey + * Magnus Holmgren + * Mandar Sahastrabuddhe + * Mans Rullgard + * Matt Sarett + * Mike Klein + * Paul Schmidt + * Sam Bushell + * Samuel Williams + * Simon-Pierre Cadieux + * Tim Wegner + * Tom Lane + * Tom Tanner + * Vadim Barkov + * Willem van Schaik + * Zhijie Liang + * Arm Holdings + - Richard Townsend + * Google Inc. + - Matt Sarett + - Mike Klein + +The build projects, the build scripts, the test scripts, and other +files in the "projects", "scripts" and "tests" directories, have other +copyright owners, but are released under the libpng license. + +Some files in the "contrib" directory, and some tools-generated files +that are distributed with libpng, have other copyright owners, and are +released under other open source licenses. diff --git a/source/Irrlicht/libpng/TRADEMARK b/source/Irrlicht/libpng/TRADEMARK new file mode 100644 index 00000000..747a8cf9 --- /dev/null +++ b/source/Irrlicht/libpng/TRADEMARK @@ -0,0 +1,8 @@ +TRADEMARK +========= + +The name "libpng" has not been registered by the Copyright owners +as a trademark in any jurisdiction. However, because libpng has +been distributed and maintained world-wide, continually since 1995, +the Copyright owners claim "common-law trademark protection" in any +jurisdiction where common-law trademark is recognized. diff --git a/source/Irrlicht/libpng/configure b/source/Irrlicht/libpng/configure deleted file mode 100644 index 0a32060c..00000000 --- a/source/Irrlicht/libpng/configure +++ /dev/null @@ -1,19 +0,0 @@ - -echo " - There is no \"configure\" script in this distribution (*.zip or *.7z) of - libpng-1.6.23. - - Instead, please copy the appropriate makefile for your system from the - \"scripts\" directory. Read the INSTALL file for more details. - - Update, July 2004: you can get a \"configure\" based distribution - from the libpng distribution sites. Download the file - libpng-1.6.23.tar.gz or libpng-1.6.23.tar.xz. - - If the line endings in the files look funny, which is likely to be the - case if you were trying to run \"configure\" on a Linux machine, you may - wish to get the other distribution of libpng. It is available in both - tar.gz/tar.xz (UNIX style line endings, with \"configure\") and .7z/.zip - (DOS style line endings, without \"configure\") formats. -" - diff --git a/source/Irrlicht/libpng/libpng-config.in b/source/Irrlicht/libpng/libpng-config.in deleted file mode 100644 index 199ad876..00000000 --- a/source/Irrlicht/libpng/libpng-config.in +++ /dev/null @@ -1,127 +0,0 @@ -#! /bin/sh - -# libpng-config -# provides configuration info for libpng. - -# Copyright (C) 2002, 2004, 2006, 2007 Glenn Randers-Pehrson - -# This code is released under the libpng license. -# For conditions of distribution and use, see the disclaimer -# and license in png.h - -# Modeled after libxml-config. - -version="@PNGLIB_VERSION@" -prefix="@prefix@" -exec_prefix="@exec_prefix@" -libdir="@libdir@" -includedir="@includedir@/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@" -libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@" -all_libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ @LIBS@" -I_opts="-I${includedir}" -L_opts="-L${libdir}" -R_opts="" -cppflags="" -ccopts="" -ldopts="" - -usage() -{ - cat < # else diff --git a/source/Irrlicht/libpng/pngusr.dfa b/source/Irrlicht/libpng/pngusr.dfa new file mode 100644 index 00000000..d1b4d374 --- /dev/null +++ b/source/Irrlicht/libpng/pngusr.dfa @@ -0,0 +1,14 @@ +# pngusr.dfa +# +# Build time configuration of libpng +# +# Enter build configuration options in this file +# +# Security settings: by default these limits are unset, you can change them +# here by entering the appropriate values as #defines preceded by '@' (to cause, +# them to be passed through to the build of pnglibconf.h), for example: +# +# @# define PNG_USER_WIDTH_MAX 65535 +# @# define PNG_USER_HEIGHT_MAX 65535 +# @# define PNG_USER_CHUNK_CACHE_MAX 256 +# @# define PNG_USER_CHUNK_MALLOC_MAX 640000 diff --git a/tests/flyCircleAnimator.cpp b/tests/flyCircleAnimator.cpp index 272dd895..b976d313 100644 --- a/tests/flyCircleAnimator.cpp +++ b/tests/flyCircleAnimator.cpp @@ -48,7 +48,7 @@ bool flyCircleAnimator(void) { smgr->drawAll(); driver->endScene(); - result = takeScreenshotAndCompareAgainstReference(driver, "-flyCircleAnimator.png", 100); + result = takeScreenshotAndCompareAgainstReference(driver, "-flyCircleAnimator.png"); } device->closeDevice(); diff --git a/tests/media/Burning's Video-2dmatFilter.png b/tests/media/Burning's Video-2dmatFilter.png index bdd17cd1..09891c8e 100644 Binary files a/tests/media/Burning's Video-2dmatFilter.png and b/tests/media/Burning's Video-2dmatFilter.png differ diff --git a/tests/media/Burning's Video-ambient-lighting.png b/tests/media/Burning's Video-ambient-lighting.png index a49b3071..242d8d75 100644 Binary files a/tests/media/Burning's Video-ambient-lighting.png and b/tests/media/Burning's Video-ambient-lighting.png differ diff --git a/tests/media/Burning's Video-draw2DImage4cFilter.png b/tests/media/Burning's Video-draw2DImage4cFilter.png index 352640e1..b0629d89 100644 Binary files a/tests/media/Burning's Video-draw2DImage4cFilter.png and b/tests/media/Burning's Video-draw2DImage4cFilter.png differ diff --git a/tests/media/Burning's Video-drawPixel.png b/tests/media/Burning's Video-drawPixel.png index 08288a85..acded3e4 100644 Binary files a/tests/media/Burning's Video-drawPixel.png and b/tests/media/Burning's Video-drawPixel.png differ diff --git a/tests/media/Burning's Video-multiTexture.png b/tests/media/Burning's Video-multiTexture.png index 338f257e..e02176b0 100644 Binary files a/tests/media/Burning's Video-multiTexture.png and b/tests/media/Burning's Video-multiTexture.png differ diff --git a/tests/media/Burning's Video-orthoCam.png b/tests/media/Burning's Video-orthoCam.png index 41a96b8b..099f9b71 100644 Binary files a/tests/media/Burning's Video-orthoCam.png and b/tests/media/Burning's Video-orthoCam.png differ diff --git a/tests/media/Burning's Video-planeMatrix-scaledClip.png b/tests/media/Burning's Video-planeMatrix-scaledClip.png index 7c93216e..36d6cb9d 100644 Binary files a/tests/media/Burning's Video-planeMatrix-scaledClip.png and b/tests/media/Burning's Video-planeMatrix-scaledClip.png differ diff --git a/tests/media/Burning's Video-renderMipmap.png b/tests/media/Burning's Video-renderMipmap.png index d2d53210..74b8e7f1 100644 Binary files a/tests/media/Burning's Video-renderMipmap.png and b/tests/media/Burning's Video-renderMipmap.png differ diff --git a/tests/media/Burning's Video-stencilShadow.png b/tests/media/Burning's Video-stencilShadow.png index 77c53fd6..0186a74a 100644 Binary files a/tests/media/Burning's Video-stencilShadow.png and b/tests/media/Burning's Video-stencilShadow.png differ diff --git a/tests/media/Burning's Video-terrainGap.png b/tests/media/Burning's Video-terrainGap.png index db125626..66480ba5 100644 Binary files a/tests/media/Burning's Video-terrainGap.png and b/tests/media/Burning's Video-terrainGap.png differ diff --git a/tests/media/Burning's Video-terrainSceneNode-1.png b/tests/media/Burning's Video-terrainSceneNode-1.png index e7a89935..d105e824 100644 Binary files a/tests/media/Burning's Video-terrainSceneNode-1.png and b/tests/media/Burning's Video-terrainSceneNode-1.png differ diff --git a/tests/media/Burning's Video-terrainSceneNode-2.png b/tests/media/Burning's Video-terrainSceneNode-2.png index 1c7538ab..63facea4 100644 Binary files a/tests/media/Burning's Video-terrainSceneNode-2.png and b/tests/media/Burning's Video-terrainSceneNode-2.png differ diff --git a/tests/media/Burning's Video-testGeometryCreator.png b/tests/media/Burning's Video-testGeometryCreator.png index 55665438..b4aeab60 100644 Binary files a/tests/media/Burning's Video-testGeometryCreator.png and b/tests/media/Burning's Video-testGeometryCreator.png differ diff --git a/tests/media/Burning's Video-testTerrainMesh.png b/tests/media/Burning's Video-testTerrainMesh.png index 802c4ec2..98a7c0d2 100644 Binary files a/tests/media/Burning's Video-testTerrainMesh.png and b/tests/media/Burning's Video-testTerrainMesh.png differ diff --git a/tests/media/Burning's Video-textureMatrix2.png b/tests/media/Burning's Video-textureMatrix2.png index 26afc9e7..f1875230 100644 Binary files a/tests/media/Burning's Video-textureMatrix2.png and b/tests/media/Burning's Video-textureMatrix2.png differ diff --git a/tests/media/Burning's Video-textureRenderStates.png b/tests/media/Burning's Video-textureRenderStates.png index 92c29fc7..a2db0d1c 100644 Binary files a/tests/media/Burning's Video-textureRenderStates.png and b/tests/media/Burning's Video-textureRenderStates.png differ diff --git a/tests/media/Burning's Video-writeImageToFile.png b/tests/media/Burning's Video-writeImageToFile.png index 08288a85..acded3e4 100644 Binary files a/tests/media/Burning's Video-writeImageToFile.png and b/tests/media/Burning's Video-writeImageToFile.png differ diff --git a/tests/tests-last-passed-at.txt b/tests/tests-last-passed-at.txt index 969e94a7..15f31461 100644 --- a/tests/tests-last-passed-at.txt +++ b/tests/tests-last-passed-at.txt @@ -1,4 +1,4 @@ Tests finished. 72 tests of 72 passed. -Compiled as RELEASE -Test suite pass at GMT Sun Oct 25 15:03:26 2020 +Compiled as DEBUG +Test suite pass at GMT Tue Dec 01 13:34:31 2020