aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender
diff options
context:
space:
mode:
authorJacek Antonelli2009-05-30 17:16:26 -0500
committerJacek Antonelli2009-05-30 19:12:37 -0500
commit499afbab7be4c4136eea0e1897319c3ac4e9799d (patch)
tree95e9de524994eae69b0dd88b8c6608d5f45d030c /linden/indra/llrender
parentFixed end-of-line style for Info-Imprudence.plist. (diff)
parentSecond Life viewer sources 1.22.11 (diff)
downloadmeta-impy-499afbab7be4c4136eea0e1897319c3ac4e9799d.zip
meta-impy-499afbab7be4c4136eea0e1897319c3ac4e9799d.tar.gz
meta-impy-499afbab7be4c4136eea0e1897319c3ac4e9799d.tar.bz2
meta-impy-499afbab7be4c4136eea0e1897319c3ac4e9799d.tar.xz
Merged SL 1.22.11 into Imprudence 1.1 RC2.
Conflicts: linden/doc/contributions.txt linden/indra/cmake/APR.cmake linden/indra/cmake/CopyWinLibs.cmake linden/indra/cmake/LLKDU.cmake (removed) linden/indra/cmake/LLMedia.cmake linden/indra/cmake/OPENAL.cmake linden/indra/cmake/QuickTime.cmake (removed) linden/indra/develop.py linden/indra/lib/python/indra/base/llsd.py linden/indra/lib/python/indra/util/fastest_elementtree.py linden/indra/lib/python/indra/util/llmanifest.py linden/indra/lib/python/indra/util/named_query.py linden/indra/llaudio/CMakeLists.txt linden/indra/llaudio/audioengine.cpp linden/indra/llaudio/audioengine.h linden/indra/llaudio/audioengine_fmod.cpp linden/indra/llaudio/audioengine_fmod.h linden/indra/llaudio/audioengine_openal.cpp linden/indra/llaudio/audioengine_openal.h linden/indra/llaudio/listener_openal.cpp linden/indra/llaudio/listener_openal.h linden/indra/llaudio/windgen.h linden/indra/llcrashlogger/llcrashlogger.cpp linden/indra/llmedia/llmediaimplgstreamer.cpp linden/indra/llmedia/llmediaimplgstreamer_syms.cpp (removed) linden/indra/llmedia/llmediaimplgstreamer_syms.h (removed) linden/indra/llmessage/llcircuit.h linden/indra/llrender/llgl.cpp linden/indra/llrender/llrender.h linden/indra/llui/llfloater.cpp linden/indra/llui/lltexteditor.cpp linden/indra/llwindow/llwindowsdl.cpp linden/indra/mac_crash_logger/CMakeLists.txt linden/indra/mac_updater/CMakeLists.txt linden/indra/newview/CMakeLists.txt linden/indra/newview/English.lproj/InfoPlist.strings linden/indra/newview/Info-Imprudence.plist linden/indra/newview/installers/windows/installer_template.nsi linden/indra/newview/installers/windows/lang_de.nsi linden/indra/newview/installers/windows/lang_en-us.nsi linden/indra/newview/installers/windows/lang_ja.nsi linden/indra/newview/installers/windows/lang_ko.nsi linden/indra/newview/llappviewer.cpp linden/indra/newview/llaudiosourcevo.cpp linden/indra/newview/llfloaterabout.cpp linden/indra/newview/llfloaterhtml.cpp linden/indra/newview/llfloaterhtml.h linden/indra/newview/llfloaterinspect.cpp linden/indra/newview/llfloatersnapshot.cpp linden/indra/newview/llpanelgeneral.cpp linden/indra/newview/llpanelgeneral.h linden/indra/newview/llpanellogin.cpp linden/indra/newview/llpanelobject.cpp linden/indra/newview/llurlhistory.cpp linden/indra/newview/llviewermenu.cpp linden/indra/newview/llviewernetwork.cpp linden/indra/newview/llviewernetwork.h linden/indra/newview/llviewerobject.cpp linden/indra/newview/llviewerwindow.cpp linden/indra/newview/llvoavatar.cpp linden/indra/newview/res/viewerRes.rc linden/indra/newview/skins/default/xui/de/floater_env_settings.xml linden/indra/newview/skins/default/xui/de/floater_html.xml linden/indra/newview/skins/default/xui/de/floater_inspect.xml linden/indra/newview/skins/default/xui/de/floater_instant_message_group.xml linden/indra/newview/skins/default/xui/de/floater_lagmeter.xml linden/indra/newview/skins/default/xui/de/floater_lsl_guide.xml linden/indra/newview/skins/default/xui/de/floater_url_entry.xml linden/indra/newview/skins/default/xui/de/floater_water.xml linden/indra/newview/skins/default/xui/de/mime_types.xml linden/indra/newview/skins/default/xui/de/need_to_long.xml linden/indra/newview/skins/default/xui/de/need_to_translate.xml linden/indra/newview/skins/default/xui/de/need_to_update.xml linden/indra/newview/skins/default/xui/de/panel_friends.xml linden/indra/newview/skins/default/xui/de/panel_media_remote_expanded.xml linden/indra/newview/skins/default/xui/de/panel_preferences_voice.xml linden/indra/newview/skins/default/xui/de/panel_voice_controls.xml linden/indra/newview/skins/default/xui/de/panel_voice_enable.xml linden/indra/newview/skins/default/xui/de/panel_voice_options.xml linden/indra/newview/skins/default/xui/de/strings.xml linden/indra/newview/skins/default/xui/en-us/floater_chat_history.xml linden/indra/newview/skins/default/xui/en-us/floater_instant_message_ad_hoc.xml linden/indra/newview/skins/default/xui/en-us/floater_instant_message_group.xml linden/indra/newview/skins/default/xui/en-us/floater_lagmeter.xml linden/indra/newview/skins/default/xui/en-us/menu_pie_object.xml linden/indra/newview/skins/default/xui/en-us/menu_viewer.xml linden/indra/newview/skins/default/xui/en-us/panel_audio_device.xml linden/indra/newview/skins/default/xui/en-us/panel_preferences_general.xml linden/indra/newview/skins/default/xui/en-us/panel_preferences_input.xml linden/indra/newview/skins/default/xui/en-us/panel_preferences_voice.xml linden/indra/newview/skins/default/xui/en-us/panel_voice_remote.xml linden/indra/newview/skins/default/xui/en-us/panel_voice_remote_expanded.xml linden/indra/newview/skins/default/xui/es/alerts.xml linden/indra/newview/skins/default/xui/es/floater_about_land.xml linden/indra/newview/skins/default/xui/es/floater_mute.xml linden/indra/newview/skins/default/xui/es/menu_viewer.xml linden/indra/newview/skins/default/xui/es/panel_group_land_money.xml linden/indra/newview/skins/default/xui/es/panel_preferences_general.xml linden/indra/newview/skins/default/xui/fr/alerts.xml linden/indra/newview/skins/default/xui/fr/floater_about.xml linden/indra/newview/skins/default/xui/fr/floater_about_land.xml linden/indra/newview/skins/default/xui/fr/floater_active_speakers.xml linden/indra/newview/skins/default/xui/fr/floater_animation_preview.xml linden/indra/newview/skins/default/xui/fr/floater_avatar_picker.xml linden/indra/newview/skins/default/xui/fr/floater_avatar_textures.xml linden/indra/newview/skins/default/xui/fr/floater_buy_contents.xml linden/indra/newview/skins/default/xui/fr/floater_buy_currency.xml linden/indra/newview/skins/default/xui/fr/floater_buy_land.xml linden/indra/newview/skins/default/xui/fr/floater_buy_object.xml linden/indra/newview/skins/default/xui/fr/floater_chat_history.xml linden/indra/newview/skins/default/xui/fr/floater_color_picker.xml linden/indra/newview/skins/default/xui/fr/floater_customize.xml linden/indra/newview/skins/default/xui/fr/floater_directory.xml linden/indra/newview/skins/default/xui/fr/floater_env_settings.xml linden/indra/newview/skins/default/xui/fr/floater_god_tools.xml linden/indra/newview/skins/default/xui/fr/floater_group_info.xml linden/indra/newview/skins/default/xui/fr/floater_hardware_settings.xml linden/indra/newview/skins/default/xui/fr/floater_html.xml linden/indra/newview/skins/default/xui/fr/floater_image_preview.xml linden/indra/newview/skins/default/xui/fr/floater_import.xml linden/indra/newview/skins/default/xui/fr/floater_instant_message.xml linden/indra/newview/skins/default/xui/fr/floater_instant_message_ad_hoc.xml linden/indra/newview/skins/default/xui/fr/floater_instant_message_group.xml linden/indra/newview/skins/default/xui/fr/floater_inventory.xml linden/indra/newview/skins/default/xui/fr/floater_inventory_item_properties.xml linden/indra/newview/skins/default/xui/fr/floater_inventory_view_finder.xml linden/indra/newview/skins/default/xui/fr/floater_joystick.xml linden/indra/newview/skins/default/xui/fr/floater_lagmeter.xml linden/indra/newview/skins/default/xui/fr/floater_land_holdings.xml linden/indra/newview/skins/default/xui/fr/floater_lsl_guide.xml linden/indra/newview/skins/default/xui/fr/floater_media_browser.xml linden/indra/newview/skins/default/xui/fr/floater_moveview.xml linden/indra/newview/skins/default/xui/fr/floater_mute.xml linden/indra/newview/skins/default/xui/fr/floater_mute_object.xml linden/indra/newview/skins/default/xui/fr/floater_name_description.xml linden/indra/newview/skins/default/xui/fr/floater_new_outfit_dialog.xml linden/indra/newview/skins/default/xui/fr/floater_openobject.xml linden/indra/newview/skins/default/xui/fr/floater_pay.xml linden/indra/newview/skins/default/xui/fr/floater_pay_object.xml linden/indra/newview/skins/default/xui/fr/floater_preferences.xml linden/indra/newview/skins/default/xui/fr/floater_preview_animation.xml linden/indra/newview/skins/default/xui/fr/floater_preview_gesture.xml linden/indra/newview/skins/default/xui/fr/floater_preview_notecard.xml linden/indra/newview/skins/default/xui/fr/floater_preview_notecard_keep_discard.xml linden/indra/newview/skins/default/xui/fr/floater_preview_sound.xml linden/indra/newview/skins/default/xui/fr/floater_price_for_listing.xml linden/indra/newview/skins/default/xui/fr/floater_region_info.xml linden/indra/newview/skins/default/xui/fr/floater_report_abuse.xml linden/indra/newview/skins/default/xui/fr/floater_report_bug.xml linden/indra/newview/skins/default/xui/fr/floater_script_ed_panel.xml linden/indra/newview/skins/default/xui/fr/floater_sell_land.xml linden/indra/newview/skins/default/xui/fr/floater_settings_debug.xml linden/indra/newview/skins/default/xui/fr/floater_skin_preview_template.xml linden/indra/newview/skins/default/xui/fr/floater_snapshot.xml linden/indra/newview/skins/default/xui/fr/floater_sound_preview.xml linden/indra/newview/skins/default/xui/fr/floater_telehub.xml linden/indra/newview/skins/default/xui/fr/floater_texture_ctrl.xml linden/indra/newview/skins/default/xui/fr/floater_tools.xml linden/indra/newview/skins/default/xui/fr/floater_top_objects.xml linden/indra/newview/skins/default/xui/fr/floater_url_entry.xml linden/indra/newview/skins/default/xui/fr/floater_windlight_options.xml linden/indra/newview/skins/default/xui/fr/floater_world_map.xml linden/indra/newview/skins/default/xui/fr/menu_inventory.xml linden/indra/newview/skins/default/xui/fr/menu_pie_avatar.xml linden/indra/newview/skins/default/xui/fr/menu_pie_land.xml linden/indra/newview/skins/default/xui/fr/menu_pie_self.xml linden/indra/newview/skins/default/xui/fr/menu_viewer.xml linden/indra/newview/skins/default/xui/fr/mime_types.xml linden/indra/newview/skins/default/xui/fr/notify.xml linden/indra/newview/skins/default/xui/fr/panel_audio.xml linden/indra/newview/skins/default/xui/fr/panel_audio_device.xml linden/indra/newview/skins/default/xui/fr/panel_avatar.xml linden/indra/newview/skins/default/xui/fr/panel_avatar_classified.xml linden/indra/newview/skins/default/xui/fr/panel_chat_bar.xml linden/indra/newview/skins/default/xui/fr/panel_classified.xml linden/indra/newview/skins/default/xui/fr/panel_event.xml linden/indra/newview/skins/default/xui/fr/panel_friends.xml linden/indra/newview/skins/default/xui/fr/panel_group.xml linden/indra/newview/skins/default/xui/fr/panel_group_finder.xml linden/indra/newview/skins/default/xui/fr/panel_group_general.xml linden/indra/newview/skins/default/xui/fr/panel_group_invite.xml linden/indra/newview/skins/default/xui/fr/panel_group_land_money.xml linden/indra/newview/skins/default/xui/fr/panel_group_notices.xml linden/indra/newview/skins/default/xui/fr/panel_group_roles.xml linden/indra/newview/skins/default/xui/fr/panel_group_voting.xml linden/indra/newview/skins/default/xui/fr/panel_groups.xml linden/indra/newview/skins/default/xui/fr/panel_login.xml linden/indra/newview/skins/default/xui/fr/panel_master_volume.xml linden/indra/newview/skins/default/xui/fr/panel_media_controls.xml linden/indra/newview/skins/default/xui/fr/panel_media_remote.xml linden/indra/newview/skins/default/xui/fr/panel_media_remote_expanded.xml linden/indra/newview/skins/default/xui/fr/panel_overlaybar.xml linden/indra/newview/skins/default/xui/fr/panel_place.xml linden/indra/newview/skins/default/xui/fr/panel_place_small.xml linden/indra/newview/skins/default/xui/fr/panel_preferences_audio.xml linden/indra/newview/skins/default/xui/fr/panel_preferences_chat.xml linden/indra/newview/skins/default/xui/fr/panel_preferences_general.xml linden/indra/newview/skins/default/xui/fr/panel_preferences_graphics1.xml linden/indra/newview/skins/default/xui/fr/panel_preferences_im.xml linden/indra/newview/skins/default/xui/fr/panel_preferences_input.xml linden/indra/newview/skins/default/xui/fr/panel_preferences_network.xml linden/indra/newview/skins/default/xui/fr/panel_preferences_popups.xml linden/indra/newview/skins/default/xui/fr/panel_preferences_voice.xml linden/indra/newview/skins/default/xui/fr/panel_preferences_web.xml linden/indra/newview/skins/default/xui/fr/panel_region_covenant.xml linden/indra/newview/skins/default/xui/fr/panel_region_debug.xml linden/indra/newview/skins/default/xui/fr/panel_region_estate.xml linden/indra/newview/skins/default/xui/fr/panel_region_general.xml linden/indra/newview/skins/default/xui/fr/panel_region_terrain.xml linden/indra/newview/skins/default/xui/fr/panel_scrolling_param.xml linden/indra/newview/skins/default/xui/fr/panel_speaker_controls.xml linden/indra/newview/skins/default/xui/fr/panel_status_bar.xml linden/indra/newview/skins/default/xui/fr/panel_toolbar.xml linden/indra/newview/skins/default/xui/fr/panel_voice_controls.xml linden/indra/newview/skins/default/xui/fr/panel_voice_enable.xml linden/indra/newview/skins/default/xui/fr/panel_voice_options.xml linden/indra/newview/skins/default/xui/fr/panel_voice_remote_expanded.xml linden/indra/newview/skins/default/xui/fr/role_actions.xml linden/indra/newview/skins/default/xui/fr/strings.xml linden/indra/newview/skins/default/xui/ja/floater_hardware_settings.xml linden/indra/newview/skins/default/xui/ja/floater_inspect.xml linden/indra/newview/skins/default/xui/ja/floater_instant_message_group.xml linden/indra/newview/skins/default/xui/ja/floater_lsl_guide.xml linden/indra/newview/skins/default/xui/ja/floater_media_browser.xml linden/indra/newview/skins/default/xui/ja/floater_mute_object.xml linden/indra/newview/skins/default/xui/ja/floater_url_entry.xml linden/indra/newview/skins/default/xui/ja/need_to_long.xml linden/indra/newview/skins/default/xui/ja/need_to_translate.xml linden/indra/newview/skins/default/xui/ja/need_to_update.xml linden/indra/newview/skins/default/xui/ja/panel_audio.xml linden/indra/newview/skins/default/xui/ja/panel_groups.xml linden/indra/newview/skins/default/xui/ja/panel_preferences_voice.xml linden/indra/newview/skins/default/xui/ja/panel_preferences_web.xml linden/indra/newview/skins/default/xui/ja/strings.xml linden/indra/newview/skins/default/xui/ko/need_to_long.xml linden/indra/newview/skins/default/xui/ko/need_to_translate.xml linden/indra/newview/skins/default/xui/ko/need_to_update.xml linden/indra/newview/skins/default/xui/pt/alerts.xml linden/indra/newview/skins/default/xui/pt/floater_about.xml linden/indra/newview/skins/default/xui/pt/floater_about_land.xml linden/indra/newview/skins/default/xui/pt/floater_animation_preview.xml linden/indra/newview/skins/default/xui/pt/floater_avatar_picker.xml linden/indra/newview/skins/default/xui/pt/floater_avatar_textures.xml linden/indra/newview/skins/default/xui/pt/floater_build_options.xml linden/indra/newview/skins/default/xui/pt/floater_buy_contents.xml linden/indra/newview/skins/default/xui/pt/floater_buy_currency.xml linden/indra/newview/skins/default/xui/pt/floater_buy_land.xml linden/indra/newview/skins/default/xui/pt/floater_buy_object.xml linden/indra/newview/skins/default/xui/pt/floater_chat_history.xml linden/indra/newview/skins/default/xui/pt/floater_color_picker.xml linden/indra/newview/skins/default/xui/pt/floater_customize.xml linden/indra/newview/skins/default/xui/pt/floater_directory.xml linden/indra/newview/skins/default/xui/pt/floater_gesture.xml linden/indra/newview/skins/default/xui/pt/floater_html.xml linden/indra/newview/skins/default/xui/pt/floater_im.xml linden/indra/newview/skins/default/xui/pt/floater_image_preview.xml linden/indra/newview/skins/default/xui/pt/floater_instant_message.xml linden/indra/newview/skins/default/xui/pt/floater_instant_message_ad_hoc.xml linden/indra/newview/skins/default/xui/pt/floater_inventory.xml linden/indra/newview/skins/default/xui/pt/floater_inventory_item_properties.xml linden/indra/newview/skins/default/xui/pt/floater_joystick.xml linden/indra/newview/skins/default/xui/pt/floater_land_holdings.xml linden/indra/newview/skins/default/xui/pt/floater_live_lsleditor.xml linden/indra/newview/skins/default/xui/pt/floater_mute.xml linden/indra/newview/skins/default/xui/pt/floater_new_outfit_dialog.xml linden/indra/newview/skins/default/xui/pt/floater_openobject.xml linden/indra/newview/skins/default/xui/pt/floater_pay.xml linden/indra/newview/skins/default/xui/pt/floater_pay_object.xml linden/indra/newview/skins/default/xui/pt/floater_postcard.xml linden/indra/newview/skins/default/xui/pt/floater_preview_animation.xml linden/indra/newview/skins/default/xui/pt/floater_preview_gesture.xml linden/indra/newview/skins/default/xui/pt/floater_preview_notecard.xml linden/indra/newview/skins/default/xui/pt/floater_preview_notecard_keep_discard.xml linden/indra/newview/skins/default/xui/pt/floater_report_abuse.xml linden/indra/newview/skins/default/xui/pt/floater_report_bug.xml linden/indra/newview/skins/default/xui/pt/floater_script_debug.xml linden/indra/newview/skins/default/xui/pt/floater_script_ed_panel.xml linden/indra/newview/skins/default/xui/pt/floater_snapshot.xml linden/indra/newview/skins/default/xui/pt/floater_texture_ctrl.xml linden/indra/newview/skins/default/xui/pt/floater_tools.xml linden/indra/newview/skins/default/xui/pt/floater_top_objects.xml linden/indra/newview/skins/default/xui/pt/floater_tos.xml linden/indra/newview/skins/default/xui/pt/floater_world_map.xml linden/indra/newview/skins/default/xui/pt/menu_inventory.xml linden/indra/newview/skins/default/xui/pt/menu_pie_avatar.xml linden/indra/newview/skins/default/xui/pt/menu_viewer.xml linden/indra/newview/skins/default/xui/pt/notify.xml linden/indra/newview/skins/default/xui/pt/panel_avatar.xml linden/indra/newview/skins/default/xui/pt/panel_avatar_classified.xml linden/indra/newview/skins/default/xui/pt/panel_chat_bar.xml linden/indra/newview/skins/default/xui/pt/panel_classified.xml linden/indra/newview/skins/default/xui/pt/panel_event.xml linden/indra/newview/skins/default/xui/pt/panel_group_general.xml linden/indra/newview/skins/default/xui/pt/panel_group_invite.xml linden/indra/newview/skins/default/xui/pt/panel_group_land_money.xml linden/indra/newview/skins/default/xui/pt/panel_group_notices.xml linden/indra/newview/skins/default/xui/pt/panel_group_roles.xml linden/indra/newview/skins/default/xui/pt/panel_group_voting.xml linden/indra/newview/skins/default/xui/pt/panel_login.xml linden/indra/newview/skins/default/xui/pt/panel_overlaybar.xml linden/indra/newview/skins/default/xui/pt/panel_place.xml linden/indra/newview/skins/default/xui/pt/panel_place_small.xml linden/indra/newview/skins/default/xui/pt/panel_preferences_audio.xml linden/indra/newview/skins/default/xui/pt/panel_preferences_chat.xml linden/indra/newview/skins/default/xui/pt/panel_preferences_general.xml linden/indra/newview/skins/default/xui/pt/panel_preferences_graphics1.xml linden/indra/newview/skins/default/xui/pt/panel_preferences_im.xml linden/indra/newview/skins/default/xui/pt/panel_preferences_input.xml linden/indra/newview/skins/default/xui/pt/panel_preferences_network.xml linden/indra/newview/skins/default/xui/pt/panel_preferences_popups.xml linden/indra/newview/skins/default/xui/pt/panel_preferences_web.xml linden/indra/newview/skins/default/xui/pt/panel_region_covenant.xml linden/indra/newview/skins/default/xui/pt/panel_region_debug.xml linden/indra/newview/skins/default/xui/pt/panel_region_estate.xml linden/indra/newview/skins/default/xui/pt/panel_region_general.xml linden/indra/newview/skins/default/xui/pt/panel_status_bar.xml linden/indra/newview/skins/default/xui/pt/panel_toolbar.xml linden/indra/newview/skins/default/xui/pt/teleport_strings.xml linden/indra/newview/skins/default/xui/zh/floater_account_history.xml linden/indra/newview/skins/default/xui/zh/floater_god_tools.xml linden/indra/newview/skins/default/xui/zh/floater_html.xml linden/indra/newview/skins/default/xui/zh/floater_inspect.xml linden/indra/newview/skins/default/xui/zh/floater_inventory_view_finder.xml linden/indra/newview/skins/default/xui/zh/floater_preferences.xml linden/indra/newview/skins/default/xui/zh/floater_sell_land.xml linden/indra/newview/skins/default/xui/zh/floater_settings_debug.xml linden/indra/newview/skins/default/xui/zh/menu_pie_attachment.xml linden/indra/newview/skins/default/xui/zh/menu_pie_avatar.xml linden/indra/newview/skins/default/xui/zh/menu_pie_land.xml linden/indra/newview/skins/default/xui/zh/menu_pie_object.xml linden/indra/newview/skins/default/xui/zh/menu_pie_self.xml linden/indra/newview/skins/default/xui/zh/menu_viewer.xml linden/indra/newview/skins/default/xui/zh/need_to_translate.xml linden/indra/newview/skins/default/xui/zh/panel_account_details.xml linden/indra/newview/skins/default/xui/zh/panel_account_planning.xml linden/indra/newview/skins/default/xui/zh/panel_account_transactions.xml linden/indra/newview/skins/default/xui/zh/panel_avatar.xml linden/indra/newview/skins/default/xui/zh/panel_group.xml linden/indra/newview/skins/default/xui/zh/panel_group_finder.xml linden/indra/newview/skins/default/xui/zh/panel_group_general.xml linden/indra/newview/skins/default/xui/zh/panel_group_invite.xml linden/indra/newview/skins/default/xui/zh/panel_group_land_money.xml linden/indra/newview/skins/default/xui/zh/panel_group_notices.xml linden/indra/newview/skins/default/xui/zh/panel_group_roles.xml linden/indra/newview/skins/default/xui/zh/panel_group_voting.xml linden/indra/newview/skins/default/xui/zh/panel_preferences_audio.xml linden/indra/newview/skins/default/xui/zh/panel_preferences_chat.xml linden/indra/newview/skins/default/xui/zh/panel_preferences_im.xml linden/indra/newview/skins/default/xui/zh/panel_preferences_popups.xml linden/indra/newview/skins/default/xui/zh/panel_region_covenant.xml linden/indra/newview/skins/default/xui/zh/strings.xml linden/indra/newview/skins/default/xui/zh/strings_long.xml linden/indra/newview/skins/silver/xui/en-us/floater_about_land.xml linden/indra/newview/skins/silver/xui/en-us/panel_status_bar.xml linden/indra/newview/viewer_manifest.py linden/indra/win_updater/updater.cpp linden/install.xml
Diffstat (limited to '')
-rw-r--r--linden/indra/llrender/llcubemap.cpp56
-rw-r--r--linden/indra/llrender/llcubemap.h4
-rw-r--r--linden/indra/llrender/llfont.cpp33
-rw-r--r--linden/indra/llrender/llfont.h3
-rw-r--r--linden/indra/llrender/llfontgl.cpp22
-rw-r--r--linden/indra/llrender/llfontgl.h2
-rw-r--r--linden/indra/llrender/llgl.cpp66
-rw-r--r--linden/indra/llrender/llgl.h8
-rw-r--r--linden/indra/llrender/llgldbg.cpp2
-rw-r--r--linden/indra/llrender/llgldbg.h2
-rw-r--r--linden/indra/llrender/llglheaders.h2
-rw-r--r--linden/indra/llrender/llglimmediate.cpp2
-rw-r--r--linden/indra/llrender/llglimmediate.h6
-rw-r--r--linden/indra/llrender/llglslshader.cpp10
-rw-r--r--linden/indra/llrender/llglslshader.h7
-rw-r--r--linden/indra/llrender/llglstates.h24
-rw-r--r--linden/indra/llrender/llgltypes.h2
-rw-r--r--linden/indra/llrender/llimagegl.cpp394
-rw-r--r--linden/indra/llrender/llimagegl.h49
-rw-r--r--linden/indra/llrender/llpostprocess.cpp109
-rw-r--r--linden/indra/llrender/llpostprocess.h15
-rw-r--r--linden/indra/llrender/llrender.cpp362
-rw-r--r--linden/indra/llrender/llrender.h129
-rw-r--r--linden/indra/llrender/llrendersphere.cpp2
-rw-r--r--linden/indra/llrender/llrendersphere.h2
-rw-r--r--linden/indra/llrender/llrendertarget.cpp58
-rw-r--r--linden/indra/llrender/llrendertarget.h17
-rw-r--r--linden/indra/llrender/llshadermgr.cpp4
-rw-r--r--linden/indra/llrender/llshadermgr.h2
-rw-r--r--linden/indra/llrender/llvertexbuffer.cpp10
-rw-r--r--linden/indra/llrender/llvertexbuffer.h18
31 files changed, 885 insertions, 537 deletions
diff --git a/linden/indra/llrender/llcubemap.cpp b/linden/indra/llrender/llcubemap.cpp
index 563d616..60215f0 100644
--- a/linden/indra/llrender/llcubemap.cpp
+++ b/linden/indra/llrender/llcubemap.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2002&license=viewergpl$ 5 * $LicenseInfo:firstyear=2002&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2002-2008, Linden Research, Inc. 7 * Copyright (c) 2002-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -92,11 +92,11 @@ void LLCubeMap::initGL()
92 for (int i = 0; i < 6; i++) 92 for (int i = 0; i < 6; i++)
93 { 93 {
94 mImages[i] = new LLImageGL(64, 64, 4, (use_cube_mipmaps? TRUE : FALSE)); 94 mImages[i] = new LLImageGL(64, 64, 4, (use_cube_mipmaps? TRUE : FALSE));
95 mImages[i]->setTarget(mTargets[i], GL_TEXTURE_CUBE_MAP_ARB); 95 mImages[i]->setTarget(mTargets[i], LLTexUnit::TT_CUBE_MAP);
96 mRawImages[i] = new LLImageRaw(64, 64, 4); 96 mRawImages[i] = new LLImageRaw(64, 64, 4);
97 mImages[i]->createGLTexture(0, mRawImages[i], texname); 97 mImages[i]->createGLTexture(0, mRawImages[i], texname);
98 98
99 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, texname); 99 gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_CUBE_MAP, texname);
100 mImages[i]->setClampCubemap (TRUE, TRUE, TRUE); 100 mImages[i]->setClampCubemap (TRUE, TRUE, TRUE);
101 stop_glerror(); 101 stop_glerror();
102 } 102 }
@@ -180,26 +180,7 @@ GLuint LLCubeMap::getGLName()
180 180
181void LLCubeMap::bind() 181void LLCubeMap::bind()
182{ 182{
183 if (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) 183 gGL.getTexUnit(mTextureStage)->bind(this);
184 {
185 // We assume that if they have cube mapping, they have multitexturing.
186 if (mTextureStage > 0)
187 {
188 gGL.getTexUnit(mTextureStage)->activate();
189 }
190 glEnable(GL_TEXTURE_CUBE_MAP_ARB);
191 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mImages[0]->getTexName());
192
193 mImages[0]->setMipFilterNearest (FALSE, FALSE);
194 if (mTextureStage > 0)
195 {
196 gGL.getTexUnit(0)->activate();
197 }
198 }
199 else
200 {
201 llwarns << "Using cube map without extension!" << llendl
202 }
203} 184}
204 185
205void LLCubeMap::enable(S32 stage) 186void LLCubeMap::enable(S32 stage)
@@ -213,17 +194,7 @@ void LLCubeMap::enableTexture(S32 stage)
213 mTextureStage = stage; 194 mTextureStage = stage;
214 if (gGLManager.mHasCubeMap && stage >= 0 && LLCubeMap::sUseCubeMaps) 195 if (gGLManager.mHasCubeMap && stage >= 0 && LLCubeMap::sUseCubeMaps)
215 { 196 {
216 if (stage > 0) 197 gGL.getTexUnit(stage)->enable(LLTexUnit::TT_CUBE_MAP);
217 {
218 gGL.getTexUnit(stage)->activate();
219 }
220
221 glEnable(GL_TEXTURE_CUBE_MAP_ARB);
222
223 if (stage > 0)
224 {
225 gGL.getTexUnit(0)->activate();
226 }
227 } 198 }
228} 199}
229 200
@@ -262,15 +233,10 @@ void LLCubeMap::disableTexture(void)
262{ 233{
263 if (gGLManager.mHasCubeMap && mTextureStage >= 0 && LLCubeMap::sUseCubeMaps) 234 if (gGLManager.mHasCubeMap && mTextureStage >= 0 && LLCubeMap::sUseCubeMaps)
264 { 235 {
265 if (mTextureStage > 0) 236 gGL.getTexUnit(mTextureStage)->disable();
237 if (mTextureStage == 0)
266 { 238 {
267 gGL.getTexUnit(mTextureStage)->activate(); 239 gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
268 }
269 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0);
270 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
271 if (mTextureStage > 0)
272 {
273 gGL.getTexUnit(0)->activate();
274 } 240 }
275 } 241 }
276} 242}
@@ -297,6 +263,8 @@ void LLCubeMap::setMatrix(S32 stage)
297{ 263{
298 mMatrixStage = stage; 264 mMatrixStage = stage;
299 265
266 if (mMatrixStage < 0) return;
267
300 if (stage > 0) 268 if (stage > 0)
301 { 269 {
302 gGL.getTexUnit(stage)->activate(); 270 gGL.getTexUnit(stage)->activate();
@@ -324,6 +292,8 @@ void LLCubeMap::setMatrix(S32 stage)
324 292
325void LLCubeMap::restoreMatrix() 293void LLCubeMap::restoreMatrix()
326{ 294{
295 if (mMatrixStage < 0) return;
296
327 if (mMatrixStage > 0) 297 if (mMatrixStage > 0)
328 { 298 {
329 gGL.getTexUnit(mMatrixStage)->activate(); 299 gGL.getTexUnit(mMatrixStage)->activate();
@@ -340,7 +310,7 @@ void LLCubeMap::restoreMatrix()
340 310
341void LLCubeMap::setReflection (void) 311void LLCubeMap::setReflection (void)
342{ 312{
343 glBindTexture (GL_TEXTURE_CUBE_MAP_ARB, getGLName()); 313 gGL.getTexUnit(mTextureStage)->bindManual(LLTexUnit::TT_CUBE_MAP, getGLName());
344 mImages[0]->setMipFilterNearest (FALSE, FALSE); 314 mImages[0]->setMipFilterNearest (FALSE, FALSE);
345 mImages[0]->setClampCubemap (TRUE, TRUE); 315 mImages[0]->setClampCubemap (TRUE, TRUE);
346} 316}
diff --git a/linden/indra/llrender/llcubemap.h b/linden/indra/llrender/llcubemap.h
index 45bfa16..8c83e6e 100644
--- a/linden/indra/llrender/llcubemap.h
+++ b/linden/indra/llrender/llcubemap.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2002&license=viewergpl$ 5 * $LicenseInfo:firstyear=2002&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2002-2008, Linden Research, Inc. 7 * Copyright (c) 2002-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -53,6 +53,7 @@ public:
53 53
54 void enableTexture(S32 stage); 54 void enableTexture(S32 stage);
55 void enableTextureCoords(S32 stage); 55 void enableTextureCoords(S32 stage);
56 S32 getStage(void) { return mTextureStage; }
56 57
57 void disable(void); 58 void disable(void);
58 void disableTexture(void); 59 void disableTexture(void);
@@ -77,6 +78,7 @@ public:
77 static bool sUseCubeMaps; 78 static bool sUseCubeMaps;
78 79
79protected: 80protected:
81 friend class LLTexUnit;
80 ~LLCubeMap(); 82 ~LLCubeMap();
81 LLGLenum mTargets[6]; 83 LLGLenum mTargets[6];
82 LLPointer<LLImageGL> mImages[6]; 84 LLPointer<LLImageGL> mImages[6];
diff --git a/linden/indra/llrender/llfont.cpp b/linden/indra/llrender/llfont.cpp
index 4b5ee64..d7310bd 100644
--- a/linden/indra/llrender/llfont.cpp
+++ b/linden/indra/llrender/llfont.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2002&license=viewergpl$ 5 * $LicenseInfo:firstyear=2002&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2002-2008, Linden Research, Inc. 7 * Copyright (c) 2002-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -92,18 +92,18 @@ LLFontManager::~LLFontManager()
92 92
93 93
94LLFontGlyphInfo::LLFontGlyphInfo(U32 index) 94LLFontGlyphInfo::LLFontGlyphInfo(U32 index)
95{ 95: mGlyphIndex(index),
96 mGlyphIndex = index; 96 mXBitmapOffset(0), // Offset to the origin in the bitmap
97 mXBitmapOffset = 0; // Offset to the origin in the bitmap 97 mYBitmapOffset(0), // Offset to the origin in the bitmap
98 mYBitmapOffset = 0; // Offset to the origin in the bitmap 98 mXBearing(0), // Distance from baseline to left in pixels
99 mXBearing = 0; // Distance from baseline to left in pixels 99 mYBearing(0), // Distance from baseline to top in pixels
100 mYBearing = 0; // Distance from baseline to top in pixels 100 mWidth(0), // In pixels
101 mWidth = 0; // In pixels 101 mHeight(0), // In pixels
102 mHeight = 0; // In pixels 102 mXAdvance(0.f), // In pixels
103 mXAdvance = 0.f; // In pixels 103 mYAdvance(0.f), // In pixels
104 mYAdvance = 0.f; // In pixels 104 mIsRendered(FALSE),
105 mIsRendered = FALSE; 105 mMetricsValid(FALSE)
106} 106{}
107 107
108LLFontList::LLFontList() 108LLFontList::LLFontList()
109{ 109{
@@ -303,6 +303,9 @@ void LLFont::resetBitmap()
303 iter != mCharGlyphInfoMap.end(); ++iter) 303 iter != mCharGlyphInfoMap.end(); ++iter)
304 { 304 {
305 iter->second->mIsRendered = FALSE; 305 iter->second->mIsRendered = FALSE;
306 //FIXME: this is only strictly necessary when resetting the entire font,
307 //not just flushing the bitmap
308 iter->second->mMetricsValid = FALSE;
306 } 309 }
307 mRawImagep->clear(255, 0); 310 mRawImagep->clear(255, 0);
308 mCurrentOffsetX = 1; 311 mCurrentOffsetX = 1;
@@ -439,6 +442,7 @@ BOOL LLFont::addGlyphFromFont(LLFont *fontp, const llwchar wch, const U32 glyph_
439 gi->mXAdvance = fontp->mFTFace->glyph->advance.x / 64.f; 442 gi->mXAdvance = fontp->mFTFace->glyph->advance.x / 64.f;
440 gi->mYAdvance = fontp->mFTFace->glyph->advance.y / 64.f; 443 gi->mYAdvance = fontp->mFTFace->glyph->advance.y / 64.f;
441 gi->mIsRendered = TRUE; 444 gi->mIsRendered = TRUE;
445 gi->mMetricsValid = TRUE;
442 446
443 insertGlyphInfo(wch, gi); 447 insertGlyphInfo(wch, gi);
444 448
@@ -528,7 +532,7 @@ F32 LLFont::getXAdvance(const llwchar wch) const
528 532
529 // Return existing info only if it is current 533 // Return existing info only if it is current
530 LLFontGlyphInfo* gi = getGlyphInfo(wch); 534 LLFontGlyphInfo* gi = getGlyphInfo(wch);
531 if (gi && gi->mIsRendered) 535 if (gi && gi->mMetricsValid)
532 { 536 {
533 return gi->mXAdvance; 537 return gi->mXAdvance;
534 } 538 }
@@ -573,6 +577,7 @@ F32 LLFont::getXAdvance(const llwchar wch) const
573 // Convert these from 26.6 units to float pixels. 577 // Convert these from 26.6 units to float pixels.
574 gi->mXAdvance = fontp->mFTFace->glyph->advance.x / 64.f; 578 gi->mXAdvance = fontp->mFTFace->glyph->advance.x / 64.f;
575 gi->mYAdvance = fontp->mFTFace->glyph->advance.y / 64.f; 579 gi->mYAdvance = fontp->mFTFace->glyph->advance.y / 64.f;
580 gi->mMetricsValid = TRUE;
576 return gi->mXAdvance; 581 return gi->mXAdvance;
577 } 582 }
578 else 583 else
diff --git a/linden/indra/llrender/llfont.h b/linden/indra/llrender/llfont.h
index d937dfd..bce8d76 100644
--- a/linden/indra/llrender/llfont.h
+++ b/linden/indra/llrender/llfont.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2002&license=viewergpl$ 5 * $LicenseInfo:firstyear=2002&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2002-2008, Linden Research, Inc. 7 * Copyright (c) 2002-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -72,6 +72,7 @@ public:
72 S32 mHeight; // In pixels 72 S32 mHeight; // In pixels
73 F32 mXAdvance; // In pixels 73 F32 mXAdvance; // In pixels
74 F32 mYAdvance; // In pixels 74 F32 mYAdvance; // In pixels
75 BOOL mMetricsValid; // We have up-to-date metrics for this glyph
75 76
76 // Information for actually rendering 77 // Information for actually rendering
77 BOOL mIsRendered; // We actually have rendered this glyph 78 BOOL mIsRendered; // We actually have rendered this glyph
diff --git a/linden/indra/llrender/llfontgl.cpp b/linden/indra/llrender/llfontgl.cpp
index a328196..526f1a9 100644
--- a/linden/indra/llrender/llfontgl.cpp
+++ b/linden/indra/llrender/llfontgl.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -148,7 +148,7 @@ void LLFontGL::init()
148 { 148 {
149 mImageGLp = new LLImageGL(FALSE); 149 mImageGLp = new LLImageGL(FALSE);
150 //RN: use nearest mipmap filtering to obviate the need to do pixel-accurate positioning 150 //RN: use nearest mipmap filtering to obviate the need to do pixel-accurate positioning
151 mImageGLp->bind(); 151 gGL.getTexUnit(0)->bind(mImageGLp);
152 // we allow bilinear filtering to get sub-pixel positioning for drop shadows 152 // we allow bilinear filtering to get sub-pixel positioning for drop shadows
153 //mImageGLp->setMipFilterNearest(TRUE, TRUE); 153 //mImageGLp->setMipFilterNearest(TRUE, TRUE);
154 } 154 }
@@ -533,7 +533,7 @@ BOOL LLFontGL::loadFace(const std::string& filename,
533 return FALSE; 533 return FALSE;
534 } 534 }
535 mImageGLp->createGLTexture(0, mRawImageGLp); 535 mImageGLp->createGLTexture(0, mRawImageGLp);
536 mImageGLp->bind(); 536 gGL.getTexUnit(0)->bind(mImageGLp);
537 mImageGLp->setMipFilterNearest(TRUE, TRUE); 537 mImageGLp->setMipFilterNearest(TRUE, TRUE);
538 return TRUE; 538 return TRUE;
539} 539}
@@ -547,7 +547,7 @@ BOOL LLFontGL::addChar(const llwchar wch)
547 547
548 stop_glerror(); 548 stop_glerror();
549 mImageGLp->setSubImage(mRawImageGLp, 0, 0, mImageGLp->getWidth(), mImageGLp->getHeight()); 549 mImageGLp->setSubImage(mRawImageGLp, 0, 0, mImageGLp->getWidth(), mImageGLp->getHeight());
550 mImageGLp->bind(); 550 gGL.getTexUnit(0)->bind(mImageGLp);
551 mImageGLp->setMipFilterNearest(TRUE, TRUE); 551 mImageGLp->setMipFilterNearest(TRUE, TRUE);
552 stop_glerror(); 552 stop_glerror();
553 return TRUE; 553 return TRUE;
@@ -583,7 +583,7 @@ S32 LLFontGL::render(const LLWString &wstr,
583 return wstr.length() ; 583 return wstr.length() ;
584 } 584 }
585 585
586 LLGLEnable tex(GL_TEXTURE_2D); 586 gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
587 587
588 if (wstr.empty()) 588 if (wstr.empty())
589 { 589 {
@@ -663,7 +663,7 @@ S32 LLFontGL::render(const LLWString &wstr,
663 663
664 // Bind the font texture 664 // Bind the font texture
665 665
666 mImageGLp->bind(0); 666 gGL.getTexUnit(0)->bind(mImageGLp);
667 667
668 // Not guaranteed to be set correctly 668 // Not guaranteed to be set correctly
669 gGL.setSceneBlendType(LLRender::BT_ALPHA); 669 gGL.setSceneBlendType(LLRender::BT_ALPHA);
@@ -761,7 +761,7 @@ S32 LLFontGL::render(const LLWString &wstr,
761 break; 761 break;
762 } 762 }
763 763
764 ext_image->bind(); 764 gGL.getTexUnit(0)->bind(ext_image);
765 const F32 ext_x = cur_render_x + (EXT_X_BEARING * sScaleX); 765 const F32 ext_x = cur_render_x + (EXT_X_BEARING * sScaleX);
766 const F32 ext_y = cur_render_y + (EXT_Y_BEARING * sScaleY + mAscender - mLineHeight); 766 const F32 ext_y = cur_render_y + (EXT_Y_BEARING * sScaleY + mAscender - mLineHeight);
767 767
@@ -795,7 +795,7 @@ S32 LLFontGL::render(const LLWString &wstr,
795 cur_render_x = cur_x; 795 cur_render_x = cur_x;
796 796
797 // Bind the font texture 797 // Bind the font texture
798 mImageGLp->bind(); 798 gGL.getTexUnit(0)->bind(mImageGLp);
799 } 799 }
800 else 800 else
801 { 801 {
@@ -863,8 +863,8 @@ S32 LLFontGL::render(const LLWString &wstr,
863 863
864 if (style & UNDERLINE) 864 if (style & UNDERLINE)
865 { 865 {
866 LLGLSNoTexture no_texture; 866 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
867 gGL.begin(LLVertexBuffer::LINES); 867 gGL.begin(LLRender::LINES);
868 gGL.vertex2f(start_x, cur_y - (mDescender)); 868 gGL.vertex2f(start_x, cur_y - (mDescender));
869 gGL.vertex2f(cur_x, cur_y - (mDescender)); 869 gGL.vertex2f(cur_x, cur_y - (mDescender));
870 gGL.end(); 870 gGL.end();
@@ -1359,7 +1359,7 @@ void LLFontGL::drawGlyph(const LLRectf& screen_rect, const LLRectf& uv_rect, con
1359 F32 slant_offset; 1359 F32 slant_offset;
1360 slant_offset = ((style & ITALIC) ? ( -mAscender * 0.2f) : 0.f); 1360 slant_offset = ((style & ITALIC) ? ( -mAscender * 0.2f) : 0.f);
1361 1361
1362 gGL.begin(LLVertexBuffer::QUADS); 1362 gGL.begin(LLRender::QUADS);
1363 { 1363 {
1364 //FIXME: bold and drop shadow are mutually exclusive only for convenience 1364 //FIXME: bold and drop shadow are mutually exclusive only for convenience
1365 //Allow both when we need them. 1365 //Allow both when we need them.
diff --git a/linden/indra/llrender/llfontgl.h b/linden/indra/llrender/llfontgl.h
index 3f88e62..97bdd1a 100644
--- a/linden/indra/llrender/llfontgl.h
+++ b/linden/indra/llrender/llfontgl.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * $LicenseInfo:firstyear=2001&license=viewergpl$ 6 * $LicenseInfo:firstyear=2001&license=viewergpl$
7 * 7 *
8 * Copyright (c) 2001-2008, Linden Research, Inc. 8 * Copyright (c) 2001-2009, Linden Research, Inc.
9 * 9 *
10 * Second Life Viewer Source Code 10 * Second Life Viewer Source Code
11 * The source code in this file ("Source Code") is provided by Linden Lab 11 * The source code in this file ("Source Code") is provided by Linden Lab
diff --git a/linden/indra/llrender/llgl.cpp b/linden/indra/llrender/llgl.cpp
index 2cb7adc..a9cf073 100644
--- a/linden/indra/llrender/llgl.cpp
+++ b/linden/indra/llrender/llgl.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -263,7 +263,6 @@ LLGLManager::LLGLManager() :
263 mHasMultitexture(FALSE), 263 mHasMultitexture(FALSE),
264 mNumTextureUnits(1), 264 mNumTextureUnits(1),
265 mHasMipMapGeneration(FALSE), 265 mHasMipMapGeneration(FALSE),
266 mHasPalettedTextures(FALSE),
267 mHasCompressedTextures(FALSE), 266 mHasCompressedTextures(FALSE),
268 mHasFramebufferObject(FALSE), 267 mHasFramebufferObject(FALSE),
269 268
@@ -566,7 +565,6 @@ void LLGLManager::initExtensions()
566 mHasFramebufferObject = FALSE; 565 mHasFramebufferObject = FALSE;
567# endif 566# endif
568 mHasMipMapGeneration = FALSE; 567 mHasMipMapGeneration = FALSE;
569 mHasPalettedTextures = FALSE;
570 mHasSeparateSpecularColor = FALSE; 568 mHasSeparateSpecularColor = FALSE;
571 mHasAnisotropic = FALSE; 569 mHasAnisotropic = FALSE;
572 mHasCubeMap = FALSE; 570 mHasCubeMap = FALSE;
@@ -578,7 +576,6 @@ void LLGLManager::initExtensions()
578#else // LL_MESA_HEADLESS 576#else // LL_MESA_HEADLESS
579 mHasMultitexture = glh_init_extensions("GL_ARB_multitexture"); 577 mHasMultitexture = glh_init_extensions("GL_ARB_multitexture");
580 mHasMipMapGeneration = glh_init_extensions("GL_SGIS_generate_mipmap"); 578 mHasMipMapGeneration = glh_init_extensions("GL_SGIS_generate_mipmap");
581 mHasPalettedTextures = glh_init_extensions("GL_EXT_paletted_texture");
582 mHasSeparateSpecularColor = glh_init_extensions("GL_EXT_separate_specular_color"); 579 mHasSeparateSpecularColor = glh_init_extensions("GL_EXT_separate_specular_color");
583 mHasAnisotropic = glh_init_extensions("GL_EXT_texture_filter_anisotropic"); 580 mHasAnisotropic = glh_init_extensions("GL_EXT_texture_filter_anisotropic");
584 glh_init_extensions("GL_ARB_texture_cube_map"); 581 glh_init_extensions("GL_ARB_texture_cube_map");
@@ -610,7 +607,6 @@ void LLGLManager::initExtensions()
610 mHasVertexBufferObject = FALSE; 607 mHasVertexBufferObject = FALSE;
611 mHasFramebufferObject = FALSE; 608 mHasFramebufferObject = FALSE;
612 mHasMipMapGeneration = FALSE; 609 mHasMipMapGeneration = FALSE;
613 mHasPalettedTextures = FALSE;
614 mHasSeparateSpecularColor = FALSE; 610 mHasSeparateSpecularColor = FALSE;
615 mHasAnisotropic = FALSE; 611 mHasAnisotropic = FALSE;
616 mHasCubeMap = FALSE; 612 mHasCubeMap = FALSE;
@@ -628,7 +624,6 @@ void LLGLManager::initExtensions()
628 // bug reports. This should be the default until we get a 624 // bug reports. This should be the default until we get a
629 // proper blacklist/whitelist on Linux. 625 // proper blacklist/whitelist on Linux.
630 mHasMipMapGeneration = FALSE; 626 mHasMipMapGeneration = FALSE;
631 mHasPalettedTextures = FALSE;
632 mHasAnisotropic = FALSE; 627 mHasAnisotropic = FALSE;
633 //mHasCubeMap = FALSE; // apparently fatal on Intel 915 & similar 628 //mHasCubeMap = FALSE; // apparently fatal on Intel 915 & similar
634 //mHasOcclusionQuery = FALSE; // source of many ATI system hangs 629 //mHasOcclusionQuery = FALSE; // source of many ATI system hangs
@@ -648,7 +643,6 @@ void LLGLManager::initExtensions()
648 if (strchr(blacklist,'b')) mHasCompressedTextures = FALSE; 643 if (strchr(blacklist,'b')) mHasCompressedTextures = FALSE;
649 if (strchr(blacklist,'c')) mHasVertexBufferObject = FALSE; 644 if (strchr(blacklist,'c')) mHasVertexBufferObject = FALSE;
650 if (strchr(blacklist,'d')) mHasMipMapGeneration = FALSE;//S 645 if (strchr(blacklist,'d')) mHasMipMapGeneration = FALSE;//S
651 if (strchr(blacklist,'e')) mHasPalettedTextures = FALSE;//S
652// if (strchr(blacklist,'f')) mHasNVVertexArrayRange = FALSE;//S 646// if (strchr(blacklist,'f')) mHasNVVertexArrayRange = FALSE;//S
653// if (strchr(blacklist,'g')) mHasNVFence = FALSE;//S 647// if (strchr(blacklist,'g')) mHasNVFence = FALSE;//S
654 if (strchr(blacklist,'h')) mHasSeparateSpecularColor = FALSE; 648 if (strchr(blacklist,'h')) mHasSeparateSpecularColor = FALSE;
@@ -663,13 +657,6 @@ void LLGLManager::initExtensions()
663 if (strchr(blacklist,'q')) mHasFramebufferObject = FALSE;//S 657 if (strchr(blacklist,'q')) mHasFramebufferObject = FALSE;//S
664 } 658 }
665#endif // LL_LINUX 659#endif // LL_LINUX
666
667#if LL_DARWIN || LL_LINUX
668 // MBW -- 12/4/2003 -- Using paletted textures causes a bunch of avatar rendering problems on the Mac.
669 // Not sure if this is due to driver problems or incorrect use of the extension, but I'm disabling it for now.
670 // Tofu - 2006-10-03 -- Same problem on Linux.
671 mHasPalettedTextures = false;
672#endif
673 660
674 if (!mHasMultitexture) 661 if (!mHasMultitexture)
675 { 662 {
@@ -683,10 +670,6 @@ void LLGLManager::initExtensions()
683 { 670 {
684 LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_texture_env_combine" << LL_ENDL; 671 LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_texture_env_combine" << LL_ENDL;
685 } 672 }
686 if (!mHasPalettedTextures)
687 {
688 LL_INFOS("RenderInit") << "Couldn't initialize GL_EXT_paletted_texture" << LL_ENDL;
689 }
690 if (!mHasSeparateSpecularColor) 673 if (!mHasSeparateSpecularColor)
691 { 674 {
692 LL_INFOS("RenderInit") << "Couldn't initialize separate specular color" << LL_ENDL; 675 LL_INFOS("RenderInit") << "Couldn't initialize separate specular color" << LL_ENDL;
@@ -788,13 +771,7 @@ void LLGLManager::initExtensions()
788 mGLMaxIndexRange = 0; 771 mGLMaxIndexRange = 0;
789 } 772 }
790#endif // !LL_LINUX 773#endif // !LL_LINUX
791#if LL_LINUX 774
792 // On Linux we need to get glColorTableEXT dynamically.
793 if (mHasPalettedTextures)
794 {
795 glColorTableEXT = (PFNGLCOLORTABLEEXTPROC)GLH_EXT_GET_PROC_ADDRESS("glColorTableEXT");
796 }
797#endif // LL_LINUX
798 if (mHasOcclusionQuery) 775 if (mHasOcclusionQuery)
799 { 776 {
800 glGenQueriesARB = (PFNGLGENQUERIESARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGenQueriesARB"); 777 glGenQueriesARB = (PFNGLGENQUERIESARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGenQueriesARB");
@@ -960,7 +937,8 @@ void assert_glerror()
960 GLubyte const * gl_error_msg = gluErrorString(error); 937 GLubyte const * gl_error_msg = gluErrorString(error);
961 if (NULL != gl_error_msg) 938 if (NULL != gl_error_msg)
962 { 939 {
963 LL_WARNS("RenderState") << "GL Error:" << gl_error_msg << LL_ENDL; 940 LL_WARNS("RenderState") << "GL Error:" << error<< LL_ENDL;
941 LL_WARNS("RenderState") << "GL Error String:" << gl_error_msg << LL_ENDL;
964 } 942 }
965 else 943 else
966 { 944 {
@@ -1001,7 +979,7 @@ GLboolean LLGLDepthTest::sWriteEnabled = GL_TRUE; // OpenGL default
1001void LLGLState::initClass() 979void LLGLState::initClass()
1002{ 980{
1003 sStateMap[GL_DITHER] = GL_TRUE; 981 sStateMap[GL_DITHER] = GL_TRUE;
1004 sStateMap[GL_TEXTURE_2D] = GL_TRUE; 982 // sStateMap[GL_TEXTURE_2D] = GL_TRUE;
1005 983
1006 //make sure multisample defaults to disabled 984 //make sure multisample defaults to disabled
1007 sStateMap[GL_MULTISAMPLE_ARB] = GL_FALSE; 985 sStateMap[GL_MULTISAMPLE_ARB] = GL_FALSE;
@@ -1030,7 +1008,7 @@ void LLGLState::resetTextureStates()
1030 { 1008 {
1031 gGL.getTexUnit(j)->activate(); 1009 gGL.getTexUnit(j)->activate();
1032 glClientActiveTextureARB(GL_TEXTURE0_ARB+j); 1010 glClientActiveTextureARB(GL_TEXTURE0_ARB+j);
1033 j == 0 ? glEnable(GL_TEXTURE_2D) : glDisable(GL_TEXTURE_2D); 1011 j == 0 ? gGL.getTexUnit(j)->enable(LLTexUnit::TT_TEXTURE) : gGL.getTexUnit(j)->disable();
1034 } 1012 }
1035} 1013}
1036 1014
@@ -1053,14 +1031,6 @@ void LLGLState::checkStates(const std::string& msg)
1053 1031
1054 stop_glerror(); 1032 stop_glerror();
1055 1033
1056 GLint activeTexture;
1057 glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &activeTexture);
1058
1059 if (activeTexture != GL_TEXTURE0_ARB)
1060 {
1061 LL_GL_ERRS << "Texture channel corrupted. " << LL_ENDL;
1062 }
1063
1064 GLint src; 1034 GLint src;
1065 GLint dst; 1035 GLint dst;
1066 glGetIntegerv(GL_BLEND_SRC, &src); 1036 glGetIntegerv(GL_BLEND_SRC, &src);
@@ -1099,17 +1069,7 @@ void LLGLState::checkTextureChannels(const std::string& msg)
1099 1069
1100 BOOL error = FALSE; 1070 BOOL error = FALSE;
1101 1071
1102 if (activeTexture != GL_TEXTURE0_ARB) 1072 if (activeTexture == GL_TEXTURE0_ARB)
1103 {
1104 error = TRUE;
1105 LL_WARNS("RenderState") << "Active texture channel corrupted. " << LL_ENDL;
1106 }
1107 else if (!glIsEnabled(GL_TEXTURE_2D))
1108 {
1109 error = TRUE;
1110 LL_WARNS("RenderState") << "GL_TEXTURE_2D not enabled on texture channel 0." << LL_ENDL;
1111 }
1112 else
1113 { 1073 {
1114 GLint tex_env_mode = 0; 1074 GLint tex_env_mode = 0;
1115 1075
@@ -1152,7 +1112,7 @@ void LLGLState::checkTextureChannels(const std::string& msg)
1152 LLMatrix4 identity; 1112 LLMatrix4 identity;
1153 LLMatrix4 matrix; 1113 LLMatrix4 matrix;
1154 1114
1155 for (GLint i = 0; i < maxTextureUnits; i++) 1115 for (GLint i = 1; i < maxTextureUnits; i++)
1156 { 1116 {
1157 gGL.getTexUnit(i)->activate(); 1117 gGL.getTexUnit(i)->activate();
1158 glClientActiveTextureARB(GL_TEXTURE0_ARB+i); 1118 glClientActiveTextureARB(GL_TEXTURE0_ARB+i);
@@ -1459,16 +1419,6 @@ void set_binormals(const S32 index, const U32 stride,const LLVector3 *binormals)
1459#endif 1419#endif
1460} 1420}
1461 1421
1462
1463void set_palette(U8 *palette_data)
1464{
1465 if (gGLManager.mHasPalettedTextures)
1466 {
1467 glColorTableEXT(GL_TEXTURE_2D, GL_RGBA8, 256, GL_RGBA, GL_UNSIGNED_BYTE, palette_data);
1468 }
1469}
1470
1471
1472void parse_gl_version( S32* major, S32* minor, S32* release, std::string* vendor_specific ) 1422void parse_gl_version( S32* major, S32* minor, S32* release, std::string* vendor_specific )
1473{ 1423{
1474 // GL_VERSION returns a null-terminated string with the format: 1424 // GL_VERSION returns a null-terminated string with the format:
diff --git a/linden/indra/llrender/llgl.h b/linden/indra/llrender/llgl.h
index cb368d7..011fd63 100644
--- a/linden/indra/llrender/llgl.h
+++ b/linden/indra/llrender/llgl.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -74,7 +74,6 @@ public:
74 BOOL mHasMultitexture; 74 BOOL mHasMultitexture;
75 S32 mNumTextureUnits; 75 S32 mNumTextureUnits;
76 BOOL mHasMipMapGeneration; 76 BOOL mHasMipMapGeneration;
77 BOOL mHasPalettedTextures;
78 BOOL mHasCompressedTextures; 77 BOOL mHasCompressedTextures;
79 BOOL mHasFramebufferObject; 78 BOOL mHasFramebufferObject;
80 79
@@ -318,11 +317,11 @@ public:
318class LLGLNamePool 317class LLGLNamePool
319{ 318{
320public: 319public:
321 typedef struct 320 struct NameEntry
322 { 321 {
323 GLuint name; 322 GLuint name;
324 BOOL used; 323 BOOL used;
325 } NameEntry; 324 };
326 325
327 struct CompareUsed 326 struct CompareUsed
328 { 327 {
@@ -370,7 +369,6 @@ void disable_cloth_weights(const S32 index);
370void set_vertex_weights(const S32 index, const U32 stride, const F32 *weights); 369void set_vertex_weights(const S32 index, const U32 stride, const F32 *weights);
371void set_vertex_clothing_weights(const S32 index, const U32 stride, const LLVector4 *weights); 370void set_vertex_clothing_weights(const S32 index, const U32 stride, const LLVector4 *weights);
372void set_binormals(const S32 index, const U32 stride, const LLVector3 *binormals); 371void set_binormals(const S32 index, const U32 stride, const LLVector3 *binormals);
373void set_palette(U8* palette_data);
374void parse_gl_version( S32* major, S32* minor, S32* release, std::string* vendor_specific ); 372void parse_gl_version( S32* major, S32* minor, S32* release, std::string* vendor_specific );
375 373
376extern BOOL gClothRipple; 374extern BOOL gClothRipple;
diff --git a/linden/indra/llrender/llgldbg.cpp b/linden/indra/llrender/llgldbg.cpp
index 526215b..27b45a9 100644
--- a/linden/indra/llrender/llgldbg.cpp
+++ b/linden/indra/llrender/llgldbg.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
diff --git a/linden/indra/llrender/llgldbg.h b/linden/indra/llrender/llgldbg.h
index 0e1c986..73ab7fc 100644
--- a/linden/indra/llrender/llgldbg.h
+++ b/linden/indra/llrender/llgldbg.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
diff --git a/linden/indra/llrender/llglheaders.h b/linden/indra/llrender/llglheaders.h
index f047262..20a420b 100644
--- a/linden/indra/llrender/llglheaders.h
+++ b/linden/indra/llrender/llglheaders.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
diff --git a/linden/indra/llrender/llglimmediate.cpp b/linden/indra/llrender/llglimmediate.cpp
index 9b60e49..bade1aa 100644
--- a/linden/indra/llrender/llglimmediate.cpp
+++ b/linden/indra/llrender/llglimmediate.cpp
@@ -7,7 +7,7 @@
7 * 7 *
8 * $LicenseInfo:firstyear=2001&license=viewergpl$ 8 * $LicenseInfo:firstyear=2001&license=viewergpl$
9 * 9 *
10 * Copyright (c) 2001-2008, Linden Research, Inc. 10 * Copyright (c) 2001-2009, Linden Research, Inc.
11 * 11 *
12 * Second Life Viewer Source Code 12 * Second Life Viewer Source Code
13 * The source code in this file ("Source Code") is provided by Linden Lab 13 * The source code in this file ("Source Code") is provided by Linden Lab
diff --git a/linden/indra/llrender/llglimmediate.h b/linden/indra/llrender/llglimmediate.h
index 2d7d768..690abe0 100644
--- a/linden/indra/llrender/llglimmediate.h
+++ b/linden/indra/llrender/llglimmediate.h
@@ -12,7 +12,7 @@
12 * 12 *
13 * $LicenseInfo:firstyear=2001&license=viewergpl$ 13 * $LicenseInfo:firstyear=2001&license=viewergpl$
14 * 14 *
15 * Copyright (c) 2001-2008, Linden Research, Inc. 15 * Copyright (c) 2001-2009, Linden Research, Inc.
16 * 16 *
17 * Second Life Viewer Source Code 17 * Second Life Viewer Source Code
18 * The source code in this file ("Source Code") is provided by Linden Lab 18 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -76,12 +76,12 @@ public:
76 void color3fv(const GLfloat* c); 76 void color3fv(const GLfloat* c);
77 void color4ubv(const GLubyte* c); 77 void color4ubv(const GLubyte* c);
78 78
79 typedef struct Vertex 79 typedef struct
80 { 80 {
81 GLfloat v[3]; 81 GLfloat v[3];
82 GLubyte c[4]; 82 GLubyte c[4];
83 GLfloat uv[2]; 83 GLfloat uv[2];
84 }; 84 } Vertex;
85 85
86private: 86private:
87 U32 mCount; 87 U32 mCount;
diff --git a/linden/indra/llrender/llglslshader.cpp b/linden/indra/llrender/llglslshader.cpp
index 26984e1..6683916 100644
--- a/linden/indra/llrender/llglslshader.cpp
+++ b/linden/indra/llrender/llglslshader.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2005&license=viewergpl$ 5 * $LicenseInfo:firstyear=2005&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2005-2008, Linden Research, Inc. 7 * Copyright (c) 2005-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -365,7 +365,7 @@ void LLGLSLShader::bindNoShader(void)
365 glUseProgramObjectARB(0); 365 glUseProgramObjectARB(0);
366} 366}
367 367
368S32 LLGLSLShader::enableTexture(S32 uniform, S32 mode) 368S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode)
369{ 369{
370 if (uniform < 0 || uniform >= (S32)mTexture.size()) 370 if (uniform < 0 || uniform >= (S32)mTexture.size())
371 { 371 {
@@ -376,12 +376,12 @@ S32 LLGLSLShader::enableTexture(S32 uniform, S32 mode)
376 if (index != -1) 376 if (index != -1)
377 { 377 {
378 gGL.getTexUnit(index)->activate(); 378 gGL.getTexUnit(index)->activate();
379 glEnable(mode); 379 gGL.getTexUnit(index)->enable(mode);
380 } 380 }
381 return index; 381 return index;
382} 382}
383 383
384S32 LLGLSLShader::disableTexture(S32 uniform, S32 mode) 384S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode)
385{ 385{
386 if (uniform < 0 || uniform >= (S32)mTexture.size()) 386 if (uniform < 0 || uniform >= (S32)mTexture.size())
387 { 387 {
@@ -392,7 +392,7 @@ S32 LLGLSLShader::disableTexture(S32 uniform, S32 mode)
392 if (index != -1) 392 if (index != -1)
393 { 393 {
394 gGL.getTexUnit(index)->activate(); 394 gGL.getTexUnit(index)->activate();
395 glDisable(mode); 395 gGL.getTexUnit(index)->disable();
396 } 396 }
397 return index; 397 return index;
398} 398}
diff --git a/linden/indra/llrender/llglslshader.h b/linden/indra/llrender/llglslshader.h
index 0fa8e41..66c53df 100644
--- a/linden/indra/llrender/llglslshader.h
+++ b/linden/indra/llrender/llglslshader.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -33,6 +33,7 @@
33#define LL_LLGLSLSHADER_H 33#define LL_LLGLSLSHADER_H
34 34
35#include "llgl.h" 35#include "llgl.h"
36#include "llrender.h"
36 37
37class LLShaderFeatures 38class LLShaderFeatures
38{ 39{
@@ -111,8 +112,8 @@ public:
111 //if given texture uniform is active in the shader, 112 //if given texture uniform is active in the shader,
112 //the corresponding channel will be active upon return 113 //the corresponding channel will be active upon return
113 //returns channel texture is enabled in from [0-MAX) 114 //returns channel texture is enabled in from [0-MAX)
114 S32 enableTexture(S32 uniform, S32 mode = GL_TEXTURE_2D); 115 S32 enableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
115 S32 disableTexture(S32 uniform, S32 mode = GL_TEXTURE_2D); 116 S32 disableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
116 117
117 BOOL link(BOOL suppress_errors = FALSE); 118 BOOL link(BOOL suppress_errors = FALSE);
118 void bind(); 119 void bind();
diff --git a/linden/indra/llrender/llglstates.h b/linden/indra/llrender/llglstates.h
index e53640c..94d136e 100644
--- a/linden/indra/llrender/llglstates.h
+++ b/linden/indra/llrender/llglstates.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -87,13 +87,6 @@ public:
87 { } 87 { }
88}; 88};
89 89
90class LLGLSNoTexture
91{
92public:
93 LLGLSNoTexture()
94 { LLImageGL::unbindTexture(0); }
95};
96
97class LLGLSObjectSelect 90class LLGLSObjectSelect
98{ 91{
99protected: 92protected:
@@ -104,7 +97,7 @@ public:
104 : mBlend(GL_BLEND), mFog(GL_FOG), 97 : mBlend(GL_BLEND), mFog(GL_FOG),
105 mAlphaTest(GL_ALPHA_TEST), 98 mAlphaTest(GL_ALPHA_TEST),
106 mCullFace(GL_CULL_FACE) 99 mCullFace(GL_CULL_FACE)
107 { LLImageGL::unbindTexture(0); } 100 { }
108}; 101};
109 102
110class LLGLSObjectSelectAlpha 103class LLGLSObjectSelectAlpha
@@ -143,17 +136,6 @@ public:
143 {} 136 {}
144}; 137};
145 138
146class LLGLSNoTextureNoAlphaTest // : public LLGLSUIDefault
147{
148protected:
149 LLGLDisable mAlphaTest;
150public:
151 LLGLSNoTextureNoAlphaTest()
152 : mAlphaTest(GL_ALPHA_TEST)
153
154 { LLImageGL::unbindTexture(0); }
155};
156
157//---------------------------------------------------------------------------- 139//----------------------------------------------------------------------------
158 140
159class LLGLSFog 141class LLGLSFog
@@ -251,7 +233,7 @@ public:
251 mBlend(GL_BLEND), 233 mBlend(GL_BLEND),
252 mAlphaTest(GL_ALPHA_TEST) 234 mAlphaTest(GL_ALPHA_TEST)
253 235
254 { LLImageGL::unbindTexture(0); } 236 { }
255}; 237};
256 238
257//---------------------------------------------------------------------------- 239//----------------------------------------------------------------------------
diff --git a/linden/indra/llrender/llgltypes.h b/linden/indra/llrender/llgltypes.h
index d22d5fa..5809b9c 100644
--- a/linden/indra/llrender/llgltypes.h
+++ b/linden/indra/llrender/llgltypes.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2006&license=viewergpl$ 5 * $LicenseInfo:firstyear=2006&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2006-2008, Linden Research, Inc. 7 * Copyright (c) 2006-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
diff --git a/linden/indra/llrender/llimagegl.cpp b/linden/indra/llrender/llimagegl.cpp
index a871758..6a142a7 100644
--- a/linden/indra/llrender/llimagegl.cpp
+++ b/linden/indra/llrender/llimagegl.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -63,6 +63,52 @@ F32 LLImageGL::sLastFrameTime = 0.f;
63 63
64std::set<LLImageGL*> LLImageGL::sImageList; 64std::set<LLImageGL*> LLImageGL::sImageList;
65 65
66//**************************************************************************************
67//below are functions for debug use
68//do not delete them even though they are not currently being used.
69void check_all_images()
70{
71 for (std::set<LLImageGL*>::iterator iter = LLImageGL::sImageList.begin();
72 iter != LLImageGL::sImageList.end(); iter++)
73 {
74 LLImageGL* glimage = *iter;
75 if (glimage->getTexName() && glimage->isGLTextureCreated())
76 {
77 gGL.getTexUnit(0)->bind(glimage) ;
78 glimage->checkTexSize() ;
79 gGL.getTexUnit(0)->unbind(glimage->getTarget()) ;
80 }
81 }
82}
83
84void LLImageGL::checkTexSize() const
85{
86 if (gDebugGL && mTarget == GL_TEXTURE_2D)
87 {
88 GLint texname;
89 glGetIntegerv(GL_TEXTURE_BINDING_2D, &texname);
90 if (texname != mTexName)
91 {
92 llerrs << "Invalid texture bound!" << llendl;
93 }
94 stop_glerror() ;
95 LLGLint x = 0, y = 0 ;
96 glGetTexLevelParameteriv(mTarget, 0, GL_TEXTURE_WIDTH, (GLint*)&x);
97 glGetTexLevelParameteriv(mTarget, 0, GL_TEXTURE_HEIGHT, (GLint*)&y) ;
98 stop_glerror() ;
99 if(!x || !y)
100 {
101 return ;
102 }
103 if(x != (mWidth >> mCurrentDiscardLevel) || y != (mHeight >> mCurrentDiscardLevel))
104 {
105 llerrs << "wrong texture size and discard level!" << llendl ;
106 }
107 }
108}
109//end of debug functions
110//**************************************************************************************
111
66//---------------------------------------------------------------------------- 112//----------------------------------------------------------------------------
67 113
68//static 114//static
@@ -125,49 +171,6 @@ S32 LLImageGL::dataFormatComponents(S32 dataformat)
125//---------------------------------------------------------------------------- 171//----------------------------------------------------------------------------
126 172
127// static 173// static
128void LLImageGL::bindExternalTexture(LLGLuint gl_name, S32 stage, LLGLenum bind_target )
129{
130 gGL.flush();
131 if (stage > 0)
132 {
133 gGL.getTexUnit(stage)->activate();
134 }
135 glBindTexture(bind_target, gl_name);
136 sCurrentBoundTextures[stage] = gl_name;
137 if (stage > 0)
138 {
139 gGL.getTexUnit(0)->activate();
140 }
141}
142
143// static
144void LLImageGL::unbindTexture(S32 stage, LLGLenum bind_target)
145{
146 // LLGLSLShader can return -1
147 if (stage >= 0)
148 {
149 gGL.flush();
150 if (stage > 0)
151 {
152 gGL.getTexUnit(stage)->activate();
153 glBindTexture(GL_TEXTURE_2D, 0);
154 gGL.getTexUnit(0)->activate();
155 }
156 else
157 {
158 glBindTexture(GL_TEXTURE_2D, 0);
159 }
160 sCurrentBoundTextures[stage] = 0;
161 }
162}
163
164// static (duplicated for speed and to avoid GL_TEXTURE_2D default argument which requires GL header dependency)
165void LLImageGL::unbindTexture(S32 stage)
166{
167 unbindTexture(stage, GL_TEXTURE_2D);
168}
169
170// static
171void LLImageGL::updateStats(F32 current_time) 174void LLImageGL::updateStats(F32 current_time)
172{ 175{
173 sLastFrameTime = current_time; 176 sLastFrameTime = current_time;
@@ -189,19 +192,24 @@ void LLImageGL::destroyGL(BOOL save_state)
189{ 192{
190 for (S32 stage = 0; stage < gGLManager.mNumTextureUnits; stage++) 193 for (S32 stage = 0; stage < gGLManager.mNumTextureUnits; stage++)
191 { 194 {
192 LLImageGL::unbindTexture(stage, GL_TEXTURE_2D); 195 gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE);
193 } 196 }
197
194 for (std::set<LLImageGL*>::iterator iter = sImageList.begin(); 198 for (std::set<LLImageGL*>::iterator iter = sImageList.begin();
195 iter != sImageList.end(); iter++) 199 iter != sImageList.end(); iter++)
196 { 200 {
197 LLImageGL* glimage = *iter; 201 LLImageGL* glimage = *iter;
198 if (glimage->mTexName && glimage->mComponents) 202 if (glimage->mTexName)
199 { 203 {
200 if (save_state) 204 if (save_state && glimage->isGLTextureCreated() && glimage->mComponents)
201 { 205 {
202 glimage->mSaveData = new LLImageRaw; 206 glimage->mSaveData = new LLImageRaw;
203 glimage->readBackRaw(glimage->mCurrentDiscardLevel, glimage->mSaveData, false); 207 if(!glimage->readBackRaw(glimage->mCurrentDiscardLevel, glimage->mSaveData, false))
208 {
209 glimage->mSaveData = NULL ;
210 }
204 } 211 }
212
205 glimage->destroyGLTexture(); 213 glimage->destroyGLTexture();
206 stop_glerror(); 214 stop_glerror();
207 } 215 }
@@ -215,9 +223,13 @@ void LLImageGL::restoreGL()
215 iter != sImageList.end(); iter++) 223 iter != sImageList.end(); iter++)
216 { 224 {
217 LLImageGL* glimage = *iter; 225 LLImageGL* glimage = *iter;
218 if (glimage->mSaveData.notNull() && glimage->mSaveData->getComponents()) 226 if(glimage->getTexName())
227 {
228 llerrs << "tex name is not 0." << llendl ;
229 }
230 if (glimage->mSaveData.notNull())
219 { 231 {
220 if (glimage->getComponents()) 232 if (glimage->getComponents() && glimage->mSaveData->getComponents())
221 { 233 {
222 glimage->createGLTexture(glimage->mCurrentDiscardLevel, glimage->mSaveData); 234 glimage->createGLTexture(glimage->mCurrentDiscardLevel, glimage->mSaveData);
223 stop_glerror(); 235 stop_glerror();
@@ -284,6 +296,8 @@ LLImageGL::~LLImageGL()
284{ 296{
285 LLImageGL::cleanup(); 297 LLImageGL::cleanup();
286 sImageList.erase(this); 298 sImageList.erase(this);
299 delete [] mPickMask;
300 mPickMask = NULL;
287 sCount--; 301 sCount--;
288} 302}
289 303
@@ -293,11 +307,12 @@ void LLImageGL::init(BOOL usemipmaps)
293 mMissed = FALSE; 307 mMissed = FALSE;
294#endif 308#endif
295 309
310 mPickMask = NULL;
296 mTextureMemory = 0; 311 mTextureMemory = 0;
297 mLastBindTime = 0.f; 312 mLastBindTime = 0.f;
298 313
299 mTarget = GL_TEXTURE_2D; 314 mTarget = GL_TEXTURE_2D;
300 mBindTarget = GL_TEXTURE_2D; 315 mBindTarget = LLTexUnit::TT_TEXTURE;
301 mUseMipMaps = usemipmaps; 316 mUseMipMaps = usemipmaps;
302 mHasMipMaps = FALSE; 317 mHasMipMaps = FALSE;
303 mAutoGenMips = FALSE; 318 mAutoGenMips = FALSE;
@@ -321,6 +336,8 @@ void LLImageGL::init(BOOL usemipmaps)
321 mFormatType = GL_UNSIGNED_BYTE; 336 mFormatType = GL_UNSIGNED_BYTE;
322 mFormatSwapBytes = FALSE; 337 mFormatSwapBytes = FALSE;
323 mHasExplicitFormat = FALSE; 338 mHasExplicitFormat = FALSE;
339
340 mGLTextureCreated = FALSE ;
324} 341}
325 342
326void LLImageGL::cleanup() 343void LLImageGL::cleanup()
@@ -421,41 +438,14 @@ void LLImageGL::dump()
421 438
422//---------------------------------------------------------------------------- 439//----------------------------------------------------------------------------
423 440
424BOOL LLImageGL::bindTextureInternal(const S32 stage) const 441void LLImageGL::updateBindStats(void) const
425{ 442{
426 if (gGLManager.mIsDisabled)
427 {
428 llwarns << "Trying to bind a texture while GL is disabled!" << llendl;
429 }
430
431
432 if (sCurrentBoundTextures[stage] && sCurrentBoundTextures[stage] == mTexName)
433 {
434 // already set!
435 return TRUE;
436 }
437
438 if (mTexName != 0) 443 if (mTexName != 0)
439 { 444 {
440#ifdef DEBUG_MISS 445#ifdef DEBUG_MISS
441 mMissed = ! getIsResident(TRUE); 446 mMissed = ! getIsResident(TRUE);
442#endif 447#endif
443
444 gGL.flush();
445 if (stage > 0)
446 {
447 gGL.getTexUnit(stage)->activate();
448 }
449
450 glBindTexture(mBindTarget, mTexName);
451 sCurrentBoundTextures[stage] = mTexName;
452 sBindCount++; 448 sBindCount++;
453
454 if (stage > 0)
455 {
456 gGL.getTexUnit(0)->activate();
457 }
458
459 if (mLastBindTime != sLastFrameTime) 449 if (mLastBindTime != sLastFrameTime)
460 { 450 {
461 // we haven't accounted for this texture yet this frame 451 // we haven't accounted for this texture yet this frame
@@ -463,38 +453,22 @@ BOOL LLImageGL::bindTextureInternal(const S32 stage) const
463 updateBoundTexMem(mTextureMemory); 453 updateBoundTexMem(mTextureMemory);
464 mLastBindTime = sLastFrameTime; 454 mLastBindTime = sLastFrameTime;
465 } 455 }
466
467 return TRUE;
468 }
469 else
470 {
471 gGL.flush();
472 if (stage > 0)
473 {
474 gGL.getTexUnit(stage)->activate();
475 }
476 glBindTexture(mBindTarget, 0);
477 if (stage > 0)
478 {
479 gGL.getTexUnit(0)->activate();
480 }
481 sCurrentBoundTextures[stage] = 0;
482 return FALSE;
483 } 456 }
484} 457}
485 458
486//virtual 459//virtual
487BOOL LLImageGL::bind(const S32 stage) const 460bool LLImageGL::bindError(const S32 stage) const
488{ 461{
489 if (stage == -1) 462 return false;
490 { 463}
491 return FALSE; 464
492 } 465//virtual
493 BOOL res = bindTextureInternal(stage); 466bool LLImageGL::bindDefaultImage(const S32 stage) const
494 //llassert(res); 467{
495 return res; 468 return false;
496} 469}
497 470
471
498void LLImageGL::setExplicitFormat( LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format, BOOL swap_bytes ) 472void LLImageGL::setExplicitFormat( LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format, BOOL swap_bytes )
499{ 473{
500 // Note: must be called before createTexture() 474 // Note: must be called before createTexture()
@@ -532,7 +506,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
532 506
533 { 507 {
534// LLFastTimer t2(LLFastTimer::FTM_TEMP2); 508// LLFastTimer t2(LLFastTimer::FTM_TEMP2);
535 llverify(bindTextureInternal(0)); 509 llverify(gGL.getTexUnit(0)->bind(this));
536 } 510 }
537 511
538 if (mUseMipMaps) 512 if (mUseMipMaps)
@@ -569,7 +543,8 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
569 } 543 }
570 544
571 glTexImage2D(mTarget, gl_level, mFormatInternal, w, h, 0, mFormatPrimary, GL_UNSIGNED_BYTE, (GLvoid*)data_in); 545 glTexImage2D(mTarget, gl_level, mFormatInternal, w, h, 0, mFormatPrimary, GL_UNSIGNED_BYTE, (GLvoid*)data_in);
572 546 updatePickMask(w, h, data_in);
547
573 if(mFormatSwapBytes) 548 if(mFormatSwapBytes)
574 { 549 {
575 glPixelStorei(GL_UNPACK_SWAP_BYTES, 0); 550 glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
@@ -585,7 +560,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
585 { 560 {
586 if (mAutoGenMips) 561 if (mAutoGenMips)
587 { 562 {
588 glTexParameteri(mBindTarget, GL_GENERATE_MIPMAP_SGIS, TRUE); 563 glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_GENERATE_MIPMAP_SGIS, TRUE);
589 stop_glerror(); 564 stop_glerror();
590 { 565 {
591// LLFastTimer t2(LLFastTimer::FTM_TEMP4); 566// LLFastTimer t2(LLFastTimer::FTM_TEMP4);
@@ -596,12 +571,17 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
596 stop_glerror(); 571 stop_glerror();
597 } 572 }
598 573
574 S32 w = getWidth(mCurrentDiscardLevel);
575 S32 h = getHeight(mCurrentDiscardLevel);
576
599 glTexImage2D(mTarget, 0, mFormatInternal, 577 glTexImage2D(mTarget, 0, mFormatInternal,
600 getWidth(mCurrentDiscardLevel), getHeight(mCurrentDiscardLevel), 0, 578 w, h, 0,
601 mFormatPrimary, mFormatType, 579 mFormatPrimary, mFormatType,
602 data_in); 580 data_in);
603 stop_glerror(); 581 stop_glerror();
604 582
583 updatePickMask(w, h, data_in);
584
605 if(mFormatSwapBytes) 585 if(mFormatSwapBytes)
606 { 586 {
607 glPixelStorei(GL_UNPACK_SWAP_BYTES, 0); 587 glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
@@ -651,6 +631,10 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
651 631
652 glTexImage2D(mTarget, m, mFormatInternal, w, h, 0, mFormatPrimary, mFormatType, cur_mip_data); 632 glTexImage2D(mTarget, m, mFormatInternal, w, h, 0, mFormatPrimary, mFormatType, cur_mip_data);
653 stop_glerror(); 633 stop_glerror();
634 if (m == 0)
635 {
636 updatePickMask(w, h, cur_mip_data);
637 }
654 638
655 if(mFormatSwapBytes) 639 if(mFormatSwapBytes)
656 { 640 {
@@ -701,6 +685,8 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
701 685
702 glTexImage2D(mTarget, 0, mFormatInternal, w, h, 0, 686 glTexImage2D(mTarget, 0, mFormatInternal, w, h, 0,
703 mFormatPrimary, mFormatType, (GLvoid *)data_in); 687 mFormatPrimary, mFormatType, (GLvoid *)data_in);
688 updatePickMask(w, h, data_in);
689
704 stop_glerror(); 690 stop_glerror();
705 691
706 if(mFormatSwapBytes) 692 if(mFormatSwapBytes)
@@ -713,6 +699,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
713 mHasMipMaps = FALSE; 699 mHasMipMaps = FALSE;
714 } 700 }
715 stop_glerror(); 701 stop_glerror();
702 mGLTextureCreated = true;
716} 703}
717 704
718BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S32 x_pos, S32 y_pos, S32 width, S32 height) 705BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S32 x_pos, S32 y_pos, S32 width, S32 height)
@@ -786,12 +773,10 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3
786 773
787 datap += (y_pos * data_width + x_pos) * getComponents(); 774 datap += (y_pos * data_width + x_pos) * getComponents();
788 // Update the GL texture 775 // Update the GL texture
789 BOOL res = bindTextureInternal(0); 776 BOOL res = gGL.getTexUnit(0)->bindManual(mBindTarget, mTexName);
790 if (!res) llerrs << "LLImageGL::setSubImage(): bindTexture failed" << llendl; 777 if (!res) llerrs << "LLImageGL::setSubImage(): bindTexture failed" << llendl;
791 stop_glerror(); 778 stop_glerror();
792 779
793 LLGLEnable tex( GL_TEXTURE_2D );
794
795 glTexSubImage2D(mTarget, 0, x_pos, y_pos, 780 glTexSubImage2D(mTarget, 0, x_pos, y_pos,
796 width, height, mFormatPrimary, mFormatType, datap); 781 width, height, mFormatPrimary, mFormatType, datap);
797 stop_glerror(); 782 stop_glerror();
@@ -804,8 +789,8 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3
804 789
805 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); 790 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
806 stop_glerror(); 791 stop_glerror();
792 mGLTextureCreated = true;
807 } 793 }
808
809 return TRUE; 794 return TRUE;
810} 795}
811 796
@@ -817,9 +802,10 @@ BOOL LLImageGL::setSubImage(const LLImageRaw* imageraw, S32 x_pos, S32 y_pos, S3
817// Copy sub image from frame buffer 802// Copy sub image from frame buffer
818BOOL LLImageGL::setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_pos, S32 width, S32 height) 803BOOL LLImageGL::setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_pos, S32 width, S32 height)
819{ 804{
820 if (bindTextureInternal(0)) 805 if (gGL.getTexUnit(0)->bind(this, true))
821 { 806 {
822 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, fb_x, fb_y, x_pos, y_pos, width, height); 807 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, fb_x, fb_y, x_pos, y_pos, width, height);
808 mGLTextureCreated = true;
823 stop_glerror(); 809 stop_glerror();
824 return TRUE; 810 return TRUE;
825 } 811 }
@@ -829,6 +815,36 @@ BOOL LLImageGL::setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_
829 } 815 }
830} 816}
831 817
818//create an empty GL texture: just create a texture name
819//the texture is assiciate with some image by calling glTexImage outside LLImageGL
820BOOL LLImageGL::createGLTexture()
821{
822 if (gGLManager.mIsDisabled)
823 {
824 llwarns << "Trying to create a texture while GL is disabled!" << llendl;
825 return FALSE;
826 }
827
828 mGLTextureCreated = false ; //do not save this texture when gl is destroyed.
829
830 llassert(gGLManager.mInited);
831 stop_glerror();
832
833 if(mTexName)
834 {
835 glDeleteTextures(1, (reinterpret_cast<GLuint*>(&mTexName))) ;
836 }
837
838 glGenTextures(1, (GLuint*)&mTexName);
839 stop_glerror();
840 if (!mTexName)
841 {
842 llerrs << "LLImageGL::createGLTexture failed to make an empty texture" << llendl;
843 }
844
845 return TRUE ;
846}
847
832BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename/*=0*/) 848BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename/*=0*/)
833{ 849{
834 if (gGLManager.mIsDisabled) 850 if (gGLManager.mIsDisabled)
@@ -836,6 +852,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S
836 llwarns << "Trying to create a texture while GL is disabled!" << llendl; 852 llwarns << "Trying to create a texture while GL is disabled!" << llendl;
837 return FALSE; 853 return FALSE;
838 } 854 }
855 mGLTextureCreated = false ;
839 llassert(gGLManager.mInited); 856 llassert(gGLManager.mInited);
840 stop_glerror(); 857 stop_glerror();
841 858
@@ -919,9 +936,9 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_
919 stop_glerror(); 936 stop_glerror();
920 { 937 {
921// LLFastTimer t1(LLFastTimer::FTM_TEMP6); 938// LLFastTimer t1(LLFastTimer::FTM_TEMP6);
922 llverify(bindTextureInternal(0)); 939 llverify(gGL.getTexUnit(0)->bind(this));
923 glTexParameteri(mBindTarget, GL_TEXTURE_BASE_LEVEL, 0); 940 glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_BASE_LEVEL, 0);
924 glTexParameteri(mBindTarget, GL_TEXTURE_MAX_LEVEL, mMaxDiscardLevel-discard_level); 941 glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_MAX_LEVEL, mMaxDiscardLevel-discard_level);
925 } 942 }
926 } 943 }
927 if (!mTexName) 944 if (!mTexName)
@@ -941,7 +958,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_
941#endif 958#endif
942 } 959 }
943 960
944 mCurrentDiscardLevel = discard_level; 961 mCurrentDiscardLevel = discard_level;
945 962
946 setImage(data_in, data_hasmips); 963 setImage(data_in, data_hasmips);
947 964
@@ -949,7 +966,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_
949 setMipFilterNearest(mMagFilterNearest); 966 setMipFilterNearest(mMagFilterNearest);
950 967
951 // things will break if we don't unbind after creation 968 // things will break if we don't unbind after creation
952 unbindTexture(0, mBindTarget); 969 gGL.getTexUnit(0)->unbind(mBindTarget);
953 stop_glerror(); 970 stop_glerror();
954 971
955 if (old_name != 0) 972 if (old_name != 0)
@@ -1042,7 +1059,7 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre
1042 discard_level = mCurrentDiscardLevel; 1059 discard_level = mCurrentDiscardLevel;
1043 } 1060 }
1044 1061
1045 if (mTexName == 0 || discard_level < mCurrentDiscardLevel) 1062 if (mTexName == 0 || discard_level < mCurrentDiscardLevel || discard_level > mMaxDiscardLevel )
1046 { 1063 {
1047 return FALSE; 1064 return FALSE;
1048 } 1065 }
@@ -1050,21 +1067,11 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre
1050 S32 gl_discard = discard_level - mCurrentDiscardLevel; 1067 S32 gl_discard = discard_level - mCurrentDiscardLevel;
1051 1068
1052 //explicitly unbind texture 1069 //explicitly unbind texture
1053 LLImageGL::unbindTexture(0, mTarget); 1070 gGL.getTexUnit(0)->unbind(mBindTarget);
1054 llverify(bindTextureInternal(0)); 1071 llverify(gGL.getTexUnit(0)->bind(this));
1055 1072
1056 if (gDebugGL) 1073 //debug code, leave it there commented.
1057 { 1074 //checkTexSize() ;
1058 if (mTarget == GL_TEXTURE_2D)
1059 {
1060 GLint texname;
1061 glGetIntegerv(GL_TEXTURE_BINDING_2D, &texname);
1062 if (texname != mTexName)
1063 {
1064 llerrs << "Invalid texture bound!" << llendl;
1065 }
1066 }
1067 }
1068 1075
1069 LLGLint glwidth = 0; 1076 LLGLint glwidth = 0;
1070 glGetTexLevelParameteriv(mTarget, gl_discard, GL_TEXTURE_WIDTH, (GLint*)&glwidth); 1077 glGetTexLevelParameteriv(mTarget, gl_discard, GL_TEXTURE_WIDTH, (GLint*)&glwidth);
@@ -1073,7 +1080,7 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre
1073 // No mip data smaller than current discard level 1080 // No mip data smaller than current discard level
1074 return FALSE; 1081 return FALSE;
1075 } 1082 }
1076 1083
1077 S32 width = getWidth(discard_level); 1084 S32 width = getWidth(discard_level);
1078 S32 height = getHeight(discard_level); 1085 S32 height = getHeight(discard_level);
1079 S32 ncomponents = getComponents(); 1086 S32 ncomponents = getComponents();
@@ -1081,6 +1088,13 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre
1081 { 1088 {
1082 return FALSE; 1089 return FALSE;
1083 } 1090 }
1091 if(width < glwidth)
1092 {
1093 llwarns << "texture size is smaller than it should be." << llendl ;
1094 llwarns << "width: " << width << " glwidth: " << glwidth << " mWidth: " << mWidth <<
1095 " mCurrentDiscardLevel: " << (S32)mCurrentDiscardLevel << " discard_level: " << (S32)discard_level << llendl ;
1096 return FALSE ;
1097 }
1084 1098
1085 if (width <= 0 || width > 2048 || height <= 0 || height > 2048 || ncomponents < 1 || ncomponents > 4) 1099 if (width <= 0 || width > 2048 || height <= 0 || height > 2048 || ncomponents < 1 || ncomponents > 4)
1086 { 1100 {
@@ -1148,15 +1162,15 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre
1148 1162
1149void LLImageGL::destroyGLTexture() 1163void LLImageGL::destroyGLTexture()
1150{ 1164{
1151 stop_glerror();
1152
1153 if (mTexName != 0) 1165 if (mTexName != 0)
1154 { 1166 {
1167 stop_glerror();
1168
1155 for (int i = 0; i < gGLManager.mNumTextureUnits; i++) 1169 for (int i = 0; i < gGLManager.mNumTextureUnits; i++)
1156 { 1170 {
1157 if (sCurrentBoundTextures[i] == mTexName) 1171 if (sCurrentBoundTextures[i] == mTexName)
1158 { 1172 {
1159 unbindTexture(i, GL_TEXTURE_2D); 1173 gGL.getTexUnit(i)->unbind(LLTexUnit::TT_TEXTURE);
1160 stop_glerror(); 1174 stop_glerror();
1161 } 1175 }
1162 } 1176 }
@@ -1166,7 +1180,7 @@ void LLImageGL::destroyGLTexture()
1166 1180
1167 glDeleteTextures(1, (GLuint*)&mTexName); 1181 glDeleteTextures(1, (GLuint*)&mTexName);
1168 mTexName = 0; 1182 mTexName = 0;
1169 1183 mGLTextureCreated = FALSE ;
1170 stop_glerror(); 1184 stop_glerror();
1171 } 1185 }
1172} 1186}
@@ -1184,8 +1198,8 @@ void LLImageGL::glClamp (BOOL clamps, BOOL clampt)
1184{ 1198{
1185 if (mTexName != 0) 1199 if (mTexName != 0)
1186 { 1200 {
1187 glTexParameteri (mBindTarget, GL_TEXTURE_WRAP_S, clamps ? GL_CLAMP_TO_EDGE : GL_REPEAT); 1201 glTexParameteri (LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_WRAP_S, clamps ? GL_CLAMP_TO_EDGE : GL_REPEAT);
1188 glTexParameteri (mBindTarget, GL_TEXTURE_WRAP_T, clampt ? GL_CLAMP_TO_EDGE : GL_REPEAT); 1202 glTexParameteri (LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_WRAP_T, clampt ? GL_CLAMP_TO_EDGE : GL_REPEAT);
1189 } 1203 }
1190} 1204}
1191 1205
@@ -1223,23 +1237,23 @@ void LLImageGL::setMipFilterNearest(BOOL mag_nearest, BOOL min_nearest)
1223 { 1237 {
1224 if (mMinFilterNearest) 1238 if (mMinFilterNearest)
1225 { 1239 {
1226 glTexParameteri(mBindTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 1240 glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1227 } 1241 }
1228 else if (mHasMipMaps) 1242 else if (mHasMipMaps)
1229 { 1243 {
1230 glTexParameteri(mBindTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 1244 glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
1231 } 1245 }
1232 else 1246 else
1233 { 1247 {
1234 glTexParameteri(mBindTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 1248 glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1235 } 1249 }
1236 if (mMagFilterNearest) 1250 if (mMagFilterNearest)
1237 { 1251 {
1238 glTexParameteri(mBindTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1252 glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1239 } 1253 }
1240 else 1254 else
1241 { 1255 {
1242 glTexParameteri(mBindTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 1256 glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1243 } 1257 }
1244 if (gGLManager.mHasAnisotropic) 1258 if (gGLManager.mHasAnisotropic)
1245 { 1259 {
@@ -1247,16 +1261,15 @@ void LLImageGL::setMipFilterNearest(BOOL mag_nearest, BOOL min_nearest)
1247 { 1261 {
1248 F32 largest_anisotropy; 1262 F32 largest_anisotropy;
1249 glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_anisotropy); 1263 glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_anisotropy);
1250 glTexParameterf(mBindTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_anisotropy); 1264 glTexParameterf(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_anisotropy);
1251 } 1265 }
1252 else 1266 else
1253 { 1267 {
1254 glTexParameterf(mBindTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); 1268 glTexParameterf(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f);
1255 } 1269 }
1256 } 1270 }
1257 } 1271 stop_glerror();
1258 1272 }
1259 stop_glerror();
1260} 1273}
1261 1274
1262BOOL LLImageGL::getIsResident(BOOL test_now) 1275BOOL LLImageGL::getIsResident(BOOL test_now)
@@ -1337,14 +1350,93 @@ BOOL LLImageGL::getBoundRecently() const
1337 return (BOOL)(sLastFrameTime - mLastBindTime < MIN_TEXTURE_LIFETIME); 1350 return (BOOL)(sLastFrameTime - mLastBindTime < MIN_TEXTURE_LIFETIME);
1338} 1351}
1339 1352
1340void LLImageGL::setTarget(const LLGLenum target, const LLGLenum bind_target) 1353void LLImageGL::setTarget(const LLGLenum target, const LLTexUnit::eTextureType bind_target)
1341{ 1354{
1342 mTarget = target; 1355 mTarget = target;
1343 mBindTarget = bind_target; 1356 mBindTarget = bind_target;
1344} 1357}
1345 1358
1359void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in)
1360{
1361 if (mFormatType != GL_UNSIGNED_BYTE ||
1362 mFormatPrimary != GL_RGBA)
1363 {
1364 //cannot generate a pick mask for this texture
1365 delete [] mPickMask;
1366 mPickMask = NULL;
1367 return;
1368 }
1369
1370 U32 pick_width = width/2;
1371 U32 pick_height = height/2;
1372
1373 U32 size = llmax(pick_width, (U32) 1) * llmax(pick_height, (U32) 1);
1374
1375 size = size/8 + 1;
1376
1377 delete[] mPickMask;
1378 mPickMask = new U8[size];
1379
1380 memset(mPickMask, 0, sizeof(U8) * size);
1381
1382 U32 pick_bit = 0;
1383
1384 for (S32 y = 0; y < height; y += 2)
1385 {
1386 for (S32 x = 0; x < width; x += 2)
1387 {
1388 U8 alpha = data_in[(y*width+x)*4+3];
1389
1390 if (alpha > 32)
1391 {
1392 U32 pick_idx = pick_bit/8;
1393 U32 pick_offset = pick_bit%8;
1394 if (pick_idx >= size)
1395 {
1396 llerrs << "WTF?" << llendl;
1397 }
1398
1399 mPickMask[pick_idx] |= 1 << pick_offset;
1400 }
1401
1402 ++pick_bit;
1403 }
1404 }
1405}
1406
1407BOOL LLImageGL::getMask(const LLVector2 &tc)
1408{
1409 BOOL res = TRUE;
1410
1411 if (mPickMask)
1412 {
1413 S32 width = getWidth()/2;
1414 S32 height = getHeight()/2;
1415
1416 F32 u = tc.mV[0] - floorf(tc.mV[0]);
1417 F32 v = tc.mV[1] - floorf(tc.mV[1]);
1418
1419 if (u < 0.f || u > 1.f ||
1420 v < 0.f || v > 1.f)
1421 {
1422 llerrs << "WTF?" << llendl;
1423 }
1424
1425 S32 x = (S32)(u * width);
1426 S32 y = (S32)(v * height);
1427
1428 S32 idx = y*width+x;
1429 S32 offset = idx%8;
1430
1431 res = mPickMask[idx/8] & (1 << offset) ? TRUE : FALSE;
1432 }
1433
1434 return res;
1435}
1436
1346//---------------------------------------------------------------------------- 1437//----------------------------------------------------------------------------
1347 1438
1439
1348// Manual Mip Generation 1440// Manual Mip Generation
1349/* 1441/*
1350 S32 width = getWidth(discard_level); 1442 S32 width = getWidth(discard_level);
diff --git a/linden/indra/llrender/llimagegl.h b/linden/indra/llrender/llimagegl.h
index 3f231ee..1965495 100644
--- a/linden/indra/llrender/llimagegl.h
+++ b/linden/indra/llrender/llimagegl.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -37,6 +37,9 @@
37 37
38#include "llgltypes.h" 38#include "llgltypes.h"
39#include "llmemory.h" 39#include "llmemory.h"
40#include "v2math.h"
41
42#include "llrender.h"
40 43
41//============================================================================ 44//============================================================================
42 45
@@ -48,11 +51,7 @@ public:
48 static S32 dataFormatBytes(S32 dataformat, S32 width, S32 height); 51 static S32 dataFormatBytes(S32 dataformat, S32 width, S32 height);
49 static S32 dataFormatComponents(S32 dataformat); 52 static S32 dataFormatComponents(S32 dataformat);
50 53
51 // Wrapper for glBindTexture that keeps LLImageGL in sync. 54 void updateBindStats(void) const;
52 // Usually you want stage = 0 and bind_target = GL_TEXTURE_2D
53 static void bindExternalTexture( LLGLuint gl_name, S32 stage, LLGLenum bind_target);
54 static void unbindTexture(S32 stage, LLGLenum target);
55 static void unbindTexture(S32 stage); // Uses GL_TEXTURE_2D (not a default arg to avoid gl.h dependency)
56 55
57 // needs to be called every frame 56 // needs to be called every frame
58 static void updateStats(F32 current_time); 57 static void updateStats(F32 current_time);
@@ -79,7 +78,6 @@ public:
79 78
80protected: 79protected:
81 virtual ~LLImageGL(); 80 virtual ~LLImageGL();
82 BOOL bindTextureInternal(const S32 stage = 0) const;
83 81
84private: 82private:
85 void glClamp (BOOL clamps, BOOL clampt); 83 void glClamp (BOOL clamps, BOOL clampt);
@@ -87,10 +85,12 @@ private:
87 85
88public: 86public:
89 virtual void dump(); // debugging info to llinfos 87 virtual void dump(); // debugging info to llinfos
90 virtual BOOL bind(const S32 stage = 0) const; 88 virtual bool bindError(const S32 stage = 0) const;
89 virtual bool bindDefaultImage(const S32 stage = 0) const;
91 90
92 void setSize(S32 width, S32 height, S32 ncomponents); 91 void setSize(S32 width, S32 height, S32 ncomponents);
93 92
93 BOOL createGLTexture() ;
94 BOOL createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename = 0); 94 BOOL createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename = 0);
95 BOOL createGLTexture(S32 discard_level, const U8* data, BOOL data_hasmips = FALSE, S32 usename = 0); 95 BOOL createGLTexture(S32 discard_level, const U8* data, BOOL data_hasmips = FALSE, S32 usename = 0);
96 void setImage(const LLImageRaw* imageraw); 96 void setImage(const LLImageRaw* imageraw);
@@ -114,6 +114,8 @@ public:
114 S32 getDiscardLevel() const { return mCurrentDiscardLevel; } 114 S32 getDiscardLevel() const { return mCurrentDiscardLevel; }
115 S32 getMaxDiscardLevel() const { return mMaxDiscardLevel; } 115 S32 getMaxDiscardLevel() const { return mMaxDiscardLevel; }
116 116
117 S32 getCurrentWidth() const { return mWidth ;}
118 S32 getCurrentHeight() const { return mHeight ;}
117 S32 getWidth(S32 discard_level = -1) const; 119 S32 getWidth(S32 discard_level = -1) const;
118 S32 getHeight(S32 discard_level = -1) const; 120 S32 getHeight(S32 discard_level = -1) const;
119 U8 getComponents() const { return mComponents; } 121 U8 getComponents() const { return mComponents; }
@@ -132,7 +134,11 @@ public:
132 134
133 BOOL getIsResident(BOOL test_now = FALSE); // not const 135 BOOL getIsResident(BOOL test_now = FALSE); // not const
134 136
135 void setTarget(const LLGLenum target, const LLGLenum bind_target); 137 void setTarget(const LLGLenum target, const LLTexUnit::eTextureType bind_target);
138
139 LLTexUnit::eTextureType getTarget(void) const { return mBindTarget; }
140 bool isGLTextureCreated(void) const { return mGLTextureCreated ; }
141 void setGLTextureCreated (bool initialized) { mGLTextureCreated = initialized; }
136 142
137 BOOL getUseMipMaps() const { return mUseMipMaps; } 143 BOOL getUseMipMaps() const { return mUseMipMaps; }
138 void setUseMipMaps(BOOL usemips) { mUseMipMaps = usemips; } 144 void setUseMipMaps(BOOL usemips) { mUseMipMaps = usemips; }
@@ -141,6 +147,11 @@ public:
141 147
142 BOOL isValidForSculpt(S32 discard_level, S32 image_width, S32 image_height, S32 ncomponents) ; 148 BOOL isValidForSculpt(S32 discard_level, S32 image_width, S32 image_height, S32 ncomponents) ;
143 149
150 void updatePickMask(S32 width, S32 height, const U8* data_in);
151 BOOL getMask(const LLVector2 &tc);
152
153 void checkTexSize() const ;
154
144protected: 155protected:
145 void init(BOOL usemipmaps); 156 void init(BOOL usemipmaps);
146 virtual void cleanup(); // Clean up the LLImageGL so it can be reinitialized. Be careful when using this in derived class destructors 157 virtual void cleanup(); // Clean up the LLImageGL so it can be reinitialized. Be careful when using this in derived class destructors
@@ -152,25 +163,26 @@ public:
152 163
153private: 164private:
154 LLPointer<LLImageRaw> mSaveData; // used for destroyGL/restoreGL 165 LLPointer<LLImageRaw> mSaveData; // used for destroyGL/restoreGL
166 U8* mPickMask; //downsampled bitmap approximation of alpha channel. NULL if no alpha channel
155 S8 mUseMipMaps; 167 S8 mUseMipMaps;
156 S8 mHasMipMaps; 168 S8 mHasMipMaps;
157 S8 mHasExplicitFormat; // If false (default), GL format is f(mComponents) 169 S8 mHasExplicitFormat; // If false (default), GL format is f(mComponents)
158 S8 mAutoGenMips; 170 S8 mAutoGenMips;
159 171
160protected: 172 bool mGLTextureCreated ;
161 LLGLenum mTarget; // Normally GL_TEXTURE2D, sometimes something else (ex. cube maps)
162 LLGLenum mBindTarget; // NOrmally GL_TEXTURE2D, sometimes something else (ex. cube maps)
163
164 LLGLuint mTexName; 173 LLGLuint mTexName;
174 U16 mWidth;
175 U16 mHeight;
176 S8 mCurrentDiscardLevel;
165 177
178protected:
179 LLGLenum mTarget; // Normally GL_TEXTURE2D, sometimes something else (ex. cube maps)
180 LLTexUnit::eTextureType mBindTarget; // Normally TT_TEXTURE, sometimes something else (ex. cube maps)
181
166 LLGLboolean mIsResident; 182 LLGLboolean mIsResident;
167
168 U16 mWidth;
169 U16 mHeight;
170 183
171 S8 mComponents; 184 S8 mComponents;
172 S8 mMaxDiscardLevel; 185 S8 mMaxDiscardLevel;
173 S8 mCurrentDiscardLevel;
174 S8 mDontDiscard; // Keep full res version of this image (for UI, etc) 186 S8 mDontDiscard; // Keep full res version of this image (for UI, etc)
175 187
176 S8 mClampS; // Need to save clamp state 188 S8 mClampS; // Need to save clamp state
@@ -200,7 +212,6 @@ public:
200 static U32 sBindCount; // Tracks number of texture binds for current frame 212 static U32 sBindCount; // Tracks number of texture binds for current frame
201 static U32 sUniqueCount; // Tracks number of unique texture binds for current frame 213 static U32 sUniqueCount; // Tracks number of unique texture binds for current frame
202 static BOOL sGlobalUseAnisotropic; 214 static BOOL sGlobalUseAnisotropic;
203
204#if DEBUG_MISS 215#if DEBUG_MISS
205 BOOL mMissed; // Missed on last bind? 216 BOOL mMissed; // Missed on last bind?
206 BOOL getMissed() const { return mMissed; }; 217 BOOL getMissed() const { return mMissed; };
diff --git a/linden/indra/llrender/llpostprocess.cpp b/linden/indra/llrender/llpostprocess.cpp
index c884951..92a0854 100644
--- a/linden/indra/llrender/llpostprocess.cpp
+++ b/linden/indra/llrender/llpostprocess.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2007&license=viewergpl$ 5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2007-2008, Linden Research, Inc. 7 * Copyright (c) 2007-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -51,12 +51,14 @@ static const float LUMINANCE_B = 0.114f;
51static const char * const XML_FILENAME = "postprocesseffects.xml"; 51static const char * const XML_FILENAME = "postprocesseffects.xml";
52 52
53LLPostProcess::LLPostProcess(void) : 53LLPostProcess::LLPostProcess(void) :
54 sceneRenderTexture(0), noiseTexture(0),
55 tempBloomTexture(0),
56 initialized(false), 54 initialized(false),
57 mAllEffects(LLSD::emptyMap()), 55 mAllEffects(LLSD::emptyMap()),
58 screenW(1), screenH(1) 56 screenW(1), screenH(1)
59{ 57{
58 mSceneRenderTexture = NULL ;
59 mNoiseTexture = NULL ;
60 mTempBloomTexture = NULL ;
61
60 /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. 62 /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.
61 std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); 63 std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME));
62 LL_DEBUGS2("AppInit", "Shaders") << "Loading PostProcess Effects settings from " << pathName << LL_ENDL; 64 LL_DEBUGS2("AppInit", "Shaders") << "Loading PostProcess Effects settings from " << pathName << LL_ENDL;
@@ -110,9 +112,7 @@ LLPostProcess::LLPostProcess(void) :
110 112
111LLPostProcess::~LLPostProcess(void) 113LLPostProcess::~LLPostProcess(void)
112{ 114{
113 glDeleteTextures(1, &sceneRenderTexture); 115 invalidate() ;
114 glDeleteTextures(1, &noiseTexture);
115 glDeleteTextures(1, &tempBloomTexture);
116} 116}
117 117
118// static 118// static
@@ -157,6 +157,13 @@ void LLPostProcess::saveEffect(std::string const & effectName)
157 formatter->format(mAllEffects, effectsXML); 157 formatter->format(mAllEffects, effectsXML);
158 */ 158 */
159} 159}
160void LLPostProcess::invalidate()
161{
162 mSceneRenderTexture = NULL ;
163 mNoiseTexture = NULL ;
164 mTempBloomTexture = NULL ;
165 initialized = FALSE ;
166}
160 167
161void LLPostProcess::apply(unsigned int width, unsigned int height) 168void LLPostProcess::apply(unsigned int width, unsigned int height)
162{ 169{
@@ -172,7 +179,7 @@ void LLPostProcess::initialize(unsigned int width, unsigned int height)
172{ 179{
173 screenW = width; 180 screenW = width;
174 screenH = height; 181 screenH = height;
175 createTexture(sceneRenderTexture, screenW, screenH); 182 createTexture(mSceneRenderTexture, screenW, screenH);
176 initialized = true; 183 initialized = true;
177 184
178 checkError(); 185 checkError();
@@ -198,16 +205,20 @@ void LLPostProcess::applyShaders(void)
198 } 205 }
199 if (tweaks.useNightVisionShader()){ 206 if (tweaks.useNightVisionShader()){
200 /// If any of the above shaders have been called update the frame buffer; 207 /// If any of the above shaders have been called update the frame buffer;
201 if (tweaks.useColorFilter()){ 208 if (tweaks.useColorFilter())
202 copyFrameBuffer(sceneRenderTexture, screenW, screenH); 209 {
210 GLuint tex = mSceneRenderTexture->getTexName() ;
211 copyFrameBuffer(tex, screenW, screenH);
203 } 212 }
204 applyNightVisionShader(); 213 applyNightVisionShader();
205 checkError(); 214 checkError();
206 } 215 }
207 if (tweaks.useBloomShader()){ 216 if (tweaks.useBloomShader()){
208 /// If any of the above shaders have been called update the frame buffer; 217 /// If any of the above shaders have been called update the frame buffer;
209 if (tweaks.useColorFilter().asBoolean() || tweaks.useNightVisionShader().asBoolean()){ 218 if (tweaks.useColorFilter().asBoolean() || tweaks.useNightVisionShader().asBoolean())
210 copyFrameBuffer(sceneRenderTexture, screenW, screenH); 219 {
220 GLuint tex = mSceneRenderTexture->getTexName() ;
221 copyFrameBuffer(tex, screenW, screenH);
211 } 222 }
212 applyBloomShader(); 223 applyBloomShader();
213 checkError(); 224 checkError();
@@ -220,9 +231,9 @@ void LLPostProcess::applyColorFilterShader(void)
220 gPostColorFilterProgram.bind(); 231 gPostColorFilterProgram.bind();
221 232
222 gGL.getTexUnit(0)->activate(); 233 gGL.getTexUnit(0)->activate();
223 glEnable(GL_TEXTURE_RECTANGLE_ARB); 234 gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE);
224 235
225 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, sceneRenderTexture); 236 gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture);
226 237
227 getShaderUniforms(colorFilterUniforms, gPostColorFilterProgram.mProgramObject); 238 getShaderUniforms(colorFilterUniforms, gPostColorFilterProgram.mProgramObject);
228 glUniform1iARB(colorFilterUniforms["RenderTexture"], 0); 239 glUniform1iARB(colorFilterUniforms["RenderTexture"], 0);
@@ -264,16 +275,16 @@ void LLPostProcess::applyNightVisionShader(void)
264 gPostNightVisionProgram.bind(); 275 gPostNightVisionProgram.bind();
265 276
266 gGL.getTexUnit(0)->activate(); 277 gGL.getTexUnit(0)->activate();
267 glEnable(GL_TEXTURE_RECTANGLE_ARB); 278 gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE);
268 279
269 getShaderUniforms(nightVisionUniforms, gPostNightVisionProgram.mProgramObject); 280 getShaderUniforms(nightVisionUniforms, gPostNightVisionProgram.mProgramObject);
270 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, sceneRenderTexture); 281 gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture);
271 glUniform1iARB(nightVisionUniforms["RenderTexture"], 0); 282 glUniform1iARB(nightVisionUniforms["RenderTexture"], 0);
272 283
273 gGL.getTexUnit(1)->activate(); 284 gGL.getTexUnit(1)->activate();
274 glEnable(GL_TEXTURE_2D); 285 gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE);
275 286
276 glBindTexture(GL_TEXTURE_2D, noiseTexture); 287 gGL.getTexUnit(1)->bindManual(LLTexUnit::TT_TEXTURE, noiseTexture);
277 glUniform1iARB(nightVisionUniforms["NoiseTexture"], 1); 288 glUniform1iARB(nightVisionUniforms["NoiseTexture"], 1);
278 289
279 290
@@ -305,7 +316,7 @@ void LLPostProcess::createNightVisionShader(void)
305 nightVisionUniforms["noiseStrength"] = 0; 316 nightVisionUniforms["noiseStrength"] = 0;
306 nightVisionUniforms["lumWeights"] = 0; 317 nightVisionUniforms["lumWeights"] = 0;
307 318
308 createNoiseTexture(noiseTexture); 319 createNoiseTexture(mNoiseTexture);
309} 320}
310 321
311void LLPostProcess::applyBloomShader(void) 322void LLPostProcess::applyBloomShader(void)
@@ -315,7 +326,7 @@ void LLPostProcess::applyBloomShader(void)
315 326
316void LLPostProcess::createBloomShader(void) 327void LLPostProcess::createBloomShader(void)
317{ 328{
318 createTexture(tempBloomTexture, unsigned(screenW * 0.5), unsigned(screenH * 0.5)); 329 createTexture(mTempBloomTexture, unsigned(screenW * 0.5), unsigned(screenH * 0.5));
319 330
320 /// Create Bloom Extract Shader 331 /// Create Bloom Extract Shader
321 bloomExtractUniforms["RenderTexture"] = 0; 332 bloomExtractUniforms["RenderTexture"] = 0;
@@ -347,7 +358,10 @@ void LLPostProcess::doEffects(void)
347 glPushClientAttrib(GL_ALL_ATTRIB_BITS); 358 glPushClientAttrib(GL_ALL_ATTRIB_BITS);
348 359
349 /// Copy the screen buffer to the render texture 360 /// Copy the screen buffer to the render texture
350 copyFrameBuffer(sceneRenderTexture, screenW, screenH); 361 {
362 GLuint tex = mSceneRenderTexture->getTexName() ;
363 copyFrameBuffer(tex, screenW, screenH);
364 }
351 365
352 /// Clear the frame buffer. 366 /// Clear the frame buffer.
353 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 367 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
@@ -373,7 +387,7 @@ void LLPostProcess::doEffects(void)
373 387
374void LLPostProcess::copyFrameBuffer(GLuint & texture, unsigned int width, unsigned int height) 388void LLPostProcess::copyFrameBuffer(GLuint & texture, unsigned int width, unsigned int height)
375{ 389{
376 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture); 390 gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture);
377 glCopyTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 0, 0, width, height, 0); 391 glCopyTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 0, 0, width, height, 0);
378} 392}
379 393
@@ -478,43 +492,42 @@ void LLPostProcess::changeOrthogonal(unsigned int width, unsigned int height)
478 viewOrthogonal(width, height); 492 viewOrthogonal(width, height);
479} 493}
480 494
481void LLPostProcess::createTexture(GLuint & texture, unsigned int width, unsigned int height) 495void LLPostProcess::createTexture(LLPointer<LLImageGL>& texture, unsigned int width, unsigned int height)
482{ 496{
483 if (texture != 0){ 497 std::vector<GLubyte> data(width * height * 4, 0) ;
484 glDeleteTextures(1, &texture);
485 }
486 498
487 std::vector<GLubyte> data(width * height * 4, 0); 499 texture = new LLImageGL(FALSE) ;
488 500 if(texture->createGLTexture())
489 glGenTextures(1, &texture); 501 {
490 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture); 502 gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture->getTexName());
491 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, width, height, 0, 503 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, width, height, 0,
492 GL_RGBA, GL_UNSIGNED_BYTE, &data[0]); 504 GL_RGBA, GL_UNSIGNED_BYTE, &data[0]);
493 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_MIN_FILTER,GL_LINEAR); 505 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
494 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_MAG_FILTER,GL_LINEAR); 506 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
495 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 507 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
496 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 508 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
497}
498
499void LLPostProcess::createNoiseTexture(GLuint & texture)
500{
501 if (texture != 0){
502 glDeleteTextures(1, &texture);
503 } 509 }
504 glGenTextures(1, &texture); 510}
505 511
512void LLPostProcess::createNoiseTexture(LLPointer<LLImageGL>& texture)
513{
506 std::vector<GLubyte> buffer(NOISE_SIZE * NOISE_SIZE); 514 std::vector<GLubyte> buffer(NOISE_SIZE * NOISE_SIZE);
507 for (unsigned int i = 0; i < NOISE_SIZE; i++){ 515 for (unsigned int i = 0; i < NOISE_SIZE; i++){
508 for (unsigned int k = 0; k < NOISE_SIZE; k++){ 516 for (unsigned int k = 0; k < NOISE_SIZE; k++){
509 buffer[(i * NOISE_SIZE) + k] = (GLubyte)((double) rand() / ((double) RAND_MAX + 1.f) * 255.f); 517 buffer[(i * NOISE_SIZE) + k] = (GLubyte)((double) rand() / ((double) RAND_MAX + 1.f) * 255.f);
510 } 518 }
511 } 519 }
512 glBindTexture(GL_TEXTURE_2D, texture); 520
513 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, NOISE_SIZE, NOISE_SIZE, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, &buffer[0]); 521 texture = new LLImageGL(FALSE) ;
514 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR); 522 if(texture->createGLTexture())
515 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_LINEAR); 523 {
516 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 524 gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, texture->getTexName());
517 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 525 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, NOISE_SIZE, NOISE_SIZE, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, &buffer[0]);
526 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR);
527 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_LINEAR);
528 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
529 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
530 }
518} 531}
519 532
520bool LLPostProcess::checkError(void) 533bool LLPostProcess::checkError(void)
diff --git a/linden/indra/llrender/llpostprocess.h b/linden/indra/llrender/llpostprocess.h
index cd9f477..b191e9d 100644
--- a/linden/indra/llrender/llpostprocess.h
+++ b/linden/indra/llrender/llpostprocess.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2007&license=viewergpl$ 5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2007-2008, Linden Research, Inc. 7 * Copyright (c) 2007-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -183,21 +183,24 @@ public:
183 183
184 }; 184 };
185 185
186 GLuint sceneRenderTexture;
187 GLuint noiseTexture;
188 GLuint tempBloomTexture;
189 bool initialized; 186 bool initialized;
190 PostProcessTweaks tweaks; 187 PostProcessTweaks tweaks;
191 188
192 // the map of all availible effects 189 // the map of all availible effects
193 LLSD mAllEffects; 190 LLSD mAllEffects;
194 191
192private:
193 LLPointer<LLImageGL> mSceneRenderTexture ;
194 LLPointer<LLImageGL> mNoiseTexture ;
195 LLPointer<LLImageGL> mTempBloomTexture ;
196
195public: 197public:
196 LLPostProcess(void); 198 LLPostProcess(void);
197 199
198 ~LLPostProcess(void); 200 ~LLPostProcess(void);
199 201
200 void apply(unsigned int width, unsigned int height); 202 void apply(unsigned int width, unsigned int height);
203 void invalidate() ;
201 204
202 /// Perform global initialization for this class. 205 /// Perform global initialization for this class.
203 static void initClass(void); 206 static void initClass(void);
@@ -251,9 +254,9 @@ private:
251 254
252 /// OpenGL Helper Functions 255 /// OpenGL Helper Functions
253 void getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog); 256 void getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog);
254 void createTexture(GLuint & texture, unsigned int width, unsigned int height); 257 void createTexture(LLPointer<LLImageGL>& texture, unsigned int width, unsigned int height);
255 void copyFrameBuffer(GLuint & texture, unsigned int width, unsigned int height); 258 void copyFrameBuffer(GLuint & texture, unsigned int width, unsigned int height);
256 void createNoiseTexture(GLuint & texture); 259 void createNoiseTexture(LLPointer<LLImageGL>& texture);
257 bool checkError(void); 260 bool checkError(void);
258 void checkShaderError(GLhandleARB shader); 261 void checkShaderError(GLhandleARB shader);
259 void drawOrthoQuad(unsigned int width, unsigned int height, QuadType type); 262 void drawOrthoQuad(unsigned int width, unsigned int height, QuadType type);
diff --git a/linden/indra/llrender/llrender.cpp b/linden/indra/llrender/llrender.cpp
index 7be06af..ff0a2db 100644
--- a/linden/indra/llrender/llrender.cpp
+++ b/linden/indra/llrender/llrender.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -32,7 +32,11 @@
32#include "linden_common.h" 32#include "linden_common.h"
33 33
34#include "llrender.h" 34#include "llrender.h"
35
35#include "llvertexbuffer.h" 36#include "llvertexbuffer.h"
37#include "llcubemap.h"
38#include "llimagegl.h"
39#include "llrendertarget.h"
36 40
37LLRender gGL; 41LLRender gGL;
38 42
@@ -44,6 +48,20 @@ S32 gGLViewport[4];
44 48
45static const U32 LL_NUM_TEXTURE_LAYERS = 8; 49static const U32 LL_NUM_TEXTURE_LAYERS = 8;
46 50
51static GLenum sGLTextureType[] =
52{
53 GL_TEXTURE_2D,
54 GL_TEXTURE_RECTANGLE_ARB,
55 GL_TEXTURE_CUBE_MAP_ARB
56};
57
58static GLint sGLAddressMode[] =
59{
60 GL_REPEAT,
61 GL_MIRRORED_REPEAT,
62 GL_CLAMP_TO_EDGE
63};
64
47static GLenum sGLCompareFunc[] = 65static GLenum sGLCompareFunc[] =
48{ 66{
49 GL_NEVER, 67 GL_NEVER,
@@ -72,82 +90,213 @@ static GLenum sGLBlendFactor[] =
72 GL_ONE_MINUS_SRC_ALPHA 90 GL_ONE_MINUS_SRC_ALPHA
73}; 91};
74 92
75LLTexUnit::LLTexUnit(U32 index) 93LLTexUnit::LLTexUnit(S32 index)
76: mIsEnabled(false), mCurrBlendType(TB_MULT), 94: mCurrTexType(TT_NONE), mCurrBlendType(TB_MULT),
77mCurrColorOp(TBO_MULT), mCurrAlphaOp(TBO_MULT), 95mCurrColorOp(TBO_MULT), mCurrAlphaOp(TBO_MULT),
78mCurrColorSrc1(TBS_TEX_COLOR), mCurrColorSrc2(TBS_PREV_COLOR), 96mCurrColorSrc1(TBS_TEX_COLOR), mCurrColorSrc2(TBS_PREV_COLOR),
79mCurrAlphaSrc1(TBS_TEX_ALPHA), mCurrAlphaSrc2(TBS_PREV_ALPHA), 97mCurrAlphaSrc1(TBS_TEX_ALPHA), mCurrAlphaSrc2(TBS_PREV_ALPHA),
80mCurrColorScale(1), mCurrAlphaScale(1) 98mCurrColorScale(1), mCurrAlphaScale(1), mCurrTexture(0)
81{ 99{
82 llassert_always(index < LL_NUM_TEXTURE_LAYERS); 100 llassert_always(index < LL_NUM_TEXTURE_LAYERS);
83 mIndex = index; 101 mIndex = index;
84} 102}
85 103
86U32 LLTexUnit::getIndex(void) 104//static
105U32 LLTexUnit::getInternalType(eTextureType type)
106{
107 return sGLTextureType[type];
108}
109
110void LLTexUnit::refreshState(void)
111{
112 // We set dirty to true so that the tex unit knows to ignore caching
113 // and we reset the cached tex unit state
114
115 glActiveTextureARB(GL_TEXTURE0_ARB + mIndex);
116 if (mCurrTexType != TT_NONE)
117 {
118 glEnable(sGLTextureType[mCurrTexType]);
119 glBindTexture(sGLTextureType[mCurrTexType], mCurrTexture);
120 }
121 else
122 {
123 glDisable(GL_TEXTURE_2D);
124 glBindTexture(GL_TEXTURE_2D, 0);
125 }
126
127 if (mCurrBlendType != TB_COMBINE)
128 {
129 setTextureBlendType(mCurrBlendType);
130 }
131 else
132 {
133 setTextureCombiner(mCurrColorOp, mCurrColorSrc1, mCurrColorSrc2, false);
134 setTextureCombiner(mCurrAlphaOp, mCurrAlphaSrc1, mCurrAlphaSrc2, true);
135 }
136}
137
138void LLTexUnit::activate(void)
87{ 139{
88 return mIndex; 140 if (mIndex < 0) return;
141
142 if (gGL.mCurrTextureUnitIndex != mIndex || gGL.mDirty)
143 {
144 glActiveTextureARB(GL_TEXTURE0_ARB + mIndex);
145 gGL.mCurrTextureUnitIndex = mIndex;
146 }
89} 147}
90 148
91void LLTexUnit::enable(void) 149void LLTexUnit::enable(eTextureType type)
92{ 150{
93 if (!mIsEnabled) 151 if (mIndex < 0) return;
152
153 if ( (mCurrTexType != type || gGL.mDirty) && (type != TT_NONE) )
94 { 154 {
95 activate(); 155 activate();
96 glEnable(GL_TEXTURE_2D); 156 if (mCurrTexType != TT_NONE && !gGL.mDirty)
97 mIsEnabled = true; 157 {
158 disable(); // Force a disable of a previous texture type if it's enabled.
159 }
160 mCurrTexType = type;
161 glEnable(sGLTextureType[type]);
98 } 162 }
99} 163}
100 164
101void LLTexUnit::disable(void) 165void LLTexUnit::disable(void)
102{ 166{
103 if (mIsEnabled) 167 if (mIndex < 0) return;
168
169 if (mCurrTexType != TT_NONE)
104 { 170 {
105 activate(); 171 activate();
106 glDisable(GL_TEXTURE_2D); 172 unbind(mCurrTexType);
107 mIsEnabled = false; 173 glDisable(sGLTextureType[mCurrTexType]);
174 mCurrTexType = TT_NONE;
108 } 175 }
109} 176}
110 177
111void LLTexUnit::activate(void) 178bool LLTexUnit::bind(const LLImageGL* texture, bool forceBind)
112{ 179{
113 //if (gGL.mCurrTextureUnitIndex != mIndex) 180 if (mIndex < 0) return false;
181
182 gGL.flush();
183
184 if (texture == NULL)
114 { 185 {
115 glActiveTextureARB(GL_TEXTURE0_ARB + mIndex); 186 llwarns << "NULL LLTexUnit::bind texture" << llendl;
116 gGL.mCurrTextureUnitIndex = mIndex; 187 return false;
188 }
189
190 if (!texture->getTexName()) //if texture does not exist
191 {
192 return texture->bindDefaultImage(mIndex);
117 } 193 }
194 // Disabled caching of binding state.
195 activate();
196 enable(texture->getTarget());
197 mCurrTexture = texture->getTexName();
198 glBindTexture(sGLTextureType[texture->getTarget()], mCurrTexture);
199 texture->updateBindStats();
200 return true;
118} 201}
119 202
120// Useful for debugging that you've manually assigned a texture operation to the correct 203bool LLTexUnit::bind(LLCubeMap* cubeMap)
121// texture unit based on the currently set active texture in opengl.
122void LLTexUnit::debugTextureUnit(void)
123{ 204{
124 GLint activeTexture; 205 if (mIndex < 0) return false;
125 glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &activeTexture); 206
126 if ((GL_TEXTURE0_ARB + mIndex) != activeTexture) 207 gGL.flush();
208
209 // Disabled caching of binding state.
210 if (cubeMap != NULL)
127 { 211 {
128 llerrs << "Incorrect Texture Unit! Expected: " << (activeTexture - GL_TEXTURE0_ARB) << " Actual: " << mIndex << llendl; 212 if (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps)
213 {
214 activate();
215 enable(LLTexUnit::TT_CUBE_MAP);
216 mCurrTexture = cubeMap->mImages[0]->getTexName();
217 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mCurrTexture);
218 cubeMap->mImages[0]->updateBindStats();
219 cubeMap->mImages[0]->setMipFilterNearest (FALSE, FALSE);
220 return true;
221 }
222 else
223 {
224 llwarns << "Using cube map without extension!" << llendl
225 }
129 } 226 }
227 return false;
130} 228}
131 229
132void LLTexUnit::bindTexture(const LLImageGL* texture) 230bool LLTexUnit::bind(LLRenderTarget* renderTarget, bool bindDepth)
133{ 231{
134 if (texture != NULL) 232 if (mIndex < 0) return false;
233
234 gGL.flush();
235
236 if (bindDepth)
135 { 237 {
136 activate(); 238 bindManual(renderTarget->getUsage(), renderTarget->getDepth());
137 texture->bind(mIndex);
138 } 239 }
240 else
241 {
242 bindManual(renderTarget->getUsage(), renderTarget->getTexture());
243 }
244
245 return true;
139} 246}
140 247
141void LLTexUnit::unbindTexture(void) 248bool LLTexUnit::bindManual(eTextureType type, U32 texture)
142{ 249{
250 if (mIndex < 0) return false;
251
252 // Disabled caching of binding state.
253 gGL.flush();
254
143 activate(); 255 activate();
144 glBindTexture(GL_TEXTURE_2D, 0); 256 enable(type);
257 mCurrTexture = texture;
258 glBindTexture(sGLTextureType[type], texture);
259 return true;
260}
261
262void LLTexUnit::unbind(eTextureType type)
263{
264 if (mIndex < 0) return;
265
266 // Disabled caching of binding state.
267 if (mCurrTexType == type)
268 {
269 gGL.flush();
270
271 activate();
272 mCurrTexture = 0;
273 glBindTexture(sGLTextureType[type], 0);
274 }
275}
276
277void LLTexUnit::setTextureAddressMode(eTextureAddressMode mode)
278{
279 if (mIndex < 0) return;
280
281 if (true)
282 {
283 activate();
284
285 glTexParameteri (sGLTextureType[mCurrTexType], GL_TEXTURE_WRAP_S, sGLAddressMode[mode]);
286 glTexParameteri (sGLTextureType[mCurrTexType], GL_TEXTURE_WRAP_T, sGLAddressMode[mode]);
287 if (mCurrTexType == TT_CUBE_MAP)
288 {
289 glTexParameteri (GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, sGLAddressMode[mode]);
290 }
291 }
145} 292}
146 293
147void LLTexUnit::setTextureBlendType(eTextureBlendType type) 294void LLTexUnit::setTextureBlendType(eTextureBlendType type)
148{ 295{
296 if (mIndex < 0) return;
297
149 // Do nothing if it's already correctly set. 298 // Do nothing if it's already correctly set.
150 if (mCurrBlendType == type) 299 if (mCurrBlendType == type && !gGL.mDirty)
151 { 300 {
152 return; 301 return;
153 } 302 }
@@ -262,16 +411,18 @@ GLint LLTexUnit::getTextureSourceType(eTextureBlendSrc src, bool isAlpha)
262 411
263void LLTexUnit::setTextureCombiner(eTextureBlendOp op, eTextureBlendSrc src1, eTextureBlendSrc src2, bool isAlpha) 412void LLTexUnit::setTextureCombiner(eTextureBlendOp op, eTextureBlendSrc src1, eTextureBlendSrc src2, bool isAlpha)
264{ 413{
414 if (mIndex < 0) return;
415
265 activate(); 416 activate();
266 if (mCurrBlendType != TB_COMBINE) 417 if (mCurrBlendType != TB_COMBINE || gGL.mDirty)
267 { 418 {
268 mCurrBlendType = TB_COMBINE; 419 mCurrBlendType = TB_COMBINE;
269 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); 420 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
270 } 421 }
271 422
272 // We want an early out, because this function does a LOT of stuff. 423 // We want an early out, because this function does a LOT of stuff.
273 if ( (isAlpha && (mCurrAlphaOp == op) && (mCurrAlphaSrc1 == src1) && (mCurrAlphaSrc2 == src2) ) 424 if ( ( (isAlpha && (mCurrAlphaOp == op) && (mCurrAlphaSrc1 == src1) && (mCurrAlphaSrc2 == src2))
274 || (!isAlpha && (mCurrColorOp == op) && (mCurrColorSrc1 == src1) && (mCurrColorSrc2 == src2) )) 425 || (!isAlpha && (mCurrColorOp == op) && (mCurrColorSrc1 == src1) && (mCurrColorSrc2 == src2)) ) && !gGL.mDirty)
275 { 426 {
276 return; 427 return;
277 } 428 }
@@ -304,7 +455,7 @@ void LLTexUnit::setTextureCombiner(eTextureBlendOp op, eTextureBlendSrc src1, eT
304 } 455 }
305 else 456 else
306 { 457 {
307 // Set enums to ALPHA ones 458 // Set enums to RGB ones
308 comb_enum = GL_COMBINE_RGB_ARB; 459 comb_enum = GL_COMBINE_RGB_ARB;
309 src0_enum = GL_SOURCE0_RGB_ARB; 460 src0_enum = GL_SOURCE0_RGB_ARB;
310 src1_enum = GL_SOURCE1_RGB_ARB; 461 src1_enum = GL_SOURCE1_RGB_ARB;
@@ -405,7 +556,7 @@ void LLTexUnit::setTextureCombiner(eTextureBlendOp op, eTextureBlendSrc src1, eT
405 556
406void LLTexUnit::setColorScale(S32 scale) 557void LLTexUnit::setColorScale(S32 scale)
407{ 558{
408 if (mCurrColorScale != scale) 559 if (mCurrColorScale != scale || gGL.mDirty)
409 { 560 {
410 mCurrColorScale = scale; 561 mCurrColorScale = scale;
411 glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE, scale ); 562 glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE, scale );
@@ -414,27 +565,52 @@ void LLTexUnit::setColorScale(S32 scale)
414 565
415void LLTexUnit::setAlphaScale(S32 scale) 566void LLTexUnit::setAlphaScale(S32 scale)
416{ 567{
417 if (mCurrAlphaScale != scale) 568 if (mCurrAlphaScale != scale || gGL.mDirty)
418 { 569 {
419 mCurrAlphaScale = scale; 570 mCurrAlphaScale = scale;
420 glTexEnvi( GL_TEXTURE_ENV, GL_ALPHA_SCALE, scale ); 571 glTexEnvi( GL_TEXTURE_ENV, GL_ALPHA_SCALE, scale );
421 } 572 }
422} 573}
423 574
575// Useful for debugging that you've manually assigned a texture operation to the correct
576// texture unit based on the currently set active texture in opengl.
577void LLTexUnit::debugTextureUnit(void)
578{
579 if (mIndex < 0) return;
580
581 GLint activeTexture;
582 glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &activeTexture);
583 if ((GL_TEXTURE0_ARB + mIndex) != activeTexture)
584 {
585 U32 set_unit = (activeTexture - GL_TEXTURE0_ARB);
586 llwarns << "Incorrect Texture Unit! Expected: " << set_unit << " Actual: " << mIndex << llendl;
587 }
588}
589
590
424LLRender::LLRender() 591LLRender::LLRender()
592: mDirty(false), mCount(0), mMode(LLRender::TRIANGLES)
425{ 593{
426 mCount = 0;
427 mMode = LLVertexBuffer::TRIANGLES;
428 mBuffer = new LLVertexBuffer(immediate_mask, 0); 594 mBuffer = new LLVertexBuffer(immediate_mask, 0);
429 mBuffer->allocateBuffer(4096, 0, TRUE); 595 mBuffer->allocateBuffer(4096, 0, TRUE);
430 mBuffer->getVertexStrider(mVerticesp); 596 mBuffer->getVertexStrider(mVerticesp);
431 mBuffer->getTexCoordStrider(mTexcoordsp); 597 mBuffer->getTexCoordStrider(mTexcoordsp);
432 mBuffer->getColorStrider(mColorsp); 598 mBuffer->getColorStrider(mColorsp);
433 599
434 for (unsigned int i = 0; i < LL_NUM_TEXTURE_LAYERS; i++) 600 mTexUnits.reserve(LL_NUM_TEXTURE_LAYERS);
601 for (U32 i = 0; i < LL_NUM_TEXTURE_LAYERS; i++)
435 { 602 {
436 mTexUnits.push_back(new LLTexUnit(i)); 603 mTexUnits.push_back(new LLTexUnit(i));
437 } 604 }
605 mDummyTexUnit = new LLTexUnit(-1);
606
607 for (U32 i = 0; i < 4; i++)
608 {
609 mCurrColorMask[i] = true;
610 }
611
612 mCurrAlphaFunc = CF_DEFAULT;
613 mCurrAlphaFuncVal = 0.01f;
438} 614}
439 615
440LLRender::~LLRender() 616LLRender::~LLRender()
@@ -449,6 +625,28 @@ void LLRender::shutdown()
449 delete mTexUnits[i]; 625 delete mTexUnits[i];
450 } 626 }
451 mTexUnits.clear(); 627 mTexUnits.clear();
628 delete mDummyTexUnit;
629 mDummyTexUnit = NULL;
630}
631
632void LLRender::refreshState(void)
633{
634 mDirty = true;
635
636 U32 active_unit = mCurrTextureUnitIndex;
637
638 for (U32 i = 0; i < mTexUnits.size(); i++)
639 {
640 mTexUnits[i]->refreshState();
641 }
642
643 mTexUnits[active_unit]->activate();
644
645 setColorMask(mCurrColorMask[0], mCurrColorMask[1], mCurrColorMask[2], mCurrColorMask[3]);
646
647 setAlphaRejectSettings(mCurrAlphaFunc, mCurrAlphaFuncVal);
648
649 mDirty = false;
452} 650}
453 651
454void LLRender::translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z) 652void LLRender::translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z)
@@ -483,6 +681,12 @@ void LLRender::setColorMask(bool writeColor, bool writeAlpha)
483void LLRender::setColorMask(bool writeColorR, bool writeColorG, bool writeColorB, bool writeAlpha) 681void LLRender::setColorMask(bool writeColorR, bool writeColorG, bool writeColorB, bool writeAlpha)
484{ 682{
485 flush(); 683 flush();
684
685 mCurrColorMask[0] = writeColorR;
686 mCurrColorMask[1] = writeColorG;
687 mCurrColorMask[2] = writeColorB;
688 mCurrColorMask[3] = writeAlpha;
689
486 glColorMask(writeColorR, writeColorG, writeColorB, writeAlpha); 690 glColorMask(writeColorR, writeColorG, writeColorB, writeAlpha);
487} 691}
488 692
@@ -518,6 +722,9 @@ void LLRender::setSceneBlendType(eBlendType type)
518void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value) 722void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value)
519{ 723{
520 flush(); 724 flush();
725
726 mCurrAlphaFunc = func;
727 mCurrAlphaFuncVal = value;
521 if (func == CF_DEFAULT) 728 if (func == CF_DEFAULT)
522 { 729 {
523 glAlphaFunc(GL_GREATER, 0.01f); 730 glAlphaFunc(GL_GREATER, 0.01f);
@@ -536,22 +743,38 @@ void LLRender::blendFunc(eBlendFactor sfactor, eBlendFactor dfactor)
536 743
537LLTexUnit* LLRender::getTexUnit(U32 index) 744LLTexUnit* LLRender::getTexUnit(U32 index)
538{ 745{
539 if (index < mTexUnits.size()) 746 if ((index >= 0) && (index < mTexUnits.size()))
540 { 747 {
541 return mTexUnits[index]; 748 return mTexUnits[index];
542 } 749 }
543 llerrs << "Non-existing texture unit layer requested: " << index << llendl; 750 else
544 return NULL; 751 {
752 lldebugs << "Non-existing texture unit layer requested: " << index << llendl;
753 return mDummyTexUnit;
754 }
755}
756
757bool LLRender::verifyTexUnitActive(U32 unitToVerify)
758{
759 if (mCurrTextureUnitIndex == unitToVerify)
760 {
761 return true;
762 }
763 else
764 {
765 llwarns << "TexUnit currently active: " << mCurrTextureUnitIndex << " (expecting " << unitToVerify << ")" << llendl;
766 return false;
767 }
545} 768}
546 769
547void LLRender::begin(const GLuint& mode) 770void LLRender::begin(const GLuint& mode)
548{ 771{
549 if (mode != mMode) 772 if (mode != mMode)
550 { 773 {
551 if (mMode == LLVertexBuffer::QUADS || 774 if (mMode == LLRender::QUADS ||
552 mMode == LLVertexBuffer::LINES || 775 mMode == LLRender::LINES ||
553 mMode == LLVertexBuffer::TRIANGLES || 776 mMode == LLRender::TRIANGLES ||
554 mMode == LLVertexBuffer::POINTS) 777 mMode == LLRender::POINTS)
555 { 778 {
556 flush(); 779 flush();
557 } 780 }
@@ -572,10 +795,10 @@ void LLRender::end()
572 //IMM_ERRS << "GL begin and end called with no vertices specified." << llendl; 795 //IMM_ERRS << "GL begin and end called with no vertices specified." << llendl;
573 } 796 }
574 797
575 if ((mMode != LLVertexBuffer::QUADS && 798 if ((mMode != LLRender::QUADS &&
576 mMode != LLVertexBuffer::LINES && 799 mMode != LLRender::LINES &&
577 mMode != LLVertexBuffer::TRIANGLES && 800 mMode != LLRender::TRIANGLES &&
578 mMode != LLVertexBuffer::POINTS) || 801 mMode != LLRender::POINTS) ||
579 mCount > 2048) 802 mCount > 2048)
580 { 803 {
581 flush(); 804 flush();
@@ -638,7 +861,8 @@ void LLRender::flush()
638} 861}
639void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z) 862void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z)
640{ 863{
641 if (mCount >= 4096) 864 //the range of mVerticesp, mColorsp and mTexcoordsp is [0, 4095]
865 if (mCount > 4094)
642 { 866 {
643 // llwarns << "GL immediate mode overflow. Some geometry not drawn." << llendl; 867 // llwarns << "GL immediate mode overflow. Some geometry not drawn." << llendl;
644 return; 868 return;
@@ -720,3 +944,35 @@ void LLRender::color3fv(const GLfloat* c)
720 color4f(c[0],c[1],c[2],1); 944 color4f(c[0],c[1],c[2],1);
721} 945}
722 946
947void LLRender::debugTexUnits(void)
948{
949 LL_INFOS("TextureUnit") << "Active TexUnit: " << mCurrTextureUnitIndex << LL_ENDL;
950 std::string active_enabled = "false";
951 for (U32 i = 0; i < mTexUnits.size(); i++)
952 {
953 if (getTexUnit(i)->mCurrTexType != LLTexUnit::TT_NONE)
954 {
955 if (i == mCurrTextureUnitIndex) active_enabled = "true";
956 LL_INFOS("TextureUnit") << "TexUnit: " << i << " Enabled" << LL_ENDL;
957 LL_INFOS("TextureUnit") << "Enabled As: " ;
958 switch (getTexUnit(i)->mCurrTexType)
959 {
960 case LLTexUnit::TT_TEXTURE:
961 LL_CONT << "Texture 2D";
962 break;
963 case LLTexUnit::TT_RECT_TEXTURE:
964 LL_CONT << "Texture Rectangle";
965 break;
966 case LLTexUnit::TT_CUBE_MAP:
967 LL_CONT << "Cube Map";
968 break;
969 default:
970 LL_CONT << "ARGH!!! NONE!";
971 break;
972 }
973 LL_CONT << ", Texture Bound: " << getTexUnit(i)->mCurrTexture << LL_ENDL;
974 }
975 }
976 LL_INFOS("TextureUnit") << "Active TexUnit Enabled : " << active_enabled << LL_ENDL;
977}
978
diff --git a/linden/indra/llrender/llrender.h b/linden/indra/llrender/llrender.h
index ef495ed..e949190 100644
--- a/linden/indra/llrender/llrender.h
+++ b/linden/indra/llrender/llrender.h
@@ -9,7 +9,7 @@
9 * 9 *
10 * $LicenseInfo:firstyear=2001&license=viewergpl$ 10 * $LicenseInfo:firstyear=2001&license=viewergpl$
11 * 11 *
12 * Copyright (c) 2001-2008, Linden Research, Inc. 12 * Copyright (c) 2001-2009, Linden Research, Inc.
13 * 13 *
14 * Second Life Viewer Source Code 14 * Second Life Viewer Source Code
15 * The source code in this file ("Source Code") is provided by Linden Lab 15 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -37,14 +37,39 @@
37#ifndef LL_LLGLRENDER_H 37#ifndef LL_LLGLRENDER_H
38#define LL_LLGLRENDER_H 38#define LL_LLGLRENDER_H
39 39
40#include "stdtypes.h" 40//#include "linden_common.h"
41#include "llgltypes.h" 41
42#include "v2math.h"
43#include "v3math.h"
44#include "v4coloru.h"
45#include "llstrider.h"
46#include "llmemory.h"
42#include "llglheaders.h" 47#include "llglheaders.h"
43#include "llvertexbuffer.h" 48
49class LLVertexBuffer;
50class LLCubeMap;
51class LLImageGL;
52class LLRenderTarget;
44 53
45class LLTexUnit 54class LLTexUnit
46{ 55{
56 friend class LLRender;
47public: 57public:
58 typedef enum
59 {
60 TT_TEXTURE = 0, // Standard 2D Texture
61 TT_RECT_TEXTURE, // Non power of 2 texture
62 TT_CUBE_MAP, // 6-sided cube map texture
63 TT_NONE // No texture type is currently enabled
64 } eTextureType;
65
66 typedef enum
67 {
68 TAM_WRAP = 0, // Standard 2D Texture
69 TAM_MIRROR, // Non power of 2 texture
70 TAM_CLAMP // No texture type is currently enabled
71 } eTextureAddressMode;
72
48 typedef enum 73 typedef enum
49 { 74 {
50 TB_REPLACE = 0, 75 TB_REPLACE = 0,
@@ -93,15 +118,41 @@ public:
93 TBS_ONE_MINUS_CONST_ALPHA 118 TBS_ONE_MINUS_CONST_ALPHA
94 } eTextureBlendSrc; 119 } eTextureBlendSrc;
95 120
96 LLTexUnit(U32 index); 121 LLTexUnit(S32 index);
97 U32 getIndex(void);
98 122
99 void enable(void); 123 // Refreshes renderer state of the texture unit to the cached values
100 void disable(void); 124 // Needed when the render context has changed and invalidated the current state
101 void activate(void); 125 void refreshState(void);
102 126
103 void bindTexture(const LLImageGL* texture); 127 // returns the index of this texture unit
104 void unbindTexture(void); 128 S32 getIndex(void) const { return mIndex; }
129
130 // Sets this tex unit to be the currently active one
131 void activate(void);
132
133 // Enables this texture unit for the given texture type (automatically disables any previously enabled texture type)
134 void enable(eTextureType type);
135 // Disables the current texture unit
136 void disable(void);
137
138 // Binds the LLImageGL to this texture unit
139 // (automatically enables the unit for the LLImageGL's texture type)
140 bool bind(const LLImageGL* texture, bool forceBind = false);
141
142 // Binds a cubemap to this texture unit
143 // (automatically enables the texture unit for cubemaps)
144 bool bind(LLCubeMap* cubeMap);
145
146 // Binds a render target to this texture unit (automatically enables the texture unit for the RT's texture type)
147 bool bind(LLRenderTarget * renderTarget, bool bindDepth = false);
148
149 // Manually binds a texture to the texture unit (automatically enables the tex unit for the given texture type)
150 bool bindManual(eTextureType type, U32 texture);
151
152 // Unbinds the currently bound texture of the given type (only if there's a texture of the given type currently bound)
153 void unbind(eTextureType type);
154
155 void setTextureAddressMode(eTextureAddressMode mode);
105 156
106 void setTextureBlendType(eTextureBlendType type); 157 void setTextureBlendType(eTextureBlendType type);
107 158
@@ -110,11 +161,14 @@ public:
110 161
111 // NOTE: If *_COLOR enums are passed to src1 or src2, the corresponding *_ALPHA enum will be used instead. 162 // NOTE: If *_COLOR enums are passed to src1 or src2, the corresponding *_ALPHA enum will be used instead.
112 inline void setTextureAlphaBlend(eTextureBlendOp op, eTextureBlendSrc src1, eTextureBlendSrc src2 = TBS_PREV_ALPHA) 163 inline void setTextureAlphaBlend(eTextureBlendOp op, eTextureBlendSrc src1, eTextureBlendSrc src2 = TBS_PREV_ALPHA)
113 { setTextureCombiner(op, src1, src2, true); } 164 { setTextureCombiner(op, src1, src2, true); }
114 165
115private: 166 static U32 getInternalType(eTextureType type);
116 U32 mIndex; 167
117 bool mIsEnabled; 168protected:
169 S32 mIndex;
170 U32 mCurrTexture;
171 eTextureType mCurrTexType;
118 eTextureBlendType mCurrBlendType; 172 eTextureBlendType mCurrBlendType;
119 eTextureBlendOp mCurrColorOp; 173 eTextureBlendOp mCurrColorOp;
120 eTextureBlendSrc mCurrColorSrc1; 174 eTextureBlendSrc mCurrColorSrc1;
@@ -137,6 +191,19 @@ class LLRender
137{ 191{
138 friend class LLTexUnit; 192 friend class LLTexUnit;
139public: 193public:
194
195 typedef enum {
196 TRIANGLES = 0,
197 TRIANGLE_STRIP,
198 TRIANGLE_FAN,
199 POINTS,
200 LINES,
201 LINE_STRIP,
202 QUADS,
203 LINE_LOOP,
204 NUM_MODES
205 } eGeomModes;
206
140 typedef enum 207 typedef enum
141 { 208 {
142 CF_NEVER = 0, 209 CF_NEVER = 0,
@@ -178,6 +245,10 @@ public:
178 ~LLRender(); 245 ~LLRender();
179 void shutdown(); 246 void shutdown();
180 247
248 // Refreshes renderer state to the cached values
249 // Needed when the render context has changed and invalidated the current state
250 void refreshState(void);
251
181 void translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z); 252 void translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z);
182 void scalef(const GLfloat& x, const GLfloat& y, const GLfloat& z); 253 void scalef(const GLfloat& x, const GLfloat& y, const GLfloat& z);
183 void pushMatrix(); 254 void pushMatrix();
@@ -214,6 +285,12 @@ public:
214 285
215 LLTexUnit* getTexUnit(U32 index); 286 LLTexUnit* getTexUnit(U32 index);
216 287
288 U32 getCurrentTexUnitIndex(void) const { return mCurrTextureUnitIndex; }
289
290 bool verifyTexUnitActive(U32 unitToVerify);
291
292 void debugTexUnits(void);
293
217 struct Vertex 294 struct Vertex
218 { 295 {
219 GLfloat v[3]; 296 GLfloat v[3];
@@ -224,14 +301,20 @@ public:
224public: 301public:
225 302
226private: 303private:
227 U32 mCount; 304 bool mDirty;
228 U32 mMode; 305 U32 mCount;
229 U32 mCurrTextureUnitIndex; 306 U32 mMode;
230 LLPointer<LLVertexBuffer> mBuffer; 307 U32 mCurrTextureUnitIndex;
231 LLStrider<LLVector3> mVerticesp; 308 bool mCurrColorMask[4];
232 LLStrider<LLVector2> mTexcoordsp; 309 eCompareFunc mCurrAlphaFunc;
233 LLStrider<LLColor4U> mColorsp; 310 F32 mCurrAlphaFuncVal;
234 std::vector<LLTexUnit*> mTexUnits; 311
312 LLPointer<LLVertexBuffer> mBuffer;
313 LLStrider<LLVector3> mVerticesp;
314 LLStrider<LLVector2> mTexcoordsp;
315 LLStrider<LLColor4U> mColorsp;
316 std::vector<LLTexUnit*> mTexUnits;
317 LLTexUnit* mDummyTexUnit;
235}; 318};
236 319
237extern F64 gGLModelView[16]; 320extern F64 gGLModelView[16];
diff --git a/linden/indra/llrender/llrendersphere.cpp b/linden/indra/llrender/llrendersphere.cpp
index 0c3cd19..6aaa03e 100644
--- a/linden/indra/llrender/llrendersphere.cpp
+++ b/linden/indra/llrender/llrendersphere.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
diff --git a/linden/indra/llrender/llrendersphere.h b/linden/indra/llrender/llrendersphere.h
index ace57e4..d48b917 100644
--- a/linden/indra/llrender/llrendersphere.h
+++ b/linden/indra/llrender/llrendersphere.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=internal$ 5 * $LicenseInfo:firstyear=2001&license=internal$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of 9 * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of
10 * this source code is governed by the Linden Lab Source Code Disclosure 10 * this source code is governed by the Linden Lab Source Code Disclosure
diff --git a/linden/indra/llrender/llrendertarget.cpp b/linden/indra/llrender/llrendertarget.cpp
index e18ec56..392ec24 100644
--- a/linden/indra/llrender/llrendertarget.cpp
+++ b/linden/indra/llrender/llrendertarget.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -47,7 +47,7 @@ LLRenderTarget::LLRenderTarget() :
47 mStencil(0), 47 mStencil(0),
48 mUseDepth(FALSE), 48 mUseDepth(FALSE),
49 mRenderDepth(FALSE), 49 mRenderDepth(FALSE),
50 mUsage(GL_TEXTURE_2D) 50 mUsage(LLTexUnit::TT_TEXTURE)
51{ 51{
52} 52}
53 53
@@ -56,7 +56,7 @@ LLRenderTarget::~LLRenderTarget()
56 release(); 56 release();
57} 57}
58 58
59void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage, BOOL use_fbo) 59void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, LLTexUnit::eTextureType usage, BOOL use_fbo)
60{ 60{
61 stop_glerror(); 61 stop_glerror();
62 mResX = resx; 62 mResX = resx;
@@ -67,22 +67,22 @@ void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32
67 release(); 67 release();
68 68
69 glGenTextures(1, (GLuint *) &mTex); 69 glGenTextures(1, (GLuint *) &mTex);
70 glBindTexture(mUsage, mTex); 70 gGL.getTexUnit(0)->bindManual(mUsage, mTex);
71 glTexImage2D(mUsage, 0, color_fmt, mResX, mResY, 0, color_fmt, GL_UNSIGNED_BYTE, NULL); 71 glTexImage2D(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, 0, color_fmt, GL_UNSIGNED_BYTE, NULL);
72 72
73 glTexParameteri(mUsage, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 73 glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_MAG_FILTER, GL_LINEAR);
74 glTexParameteri(mUsage, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 74 glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_MIN_FILTER, GL_LINEAR);
75 75
76 if (mUsage != GL_TEXTURE_RECTANGLE_ARB) 76 if (mUsage != LLTexUnit::TT_RECT_TEXTURE)
77 { 77 {
78 glTexParameteri(mUsage, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); 78 glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
79 glTexParameteri(mUsage, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); 79 glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
80 } 80 }
81 else 81 else
82 { 82 {
83 // ATI doesn't support mirrored repeat for rectangular textures. 83 // ATI doesn't support mirrored repeat for rectangular textures.
84 glTexParameteri(mUsage, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 84 glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
85 glTexParameteri(mUsage, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 85 glTexParameteri(LLTexUnit::getInternalType(mUsage), GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
86 } 86 }
87 87
88 stop_glerror(); 88 stop_glerror();
@@ -107,14 +107,14 @@ void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32
107 107
108 if (mDepth) 108 if (mDepth)
109 { 109 {
110 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, mUsage, mDepth, 0); 110 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, LLTexUnit::getInternalType(mUsage), mDepth, 0);
111 stop_glerror(); 111 stop_glerror();
112 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, mUsage, mDepth, 0); 112 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, LLTexUnit::getInternalType(mUsage), mDepth, 0);
113 stop_glerror(); 113 stop_glerror();
114 } 114 }
115 115
116 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, 116 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
117 mUsage, mTex, 0); 117 LLTexUnit::getInternalType(mUsage), mTex, 0);
118 stop_glerror(); 118 stop_glerror();
119 119
120 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 120 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
@@ -125,10 +125,11 @@ void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32
125void LLRenderTarget::allocateDepth() 125void LLRenderTarget::allocateDepth()
126{ 126{
127 glGenTextures(1, (GLuint *) &mDepth); 127 glGenTextures(1, (GLuint *) &mDepth);
128 glBindTexture(mUsage, mDepth); 128 gGL.getTexUnit(0)->bindManual(mUsage, mDepth);
129 glTexParameteri(mUsage, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 129 U32 internal_type = LLTexUnit::getInternalType(mUsage);
130 glTexParameteri(mUsage, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 130 glTexParameteri(internal_type, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
131 glTexImage2D(mUsage, 0, GL_DEPTH24_STENCIL8_EXT, mResX, mResY, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL); 131 glTexParameteri(internal_type, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
132 glTexImage2D(internal_type, 0, GL_DEPTH24_STENCIL8_EXT, mResX, mResY, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL);
132} 133}
133 134
134void LLRenderTarget::release() 135void LLRenderTarget::release()
@@ -191,24 +192,13 @@ void LLRenderTarget::clear()
191 } 192 }
192} 193}
193 194
194void LLRenderTarget::bindTexture()
195{
196 glBindTexture(mUsage, mTex);
197}
198
199void LLRenderTarget::bindDepth()
200{
201 glBindTexture(mUsage, mDepth);
202}
203
204
205void LLRenderTarget::flush(BOOL fetch_depth) 195void LLRenderTarget::flush(BOOL fetch_depth)
206{ 196{
207 gGL.flush(); 197 gGL.flush();
208 if (!mFBO) 198 if (!mFBO)
209 { 199 {
210 bindTexture(); 200 gGL.getTexUnit(0)->bind(this);
211 glCopyTexSubImage2D(mUsage, 0, 0, 0, 0, 0, mResX, mResY); 201 glCopyTexSubImage2D(LLTexUnit::getInternalType(mUsage), 0, 0, 0, 0, 0, mResX, mResY);
212 202
213 if (fetch_depth) 203 if (fetch_depth)
214 { 204 {
@@ -217,8 +207,8 @@ void LLRenderTarget::flush(BOOL fetch_depth)
217 allocateDepth(); 207 allocateDepth();
218 } 208 }
219 209
220 bindDepth(); 210 gGL.getTexUnit(0)->bind(this, true);
221 glCopyTexImage2D(mUsage, 0, GL_DEPTH24_STENCIL8_EXT, 0, 0, mResX, mResY, 0); 211 glCopyTexImage2D(LLTexUnit::getInternalType(mUsage), 0, GL_DEPTH24_STENCIL8_EXT, 0, 0, mResX, mResY, 0);
222 } 212 }
223 } 213 }
224 else 214 else
diff --git a/linden/indra/llrender/llrendertarget.h b/linden/indra/llrender/llrendertarget.h
index 5e3c4d9..38a41cb 100644
--- a/linden/indra/llrender/llrendertarget.h
+++ b/linden/indra/llrender/llrendertarget.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -33,6 +33,7 @@
33#define LL_LLRENDERTARGET_H 33#define LL_LLRENDERTARGET_H
34 34
35#include "llgl.h" 35#include "llgl.h"
36#include "llrender.h"
36 37
37/* 38/*
38 SAMPLE USAGE: 39 SAMPLE USAGE:
@@ -53,7 +54,7 @@
53 ... 54 ...
54 55
55 //use target as a texture 56 //use target as a texture
56 target.bindTexture(); 57 gGL.getTexUnit(INDEX)->bind(&target);
57 ... <issue drawing commands> ... 58 ... <issue drawing commands> ...
58 59
59*/ 60*/
@@ -71,7 +72,7 @@ public:
71 //allocate resources for rendering 72 //allocate resources for rendering
72 //must be called before use 73 //must be called before use
73 //multiple calls will release previously allocated resources 74 //multiple calls will release previously allocated resources
74 void allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage = GL_TEXTURE_2D, BOOL use_fbo = FALSE); 75 void allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, LLTexUnit::eTextureType usage = LLTexUnit::TT_TEXTURE, BOOL use_fbo = FALSE);
75 76
76 //allocate a depth texture 77 //allocate a depth texture
77 void allocateDepth(); 78 void allocateDepth();
@@ -100,11 +101,11 @@ public:
100 //get Y resolution 101 //get Y resolution
101 U32 getHeight() const { return mResY; } 102 U32 getHeight() const { return mResY; }
102 103
103 //bind results of render for sampling 104 LLTexUnit::eTextureType getUsage(void) const { return mUsage; }
104 void bindTexture();
105 105
106 //bind results of render for sampling depth buffer 106 U32 getTexture(void) const { return mTex; }
107 void bindDepth(); 107
108 U32 getDepth(void) const { return mDepth; }
108 109
109 //flush rendering operations 110 //flush rendering operations
110 //must be called when rendering is complete 111 //must be called when rendering is complete
@@ -128,7 +129,7 @@ private:
128 U32 mStencil; 129 U32 mStencil;
129 BOOL mUseDepth; 130 BOOL mUseDepth;
130 BOOL mRenderDepth; 131 BOOL mRenderDepth;
131 U32 mUsage; 132 LLTexUnit::eTextureType mUsage;
132 133
133}; 134};
134 135
diff --git a/linden/indra/llrender/llshadermgr.cpp b/linden/indra/llrender/llshadermgr.cpp
index 4416775..3046d19 100644
--- a/linden/indra/llrender/llshadermgr.cpp
+++ b/linden/indra/llrender/llshadermgr.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2005&license=viewergpl$ 5 * $LicenseInfo:firstyear=2005&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2005-2008, Linden Research, Inc. 7 * Copyright (c) 2005-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -307,7 +307,7 @@ void LLShaderMgr::dumpObjectLog(GLhandleARB ret, BOOL warns)
307 { 307 {
308 LL_DEBUGS("ShaderLoading") << log << LL_ENDL; 308 LL_DEBUGS("ShaderLoading") << log << LL_ENDL;
309 } 309 }
310} 310 }
311} 311}
312 312
313GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type) 313GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type)
diff --git a/linden/indra/llrender/llshadermgr.h b/linden/indra/llrender/llshadermgr.h
index 8918416..1f78e30 100644
--- a/linden/indra/llrender/llshadermgr.h
+++ b/linden/indra/llrender/llshadermgr.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
diff --git a/linden/indra/llrender/llvertexbuffer.cpp b/linden/indra/llrender/llvertexbuffer.cpp
index 547663b..cb7f352 100644
--- a/linden/indra/llrender/llvertexbuffer.cpp
+++ b/linden/indra/llrender/llvertexbuffer.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2003&license=viewergpl$ 5 * $LicenseInfo:firstyear=2003&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2003-2008, Linden Research, Inc. 7 * Copyright (c) 2003-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -76,7 +76,7 @@ S32 LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_MAX] =
76 sizeof(LLVector4), // TYPE_CLOTHWEIGHT, 76 sizeof(LLVector4), // TYPE_CLOTHWEIGHT,
77}; 77};
78 78
79U32 LLVertexBuffer::sGLMode[LLVertexBuffer::NUM_MODES] = 79U32 LLVertexBuffer::sGLMode[LLRender::NUM_MODES] =
80{ 80{
81 GL_TRIANGLES, 81 GL_TRIANGLES,
82 GL_TRIANGLE_STRIP, 82 GL_TRIANGLE_STRIP,
@@ -187,7 +187,7 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi
187 llerrs << "Wrong vertex buffer bound." << llendl; 187 llerrs << "Wrong vertex buffer bound." << llendl;
188 } 188 }
189 189
190 if (mode > NUM_MODES) 190 if (mode > LLRender::NUM_MODES)
191 { 191 {
192 llerrs << "Invalid draw mode: " << mode << llendl; 192 llerrs << "Invalid draw mode: " << mode << llendl;
193 return; 193 return;
@@ -216,7 +216,7 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const
216 llerrs << "Wrong vertex buffer bound." << llendl; 216 llerrs << "Wrong vertex buffer bound." << llendl;
217 } 217 }
218 218
219 if (mode > NUM_MODES) 219 if (mode > LLRender::NUM_MODES)
220 { 220 {
221 llerrs << "Invalid draw mode: " << mode << llendl; 221 llerrs << "Invalid draw mode: " << mode << llendl;
222 return; 222 return;
@@ -240,7 +240,7 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const
240 llerrs << "Wrong vertex buffer bound." << llendl; 240 llerrs << "Wrong vertex buffer bound." << llendl;
241 } 241 }
242 242
243 if (mode > NUM_MODES) 243 if (mode > LLRender::NUM_MODES)
244 { 244 {
245 llerrs << "Invalid draw mode: " << mode << llendl; 245 llerrs << "Invalid draw mode: " << mode << llendl;
246 return; 246 return;
diff --git a/linden/indra/llrender/llvertexbuffer.h b/linden/indra/llrender/llvertexbuffer.h
index 8edcf69..aa1aafc 100644
--- a/linden/indra/llrender/llvertexbuffer.h
+++ b/linden/indra/llrender/llvertexbuffer.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2003&license=viewergpl$ 5 * $LicenseInfo:firstyear=2003&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2003-2008, Linden Research, Inc. 7 * Copyright (c) 2003-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -39,6 +39,7 @@
39#include "v4coloru.h" 39#include "v4coloru.h"
40#include "llstrider.h" 40#include "llstrider.h"
41#include "llmemory.h" 41#include "llmemory.h"
42#include "llrender.h"
42#include <set> 43#include <set>
43#include <vector> 44#include <vector>
44#include <list> 45#include <list>
@@ -123,19 +124,8 @@ public:
123 MAP_UNMAPPED = 0x8000 // Indicates that buffer has been logically un-mapped 124 MAP_UNMAPPED = 0x8000 // Indicates that buffer has been logically un-mapped
124 }; 125 };
125 126
126 enum {
127 TRIANGLES = 0,
128 TRIANGLE_STRIP,
129 TRIANGLE_FAN,
130 POINTS,
131 LINES,
132 LINE_STRIP,
133 QUADS,
134 LINE_LOOP,
135 NUM_MODES
136 };
137protected: 127protected:
138 friend class LLGLImmediate; 128 friend class LLRender;
139 129
140 virtual ~LLVertexBuffer(); // use unref() 130 virtual ~LLVertexBuffer(); // use unref()
141 131
@@ -255,7 +245,7 @@ public:
255 245
256 static BOOL sEnableVBOs; 246 static BOOL sEnableVBOs;
257 static S32 sTypeOffsets[TYPE_MAX]; 247 static S32 sTypeOffsets[TYPE_MAX];
258 static U32 sGLMode[NUM_MODES]; 248 static U32 sGLMode[LLRender::NUM_MODES];
259 static U32 sGLRenderBuffer; 249 static U32 sGLRenderBuffer;
260 static U32 sGLRenderIndices; 250 static U32 sGLRenderIndices;
261 static BOOL sVBOActive; 251 static BOOL sVBOActive;