trunk/3rdparty/bgfx/examples/common/entry/entry_osx.mm
| r244771 | r244772 | |
| 16 | 16 | #include <bx/os.h> |
| 17 | 17 | #include <bx/handlealloc.h> |
| 18 | 18 | |
| 19 | #define DEFAULT_WIDTH 1280 |
| 20 | #define DEFAULT_HEIGHT 720 |
| 21 | |
| 19 | 22 | @interface AppDelegate : NSObject<NSApplicationDelegate> |
| 20 | 23 | { |
| 21 | 24 | bool terminated; |
| r244771 | r244772 | |
| 77 | 80 | struct Context |
| 78 | 81 | { |
| 79 | 82 | Context() |
| 80 | | : m_scroll(0) |
| 81 | | , m_exit(false) |
| 83 | : m_exit(false) |
| 82 | 84 | { |
| 83 | 85 | s_translateKey[27] = Key::Esc; |
| 84 | 86 | s_translateKey[13] = Key::Return; |
| r244771 | r244772 | |
| 104 | 106 | |
| 105 | 107 | for (char ch = 'a'; ch <= 'z'; ++ch) |
| 106 | 108 | { |
| 107 | | s_translateKey[uint8_t(ch)] = |
| 109 | s_translateKey[uint8_t(ch)] = |
| 108 | 110 | s_translateKey[uint8_t(ch - ' ')] = Key::KeyA + (ch - 'a'); |
| 109 | 111 | } |
| 110 | 112 | } |
| r244771 | r244772 | |
| 234 | 236 | case NSMouseMoved: |
| 235 | 237 | case NSLeftMouseDragged: |
| 236 | 238 | case NSRightMouseDragged: |
| 237 | | case NSOtherMouseDragged: |
| 238 | 239 | { |
| 239 | 240 | int x, y; |
| 240 | 241 | getMousePos(&x, &y); |
| 241 | | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll); |
| 242 | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, 0); |
| 242 | 243 | break; |
| 243 | 244 | } |
| 244 | 245 | |
| r244771 | r244772 | |
| 246 | 247 | { |
| 247 | 248 | int x, y; |
| 248 | 249 | getMousePos(&x, &y); |
| 249 | | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll, MouseButton::Left, true); |
| 250 | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, 0, MouseButton::Left, true); |
| 250 | 251 | break; |
| 251 | 252 | } |
| 252 | 253 | |
| r244771 | r244772 | |
| 254 | 255 | { |
| 255 | 256 | int x, y; |
| 256 | 257 | getMousePos(&x, &y); |
| 257 | | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll, MouseButton::Left, false); |
| 258 | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, 0, MouseButton::Left, false); |
| 258 | 259 | break; |
| 259 | 260 | } |
| 260 | 261 | |
| r244771 | r244772 | |
| 262 | 263 | { |
| 263 | 264 | int x, y; |
| 264 | 265 | getMousePos(&x, &y); |
| 265 | | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll, MouseButton::Right, true); |
| 266 | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, 0, MouseButton::Right, true); |
| 266 | 267 | break; |
| 267 | 268 | } |
| 268 | 269 | |
| r244771 | r244772 | |
| 270 | 271 | { |
| 271 | 272 | int x, y; |
| 272 | 273 | getMousePos(&x, &y); |
| 273 | | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll, MouseButton::Right, false); |
| 274 | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, 0, MouseButton::Right, false); |
| 274 | 275 | break; |
| 275 | 276 | } |
| 276 | 277 | |
| 277 | | case NSOtherMouseDown: |
| 278 | | { |
| 279 | | int x, y; |
| 280 | | getMousePos(&x, &y); |
| 281 | | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll, MouseButton::Middle, true); |
| 282 | | break; |
| 283 | | } |
| 284 | | |
| 285 | | case NSOtherMouseUp: |
| 286 | | { |
| 287 | | int x, y; |
| 288 | | getMousePos(&x, &y); |
| 289 | | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll, MouseButton::Middle, false); |
| 290 | | break; |
| 291 | | } |
| 292 | | |
| 293 | | case NSScrollWheel: |
| 294 | | { |
| 295 | | int x, y; |
| 296 | | getMousePos(&x, &y); |
| 297 | | m_scroll += ([event deltaY] > 0.0f) ? 1 : -1; |
| 298 | | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll); |
| 299 | | break; |
| 300 | | } |
| 301 | | |
| 302 | 278 | case NSKeyDown: |
| 303 | 279 | { |
| 304 | 280 | uint8_t modifiers = 0; |
| r244771 | r244772 | |
| 388 | 364 | [NSApp setMainMenu:menubar]; |
| 389 | 365 | |
| 390 | 366 | m_windowAlloc.alloc(); |
| 391 | | NSRect rect = NSMakeRect(0, 0, ENTRY_DEFAULT_WIDTH, ENTRY_DEFAULT_HEIGHT); |
| 367 | NSRect rect = NSMakeRect(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT); |
| 392 | 368 | NSWindow* window = [[NSWindow alloc] |
| 393 | 369 | initWithContentRect:rect |
| 394 | 370 | styleMask:0 |
| r244771 | r244772 | |
| 443 | 419 | bx::HandleAllocT<ENTRY_CONFIG_MAX_WINDOWS> m_windowAlloc; |
| 444 | 420 | NSWindow* m_window[ENTRY_CONFIG_MAX_WINDOWS]; |
| 445 | 421 | |
| 446 | | int32_t m_scroll; |
| 447 | 422 | bool m_exit; |
| 448 | 423 | }; |
| 449 | 424 | |
trunk/3rdparty/bgfx/examples/common/entry/entry_x11.cpp
| r244771 | r244772 | |
| 267 | 267 | initTranslateKey('x', Key::KeyX); |
| 268 | 268 | initTranslateKey('y', Key::KeyY); |
| 269 | 269 | initTranslateKey('z', Key::KeyZ); |
| 270 | | |
| 271 | | m_mx = 0; |
| 272 | | m_my = 0; |
| 273 | | m_mz = 0; |
| 274 | 270 | } |
| 275 | 271 | |
| 276 | 272 | int32_t run(int _argc, char** _argv) |
| r244771 | r244772 | |
| 371 | 367 | case ButtonRelease: |
| 372 | 368 | { |
| 373 | 369 | const XButtonEvent& xbutton = event.xbutton; |
| 374 | | MouseButton::Enum mb = MouseButton::None; |
| 370 | MouseButton::Enum mb; |
| 375 | 371 | switch (xbutton.button) |
| 376 | 372 | { |
| 377 | 373 | case Button1: mb = MouseButton::Left; break; |
| 378 | 374 | case Button2: mb = MouseButton::Middle; break; |
| 379 | 375 | case Button3: mb = MouseButton::Right; break; |
| 380 | | case Button4: ++m_mz; break; |
| 381 | | case Button5: --m_mz; break; |
| 376 | default: mb = MouseButton::None; break; |
| 382 | 377 | } |
| 383 | 378 | |
| 384 | | WindowHandle handle = findHandle(xbutton.window); |
| 385 | 379 | if (MouseButton::None != mb) |
| 386 | 380 | { |
| 381 | WindowHandle handle = findHandle(xbutton.window); |
| 387 | 382 | m_eventQueue.postMouseEvent(handle |
| 388 | 383 | , xbutton.x |
| 389 | 384 | , xbutton.y |
| r244771 | r244772 | |
| 392 | 387 | , event.type == ButtonPress |
| 393 | 388 | ); |
| 394 | 389 | } |
| 395 | | else |
| 396 | | { |
| 397 | | m_eventQueue.postMouseEvent(handle |
| 398 | | , m_mx |
| 399 | | , m_my |
| 400 | | , m_mz |
| 401 | | ); |
| 402 | | } |
| 403 | 390 | } |
| 404 | 391 | break; |
| 405 | 392 | |
| r244771 | r244772 | |
| 407 | 394 | { |
| 408 | 395 | const XMotionEvent& xmotion = event.xmotion; |
| 409 | 396 | WindowHandle handle = findHandle(xmotion.window); |
| 410 | | |
| 411 | | m_mx = xmotion.x; |
| 412 | | m_my = xmotion.y; |
| 413 | | |
| 414 | 397 | m_eventQueue.postMouseEvent(handle |
| 415 | | , m_mx |
| 416 | | , m_my |
| 417 | | , m_mz |
| 398 | , xmotion.x |
| 399 | , xmotion.y |
| 400 | , 0 |
| 418 | 401 | ); |
| 419 | 402 | } |
| 420 | 403 | break; |
| r244771 | r244772 | |
| 560 | 543 | uint8_t m_modifiers; |
| 561 | 544 | bool m_exit; |
| 562 | 545 | |
| 563 | | int32_t m_mx; |
| 564 | | int32_t m_my; |
| 565 | | int32_t m_mz; |
| 566 | | |
| 567 | 546 | EventQueue m_eventQueue; |
| 568 | 547 | bx::LwMutex m_lock; |
| 569 | 548 | bx::HandleAllocT<ENTRY_CONFIG_MAX_WINDOWS> m_windowAlloc; |
trunk/3rdparty/bgfx/src/bgfx.cpp
| r244771 | r244772 | |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | 904 | BX_TRACE("Supported texture formats:"); |
| 905 | | BX_TRACE("\t +------ x = supported / * = emulated"); |
| 906 | | BX_TRACE("\t |+----- vertex format"); |
| 907 | | BX_TRACE("\t || +-- name"); |
| 908 | 905 | for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii) |
| 909 | 906 | { |
| 910 | 907 | if (TextureFormat::Unknown != ii |
| 911 | 908 | && TextureFormat::UnknownDepth != ii) |
| 912 | 909 | { |
| 913 | 910 | uint8_t flags = g_caps.formats[ii]; |
| 914 | | BX_TRACE("\t[%c%c] %s" |
| 915 | | , flags&BGFX_CAPS_FORMAT_TEXTURE_COLOR ? 'x' : flags&BGFX_CAPS_FORMAT_TEXTURE_EMULATED ? '*' : ' ' |
| 916 | | , flags&BGFX_CAPS_FORMAT_TEXTURE_VERTEX ? 'v' : ' ' |
| 911 | BX_TRACE("\t[%c] %s" |
| 912 | , flags&1 ? 'x' : flags&2 ? '*' : ' ' |
| 917 | 913 | , getName(TextureFormat::Enum(ii) ) |
| 918 | 914 | ); |
| 919 | 915 | BX_UNUSED(flags); |
| r244771 | r244772 | |
| 942 | 938 | { |
| 943 | 939 | BX_CHECK(!m_rendererInitialized, "Already initialized?"); |
| 944 | 940 | |
| 945 | | m_exit = false; |
| 941 | m_exit = false; |
| 946 | 942 | m_frames = 0; |
| 947 | 943 | m_render = &m_frame[0]; |
| 948 | 944 | m_submit = &m_frame[1]; |
| 949 | | m_debug = BGFX_DEBUG_NONE; |
| 945 | m_debug = BGFX_DEBUG_NONE; |
| 950 | 946 | |
| 951 | 947 | m_submit->create(); |
| 952 | 948 | m_render->create(); |
| r244771 | r244772 | |
| 1006 | 1002 | |
| 1007 | 1003 | for (uint32_t ii = 0; ii < BX_COUNTOF(s_emulatedFormats); ++ii) |
| 1008 | 1004 | { |
| 1009 | | if (0 == (g_caps.formats[s_emulatedFormats[ii] ] & BGFX_CAPS_FORMAT_TEXTURE_COLOR) ) |
| 1005 | if (0 == g_caps.formats[s_emulatedFormats[ii] ]) |
| 1010 | 1006 | { |
| 1011 | | g_caps.formats[s_emulatedFormats[ii] ] |= BGFX_CAPS_FORMAT_TEXTURE_EMULATED; |
| 1007 | g_caps.formats[s_emulatedFormats[ii] ] = 2; |
| 1012 | 1008 | } |
| 1013 | 1009 | } |
| 1014 | 1010 | |
trunk/3rdparty/bgfx/src/bgfx_compute.sh
| r244771 | r244772 | |
| 54 | 54 | |
| 55 | 55 | #define NUM_THREADS(_x, _y, _z) [numthreads(_x, _y, _z)] |
| 56 | 56 | |
| 57 | | #define __IMAGE_IMPL(_textureType, _storeComponents, _type, _loadComponents) \ |
| 58 | | _type imageLoad(Texture2D<_textureType> _image, ivec2 _uv) \ |
| 59 | | { \ |
| 60 | | return _image[_uv]._loadComponents; \ |
| 61 | | } \ |
| 62 | | \ |
| 63 | | void imageStore(RWTexture2D<_textureType> _image, ivec2 _uv, _type _value) \ |
| 64 | | { \ |
| 65 | | _image[_uv] = _value._storeComponents; \ |
| 66 | | } |
| 57 | vec4 imageLoad(Texture2D _image, ivec2 _uv) |
| 58 | { |
| 59 | return _image.Load(uint3(_uv.xy, 0) ); |
| 60 | } |
| 67 | 61 | |
| 68 | | __IMAGE_IMPL(float, x, vec4, xxxx) |
| 69 | | __IMAGE_IMPL(vec2, xy, vec4, xyyy) |
| 70 | | __IMAGE_IMPL(vec3, xyz, vec4, xyzz) |
| 71 | | __IMAGE_IMPL(vec4, xyzw, vec4, xyzw) |
| 72 | | __IMAGE_IMPL(uint, x, uvec4, xxxx) |
| 73 | | __IMAGE_IMPL(uvec2, xy, uvec4, xyyy) |
| 74 | | __IMAGE_IMPL(uvec3, xyz, uvec4, xyzz) |
| 75 | | __IMAGE_IMPL(uvec4, xyzw, uvec4, xyzw) |
| 76 | | __IMAGE_IMPL(int, x, ivec4, xxxx) |
| 77 | | __IMAGE_IMPL(ivec2, xy, ivec4, xyyy) |
| 78 | | __IMAGE_IMPL(ivec3, xyz, ivec4, xyzz) |
| 79 | | __IMAGE_IMPL(ivec4, xyzw, ivec4, xyzw) |
| 62 | uint4 imageLoad(Texture2D<uint> _image, ivec2 _uv) |
| 63 | { |
| 64 | uint rr = _image.Load(uint3(_uv.xy, 0) ); |
| 65 | return uint4(rr, rr, rr, rr); |
| 66 | } |
| 80 | 67 | |
| 81 | 68 | uint4 imageLoad(RWTexture2D<uint> _image, ivec2 _uv) |
| 82 | 69 | { |
| r244771 | r244772 | |
| 105 | 92 | return result; |
| 106 | 93 | } |
| 107 | 94 | |
| 95 | void imageStore(RWTexture2D<float4> _image, ivec2 _uv, vec4 _rgba) |
| 96 | { |
| 97 | _image[_uv] = _rgba; |
| 98 | } |
| 99 | |
| 100 | void imageStore(RWTexture2D<uint> _image, ivec2 _uv, uvec4 _r) |
| 101 | { |
| 102 | _image[_uv] = _r.x; |
| 103 | } |
| 104 | |
| 108 | 105 | #define __ATOMIC_IMPL_TYPE(_genType, _glFunc, _dxFunc) \ |
| 109 | 106 | _genType _glFunc(_genType _mem, _genType _data) \ |
| 110 | 107 | { \ |
| r244771 | r244772 | |
| 156 | 153 | #define __IMAGE2D_XX(_name, _reg, _access) \ |
| 157 | 154 | layout(rgba8, binding=_reg) _access uniform highp image2D _name |
| 158 | 155 | |
| 159 | | #define readwrite |
| 160 | 156 | #define IMAGE2D_RO(_name, _reg) __IMAGE2D_XX(_name, _reg, readonly) |
| 161 | 157 | #define IMAGE2D_RW(_name, _reg) __IMAGE2D_XX(_name, _reg, readwrite) |
| 162 | 158 | #define IMAGE2D_WR(_name, _reg) __IMAGE2D_XX(_name, _reg, writeonly) |
trunk/3rdparty/bgfx/src/renderer_d3d11.cpp
| r244771 | r244772 | |
| 1786 | 1786 | |
| 1787 | 1787 | void commitTextureStage() |
| 1788 | 1788 | { |
| 1789 | | m_deviceCtx->VSSetShaderResources(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, m_textureStage.m_srv); |
| 1790 | | m_deviceCtx->VSSetSamplers(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, m_textureStage.m_sampler); |
| 1791 | | |
| 1792 | 1789 | m_deviceCtx->PSSetShaderResources(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, m_textureStage.m_srv); |
| 1793 | 1790 | m_deviceCtx->PSSetSamplers(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, m_textureStage.m_sampler); |
| 1794 | 1791 | } |
| r244771 | r244772 | |
| 2372 | 2369 | ID3D11DeviceContext* deviceCtx = s_renderD3D11->m_deviceCtx; |
| 2373 | 2370 | BX_CHECK(m_dynamic, "Must be dynamic!"); |
| 2374 | 2371 | |
| 2375 | | #if 1 |
| 2376 | | BX_UNUSED(_discard); |
| 2377 | | ID3D11Device* device = s_renderD3D11->m_device; |
| 2378 | | |
| 2379 | | D3D11_BUFFER_DESC desc; |
| 2380 | | desc.ByteWidth = _size; |
| 2381 | | desc.Usage = D3D11_USAGE_STAGING; |
| 2382 | | desc.BindFlags = 0; |
| 2383 | | desc.MiscFlags = 0; |
| 2384 | | desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; |
| 2385 | | desc.StructureByteStride = 0; |
| 2386 | | |
| 2387 | | D3D11_SUBRESOURCE_DATA srd; |
| 2388 | | srd.pSysMem = _data; |
| 2389 | | srd.SysMemPitch = 0; |
| 2390 | | srd.SysMemSlicePitch = 0; |
| 2391 | | |
| 2392 | | ID3D11Buffer* ptr; |
| 2393 | | DX_CHECK(device->CreateBuffer(&desc, &srd, &ptr) ); |
| 2394 | | |
| 2395 | | D3D11_BOX box; |
| 2396 | | box.left = 0; |
| 2397 | | box.top = 0; |
| 2398 | | box.front = 0; |
| 2399 | | box.right = _size; |
| 2400 | | box.bottom = 1; |
| 2401 | | box.back = 1; |
| 2402 | | |
| 2403 | | deviceCtx->CopySubresourceRegion(m_ptr |
| 2404 | | , 0 |
| 2405 | | , _offset |
| 2406 | | , 0 |
| 2407 | | , 0 |
| 2408 | | , ptr |
| 2409 | | , 0 |
| 2410 | | , &box |
| 2411 | | ); |
| 2412 | | |
| 2413 | | DX_RELEASE(ptr, 0); |
| 2414 | | #else |
| 2415 | 2372 | D3D11_MAPPED_SUBRESOURCE mapped; |
| 2416 | 2373 | BX_UNUSED(_discard); |
| 2417 | 2374 | D3D11_MAP type = D3D11_MAP_WRITE_DISCARD; |
| 2418 | 2375 | DX_CHECK(deviceCtx->Map(m_ptr, 0, type, 0, &mapped)); |
| 2419 | | memcpy( (uint8_t*)mapped.pData + _offset, _data, _size); |
| 2376 | memcpy((uint8_t*)mapped.pData + _offset, _data, _size); |
| 2420 | 2377 | deviceCtx->Unmap(m_ptr, 0); |
| 2421 | | #endif // 0 |
| 2422 | 2378 | } |
| 2423 | 2379 | |
| 2424 | 2380 | void VertexBufferD3D11::create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint8_t _flags) |
trunk/3rdparty/bgfx/src/renderer_d3d9.cpp
| r244771 | r244772 | |
| 498 | 498 | |
| 499 | 499 | for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii) |
| 500 | 500 | { |
| 501 | | uint8_t support = SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter |
| 501 | g_caps.formats[ii] = SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter |
| 502 | 502 | , m_deviceType |
| 503 | 503 | , adapterFormat |
| 504 | 504 | , 0 |
| 505 | 505 | , D3DRTYPE_TEXTURE |
| 506 | 506 | , s_textureFormat[ii].m_fmt |
| 507 | | ) ) ? BGFX_CAPS_FORMAT_TEXTURE_COLOR : BGFX_CAPS_FORMAT_TEXTURE_NONE; |
| 508 | | |
| 509 | | support |= SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter |
| 510 | | , m_deviceType |
| 511 | | , adapterFormat |
| 512 | | , D3DUSAGE_QUERY_VERTEXTEXTURE |
| 513 | | , D3DRTYPE_TEXTURE |
| 514 | | , s_textureFormat[ii].m_fmt |
| 515 | | ) ) ? BGFX_CAPS_FORMAT_TEXTURE_VERTEX : BGFX_CAPS_FORMAT_TEXTURE_NONE; |
| 516 | | |
| 517 | | g_caps.formats[ii] = support; |
| 507 | ) ) ? 1 : 0; |
| 518 | 508 | } |
| 519 | 509 | } |
| 520 | 510 | |
| r244771 | r244772 | |
| 1246 | 1236 | { |
| 1247 | 1237 | for (uint32_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage) |
| 1248 | 1238 | { |
| 1249 | | m_samplerFlags[stage][0] = UINT32_MAX; |
| 1250 | | m_samplerFlags[stage][1] = UINT32_MAX; |
| 1239 | m_samplerFlags[stage] = UINT32_MAX; |
| 1251 | 1240 | } |
| 1252 | 1241 | } |
| 1253 | 1242 | |
| 1254 | | void setSamplerState(uint8_t _stage, uint32_t _flags, bool _vertex = false) |
| 1243 | void setSamplerState(uint8_t _stage, uint32_t _flags) |
| 1255 | 1244 | { |
| 1256 | 1245 | const uint32_t flags = _flags&( (~BGFX_TEXTURE_RESERVED_MASK) | BGFX_TEXTURE_SAMPLER_BITS_MASK); |
| 1257 | | BX_CHECK(_stage < BX_COUNTOF(m_samplerFlags), ""); |
| 1258 | | if (m_samplerFlags[_stage][_vertex] != flags) |
| 1246 | if (m_samplerFlags[_stage] != flags) |
| 1259 | 1247 | { |
| 1260 | | m_samplerFlags[_stage][_vertex] = flags; |
| 1248 | m_samplerFlags[_stage] = flags; |
| 1261 | 1249 | IDirect3DDevice9* device = m_device; |
| 1262 | 1250 | D3DTEXTUREADDRESS tau = s_textureAddress[(_flags&BGFX_TEXTURE_U_MASK)>>BGFX_TEXTURE_U_SHIFT]; |
| 1263 | 1251 | D3DTEXTUREADDRESS tav = s_textureAddress[(_flags&BGFX_TEXTURE_V_MASK)>>BGFX_TEXTURE_V_SHIFT]; |
| r244771 | r244772 | |
| 1265 | 1253 | D3DTEXTUREFILTERTYPE minFilter = s_textureFilter[(_flags&BGFX_TEXTURE_MIN_MASK)>>BGFX_TEXTURE_MIN_SHIFT]; |
| 1266 | 1254 | D3DTEXTUREFILTERTYPE magFilter = s_textureFilter[(_flags&BGFX_TEXTURE_MAG_MASK)>>BGFX_TEXTURE_MAG_SHIFT]; |
| 1267 | 1255 | D3DTEXTUREFILTERTYPE mipFilter = s_textureFilter[(_flags&BGFX_TEXTURE_MIP_MASK)>>BGFX_TEXTURE_MIP_SHIFT]; |
| 1268 | | |
| 1269 | | DWORD stage = (_vertex ? D3DVERTEXTEXTURESAMPLER0 : 0) + _stage; |
| 1270 | | |
| 1271 | | DX_CHECK(device->SetSamplerState(stage, D3DSAMP_ADDRESSU, tau) ); |
| 1272 | | DX_CHECK(device->SetSamplerState(stage, D3DSAMP_ADDRESSV, tav) ); |
| 1273 | | DX_CHECK(device->SetSamplerState(stage, D3DSAMP_ADDRESSW, taw) ); |
| 1274 | | DX_CHECK(device->SetSamplerState(stage, D3DSAMP_MINFILTER, minFilter) ); |
| 1275 | | DX_CHECK(device->SetSamplerState(stage, D3DSAMP_MAGFILTER, magFilter) ); |
| 1276 | | DX_CHECK(device->SetSamplerState(stage, D3DSAMP_MIPFILTER, mipFilter) ); |
| 1277 | | DX_CHECK(device->SetSamplerState(stage, D3DSAMP_MAXANISOTROPY, m_maxAnisotropy) ); |
| 1256 | DX_CHECK(device->SetSamplerState(_stage, D3DSAMP_ADDRESSU, tau) ); |
| 1257 | DX_CHECK(device->SetSamplerState(_stage, D3DSAMP_ADDRESSV, tav) ); |
| 1258 | DX_CHECK(device->SetSamplerState(_stage, D3DSAMP_ADDRESSW, taw) ); |
| 1259 | DX_CHECK(device->SetSamplerState(_stage, D3DSAMP_MINFILTER, minFilter) ); |
| 1260 | DX_CHECK(device->SetSamplerState(_stage, D3DSAMP_MAGFILTER, magFilter) ); |
| 1261 | DX_CHECK(device->SetSamplerState(_stage, D3DSAMP_MIPFILTER, mipFilter) ); |
| 1262 | DX_CHECK(device->SetSamplerState(_stage, D3DSAMP_MAXANISOTROPY, m_maxAnisotropy) ); |
| 1278 | 1263 | } |
| 1279 | 1264 | } |
| 1280 | 1265 | |
| r244771 | r244772 | |
| 1714 | 1699 | UniformRegistry m_uniformReg; |
| 1715 | 1700 | void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; |
| 1716 | 1701 | |
| 1717 | | uint32_t m_samplerFlags[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS][1]; |
| 1702 | uint32_t m_samplerFlags[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS]; |
| 1718 | 1703 | |
| 1719 | 1704 | TextureD3D9* m_updateTexture; |
| 1720 | 1705 | uint8_t* m_updateTextureBits; |
| r244771 | r244772 | |
| 2529 | 2514 | { |
| 2530 | 2515 | s_renderD3D9->setSamplerState(_stage, 0 == (BGFX_SAMPLER_DEFAULT_FLAGS & _flags) ? _flags : m_flags); |
| 2531 | 2516 | DX_CHECK(s_renderD3D9->m_device->SetTexture(_stage, m_ptr) ); |
| 2532 | | |
| 2533 | | // s_renderD3D9->setSamplerState(_stage, 0 == (BGFX_SAMPLER_DEFAULT_FLAGS & _flags) ? _flags : m_flags, true); |
| 2534 | | // DX_CHECK(s_renderD3D9->m_device->SetTexture(D3DVERTEXTEXTURESAMPLER0 + _stage, m_ptr) ); |
| 2535 | 2517 | } |
| 2536 | 2518 | |
| 2537 | 2519 | void TextureD3D9::resolve() const |
trunk/3rdparty/bgfx/src/renderer_gl.cpp
| r244771 | r244772 | |
| 236 | 236 | }; |
| 237 | 237 | BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_textureFormat) ); |
| 238 | 238 | |
| 239 | | static GLenum s_rboFormat[] = |
| 240 | | { |
| 241 | | GL_ZERO, // BC1 |
| 242 | | GL_ZERO, // BC2 |
| 243 | | GL_ZERO, // BC3 |
| 244 | | GL_ZERO, // BC4 |
| 245 | | GL_ZERO, // BC5 |
| 246 | | GL_ZERO, // BC6H |
| 247 | | GL_ZERO, // BC7 |
| 248 | | GL_ZERO, // ETC1 |
| 249 | | GL_ZERO, // ETC2 |
| 250 | | GL_ZERO, // ETC2A |
| 251 | | GL_ZERO, // ETC2A1 |
| 252 | | GL_ZERO, // PTC12 |
| 253 | | GL_ZERO, // PTC14 |
| 254 | | GL_ZERO, // PTC12A |
| 255 | | GL_ZERO, // PTC14A |
| 256 | | GL_ZERO, // PTC22 |
| 257 | | GL_ZERO, // PTC24 |
| 258 | | GL_ZERO, // Unknown |
| 259 | | GL_ZERO, // R1 |
| 260 | | GL_R8, // R8 |
| 261 | | GL_R16, // R16 |
| 262 | | GL_R16F, // R16F |
| 263 | | GL_R32UI, // R32 |
| 264 | | GL_R32F, // R32F |
| 265 | | GL_RG8, // RG8 |
| 266 | | GL_RG16, // RG16 |
| 267 | | GL_RG16F, // RG16F |
| 268 | | GL_RG32UI, // RG32 |
| 269 | | GL_RG32F, // RG32F |
| 270 | | GL_RGBA8, // BGRA8 |
| 271 | | GL_RGBA16, // RGBA16 |
| 272 | | GL_RGBA16F, // RGBA16F |
| 273 | | GL_RGBA32UI, // RGBA32 |
| 274 | | GL_RGBA32F, // RGBA32F |
| 275 | | GL_RGB565, // R5G6B5 |
| 276 | | GL_RGBA4, // RGBA4 |
| 277 | | GL_RGB5_A1, // RGB5A1 |
| 278 | | GL_RGB10_A2, // RGB10A2 |
| 279 | | GL_R11F_G11F_B10F, // R11G11B10F |
| 280 | | GL_ZERO, // UnknownDepth |
| 281 | | GL_DEPTH_COMPONENT16, // D16 |
| 282 | | GL_DEPTH_COMPONENT24, // D24 |
| 283 | | GL_DEPTH24_STENCIL8, // D24S8 |
| 284 | | GL_DEPTH_COMPONENT32, // D32 |
| 285 | | GL_DEPTH_COMPONENT32F, // D16F |
| 286 | | GL_DEPTH_COMPONENT32F, // D24F |
| 287 | | GL_DEPTH_COMPONENT32F, // D32F |
| 288 | | GL_STENCIL_INDEX8, // D0S8 |
| 289 | | }; |
| 290 | | BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_rboFormat) ); |
| 291 | | |
| 292 | 239 | static GLenum s_imageFormat[] = |
| 293 | 240 | { |
| 294 | 241 | GL_ZERO, // BC1 |
| r244771 | r244772 | |
| 1168 | 1115 | { |
| 1169 | 1116 | setTextureFormat(TextureFormat::D32, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT); |
| 1170 | 1117 | |
| 1171 | | if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES < 30) ) |
| 1118 | if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 30) ) |
| 1172 | 1119 | { |
| 1120 | setTextureFormat(TextureFormat::R16, GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT); |
| 1121 | setTextureFormat(TextureFormat::RGBA16, GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT); |
| 1122 | } |
| 1123 | else |
| 1124 | { |
| 1173 | 1125 | setTextureFormat(TextureFormat::RGBA16F, GL_RGBA, GL_RGBA, GL_HALF_FLOAT); |
| 1174 | 1126 | |
| 1175 | 1127 | if (BX_ENABLED(BX_PLATFORM_IOS) ) |
| r244771 | r244772 | |
| 1180 | 1132 | } |
| 1181 | 1133 | } |
| 1182 | 1134 | |
| 1183 | | if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) |
| 1184 | | || BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 30) ) |
| 1185 | | { |
| 1186 | | setTextureFormat(TextureFormat::R16, GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT); |
| 1187 | | setTextureFormat(TextureFormat::RG16, GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT); |
| 1188 | | setTextureFormat(TextureFormat::RGBA16, GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT); |
| 1189 | | setTextureFormat(TextureFormat::R32, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT); |
| 1190 | | setTextureFormat(TextureFormat::RG32, GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT); |
| 1191 | | setTextureFormat(TextureFormat::RGBA32, GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT); |
| 1192 | | } |
| 1193 | | |
| 1194 | 1135 | if (s_extension[Extension::EXT_texture_format_BGRA8888 ].m_supported |
| 1195 | 1136 | || s_extension[Extension::EXT_bgra ].m_supported |
| 1196 | 1137 | || s_extension[Extension::IMG_texture_format_BGRA8888 ].m_supported |
| r244771 | r244772 | |
| 3199 | 3140 | if (0 == msaaQuality) |
| 3200 | 3141 | { |
| 3201 | 3142 | GL_CHECK(glRenderbufferStorage(GL_RENDERBUFFER |
| 3202 | | , s_rboFormat[m_textureFormat] |
| 3143 | , s_textureFormat[m_textureFormat].m_internalFmt |
| 3203 | 3144 | , _width |
| 3204 | 3145 | , _height |
| 3205 | 3146 | ) ); |
| r244771 | r244772 | |
| 3208 | 3149 | { |
| 3209 | 3150 | GL_CHECK(glRenderbufferStorageMultisample(GL_RENDERBUFFER |
| 3210 | 3151 | , msaaQuality |
| 3211 | | , s_rboFormat[m_textureFormat] |
| 3152 | , s_textureFormat[m_textureFormat].m_internalFmt |
| 3212 | 3153 | , _width |
| 3213 | 3154 | , _height |
| 3214 | 3155 | ) ); |