trunk/3rdparty/bgfx/examples/common/entry/entry_osx.mm
| r244773 | r244774 | |
| 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 | | |
| 22 | 19 | @interface AppDelegate : NSObject<NSApplicationDelegate> |
| 23 | 20 | { |
| 24 | 21 | bool terminated; |
| r244773 | r244774 | |
| 80 | 77 | struct Context |
| 81 | 78 | { |
| 82 | 79 | Context() |
| 83 | | : m_exit(false) |
| 80 | : m_scroll(0) |
| 81 | , m_exit(false) |
| 84 | 82 | { |
| 85 | 83 | s_translateKey[27] = Key::Esc; |
| 86 | 84 | s_translateKey[13] = Key::Return; |
| r244773 | r244774 | |
| 106 | 104 | |
| 107 | 105 | for (char ch = 'a'; ch <= 'z'; ++ch) |
| 108 | 106 | { |
| 109 | | s_translateKey[uint8_t(ch)] = |
| 107 | s_translateKey[uint8_t(ch)] = |
| 110 | 108 | s_translateKey[uint8_t(ch - ' ')] = Key::KeyA + (ch - 'a'); |
| 111 | 109 | } |
| 112 | 110 | } |
| r244773 | r244774 | |
| 236 | 234 | case NSMouseMoved: |
| 237 | 235 | case NSLeftMouseDragged: |
| 238 | 236 | case NSRightMouseDragged: |
| 237 | case NSOtherMouseDragged: |
| 239 | 238 | { |
| 240 | 239 | int x, y; |
| 241 | 240 | getMousePos(&x, &y); |
| 242 | | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, 0); |
| 241 | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll); |
| 243 | 242 | break; |
| 244 | 243 | } |
| 245 | 244 | |
| r244773 | r244774 | |
| 247 | 246 | { |
| 248 | 247 | int x, y; |
| 249 | 248 | getMousePos(&x, &y); |
| 250 | | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, 0, MouseButton::Left, true); |
| 249 | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll, MouseButton::Left, true); |
| 251 | 250 | break; |
| 252 | 251 | } |
| 253 | 252 | |
| r244773 | r244774 | |
| 255 | 254 | { |
| 256 | 255 | int x, y; |
| 257 | 256 | getMousePos(&x, &y); |
| 258 | | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, 0, MouseButton::Left, false); |
| 257 | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll, MouseButton::Left, false); |
| 259 | 258 | break; |
| 260 | 259 | } |
| 261 | 260 | |
| r244773 | r244774 | |
| 263 | 262 | { |
| 264 | 263 | int x, y; |
| 265 | 264 | getMousePos(&x, &y); |
| 266 | | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, 0, MouseButton::Right, true); |
| 265 | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll, MouseButton::Right, true); |
| 267 | 266 | break; |
| 268 | 267 | } |
| 269 | 268 | |
| r244773 | r244774 | |
| 271 | 270 | { |
| 272 | 271 | int x, y; |
| 273 | 272 | getMousePos(&x, &y); |
| 274 | | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, 0, MouseButton::Right, false); |
| 273 | m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll, MouseButton::Right, false); |
| 275 | 274 | break; |
| 276 | 275 | } |
| 277 | 276 | |
| 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 | |
| 278 | 302 | case NSKeyDown: |
| 279 | 303 | { |
| 280 | 304 | uint8_t modifiers = 0; |
| r244773 | r244774 | |
| 364 | 388 | [NSApp setMainMenu:menubar]; |
| 365 | 389 | |
| 366 | 390 | m_windowAlloc.alloc(); |
| 367 | | NSRect rect = NSMakeRect(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT); |
| 391 | NSRect rect = NSMakeRect(0, 0, ENTRY_DEFAULT_WIDTH, ENTRY_DEFAULT_HEIGHT); |
| 368 | 392 | NSWindow* window = [[NSWindow alloc] |
| 369 | 393 | initWithContentRect:rect |
| 370 | 394 | styleMask:0 |
| r244773 | r244774 | |
| 419 | 443 | bx::HandleAllocT<ENTRY_CONFIG_MAX_WINDOWS> m_windowAlloc; |
| 420 | 444 | NSWindow* m_window[ENTRY_CONFIG_MAX_WINDOWS]; |
| 421 | 445 | |
| 446 | int32_t m_scroll; |
| 422 | 447 | bool m_exit; |
| 423 | 448 | }; |
| 424 | 449 | |
trunk/3rdparty/bgfx/examples/common/entry/entry_x11.cpp
| r244773 | r244774 | |
| 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; |
| 270 | 274 | } |
| 271 | 275 | |
| 272 | 276 | int32_t run(int _argc, char** _argv) |
| r244773 | r244774 | |
| 367 | 371 | case ButtonRelease: |
| 368 | 372 | { |
| 369 | 373 | const XButtonEvent& xbutton = event.xbutton; |
| 370 | | MouseButton::Enum mb; |
| 374 | MouseButton::Enum mb = MouseButton::None; |
| 371 | 375 | switch (xbutton.button) |
| 372 | 376 | { |
| 373 | 377 | case Button1: mb = MouseButton::Left; break; |
| 374 | 378 | case Button2: mb = MouseButton::Middle; break; |
| 375 | 379 | case Button3: mb = MouseButton::Right; break; |
| 376 | | default: mb = MouseButton::None; break; |
| 380 | case Button4: ++m_mz; break; |
| 381 | case Button5: --m_mz; break; |
| 377 | 382 | } |
| 378 | 383 | |
| 384 | WindowHandle handle = findHandle(xbutton.window); |
| 379 | 385 | if (MouseButton::None != mb) |
| 380 | 386 | { |
| 381 | | WindowHandle handle = findHandle(xbutton.window); |
| 382 | 387 | m_eventQueue.postMouseEvent(handle |
| 383 | 388 | , xbutton.x |
| 384 | 389 | , xbutton.y |
| r244773 | r244774 | |
| 387 | 392 | , event.type == ButtonPress |
| 388 | 393 | ); |
| 389 | 394 | } |
| 395 | else |
| 396 | { |
| 397 | m_eventQueue.postMouseEvent(handle |
| 398 | , m_mx |
| 399 | , m_my |
| 400 | , m_mz |
| 401 | ); |
| 402 | } |
| 390 | 403 | } |
| 391 | 404 | break; |
| 392 | 405 | |
| r244773 | r244774 | |
| 394 | 407 | { |
| 395 | 408 | const XMotionEvent& xmotion = event.xmotion; |
| 396 | 409 | WindowHandle handle = findHandle(xmotion.window); |
| 410 | |
| 411 | m_mx = xmotion.x; |
| 412 | m_my = xmotion.y; |
| 413 | |
| 397 | 414 | m_eventQueue.postMouseEvent(handle |
| 398 | | , xmotion.x |
| 399 | | , xmotion.y |
| 400 | | , 0 |
| 415 | , m_mx |
| 416 | , m_my |
| 417 | , m_mz |
| 401 | 418 | ); |
| 402 | 419 | } |
| 403 | 420 | break; |
| r244773 | r244774 | |
| 543 | 560 | uint8_t m_modifiers; |
| 544 | 561 | bool m_exit; |
| 545 | 562 | |
| 563 | int32_t m_mx; |
| 564 | int32_t m_my; |
| 565 | int32_t m_mz; |
| 566 | |
| 546 | 567 | EventQueue m_eventQueue; |
| 547 | 568 | bx::LwMutex m_lock; |
| 548 | 569 | bx::HandleAllocT<ENTRY_CONFIG_MAX_WINDOWS> m_windowAlloc; |
trunk/3rdparty/bgfx/src/bgfx.cpp
| r244773 | r244774 | |
| 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"); |
| 905 | 908 | for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii) |
| 906 | 909 | { |
| 907 | 910 | if (TextureFormat::Unknown != ii |
| 908 | 911 | && TextureFormat::UnknownDepth != ii) |
| 909 | 912 | { |
| 910 | 913 | uint8_t flags = g_caps.formats[ii]; |
| 911 | | BX_TRACE("\t[%c] %s" |
| 912 | | , flags&1 ? 'x' : flags&2 ? '*' : ' ' |
| 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' : ' ' |
| 913 | 917 | , getName(TextureFormat::Enum(ii) ) |
| 914 | 918 | ); |
| 915 | 919 | BX_UNUSED(flags); |
| r244773 | r244774 | |
| 938 | 942 | { |
| 939 | 943 | BX_CHECK(!m_rendererInitialized, "Already initialized?"); |
| 940 | 944 | |
| 941 | | m_exit = false; |
| 945 | m_exit = false; |
| 942 | 946 | m_frames = 0; |
| 943 | 947 | m_render = &m_frame[0]; |
| 944 | 948 | m_submit = &m_frame[1]; |
| 945 | | m_debug = BGFX_DEBUG_NONE; |
| 949 | m_debug = BGFX_DEBUG_NONE; |
| 946 | 950 | |
| 947 | 951 | m_submit->create(); |
| 948 | 952 | m_render->create(); |
| r244773 | r244774 | |
| 1002 | 1006 | |
| 1003 | 1007 | for (uint32_t ii = 0; ii < BX_COUNTOF(s_emulatedFormats); ++ii) |
| 1004 | 1008 | { |
| 1005 | | if (0 == g_caps.formats[s_emulatedFormats[ii] ]) |
| 1009 | if (0 == (g_caps.formats[s_emulatedFormats[ii] ] & BGFX_CAPS_FORMAT_TEXTURE_COLOR) ) |
| 1006 | 1010 | { |
| 1007 | | g_caps.formats[s_emulatedFormats[ii] ] = 2; |
| 1011 | g_caps.formats[s_emulatedFormats[ii] ] |= BGFX_CAPS_FORMAT_TEXTURE_EMULATED; |
| 1008 | 1012 | } |
| 1009 | 1013 | } |
| 1010 | 1014 | |
trunk/3rdparty/bgfx/src/bgfx_compute.sh
| r244773 | r244774 | |
| 54 | 54 | |
| 55 | 55 | #define NUM_THREADS(_x, _y, _z) [numthreads(_x, _y, _z)] |
| 56 | 56 | |
| 57 | | vec4 imageLoad(Texture2D _image, ivec2 _uv) |
| 58 | | { |
| 59 | | return _image.Load(uint3(_uv.xy, 0) ); |
| 60 | | } |
| 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 | } |
| 61 | 67 | |
| 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 | | } |
| 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) |
| 67 | 80 | |
| 68 | 81 | uint4 imageLoad(RWTexture2D<uint> _image, ivec2 _uv) |
| 69 | 82 | { |
| r244773 | r244774 | |
| 92 | 105 | return result; |
| 93 | 106 | } |
| 94 | 107 | |
| 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 | | |
| 105 | 108 | #define __ATOMIC_IMPL_TYPE(_genType, _glFunc, _dxFunc) \ |
| 106 | 109 | _genType _glFunc(_genType _mem, _genType _data) \ |
| 107 | 110 | { \ |
| r244773 | r244774 | |
| 153 | 156 | #define __IMAGE2D_XX(_name, _reg, _access) \ |
| 154 | 157 | layout(rgba8, binding=_reg) _access uniform highp image2D _name |
| 155 | 158 | |
| 159 | #define readwrite |
| 156 | 160 | #define IMAGE2D_RO(_name, _reg) __IMAGE2D_XX(_name, _reg, readonly) |
| 157 | 161 | #define IMAGE2D_RW(_name, _reg) __IMAGE2D_XX(_name, _reg, readwrite) |
| 158 | 162 | #define IMAGE2D_WR(_name, _reg) __IMAGE2D_XX(_name, _reg, writeonly) |
trunk/3rdparty/bgfx/src/renderer_d3d11.cpp
| r244773 | r244774 | |
| 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 | |
| 1789 | 1792 | m_deviceCtx->PSSetShaderResources(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, m_textureStage.m_srv); |
| 1790 | 1793 | m_deviceCtx->PSSetSamplers(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, m_textureStage.m_sampler); |
| 1791 | 1794 | } |
| r244773 | r244774 | |
| 2369 | 2372 | ID3D11DeviceContext* deviceCtx = s_renderD3D11->m_deviceCtx; |
| 2370 | 2373 | BX_CHECK(m_dynamic, "Must be dynamic!"); |
| 2371 | 2374 | |
| 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 |
| 2372 | 2415 | D3D11_MAPPED_SUBRESOURCE mapped; |
| 2373 | 2416 | BX_UNUSED(_discard); |
| 2374 | 2417 | D3D11_MAP type = D3D11_MAP_WRITE_DISCARD; |
| 2375 | 2418 | DX_CHECK(deviceCtx->Map(m_ptr, 0, type, 0, &mapped)); |
| 2376 | | memcpy((uint8_t*)mapped.pData + _offset, _data, _size); |
| 2419 | memcpy( (uint8_t*)mapped.pData + _offset, _data, _size); |
| 2377 | 2420 | deviceCtx->Unmap(m_ptr, 0); |
| 2421 | #endif // 0 |
| 2378 | 2422 | } |
| 2379 | 2423 | |
| 2380 | 2424 | void VertexBufferD3D11::create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint8_t _flags) |
trunk/3rdparty/bgfx/src/renderer_d3d9.cpp
| r244773 | r244774 | |
| 498 | 498 | |
| 499 | 499 | for (uint32_t ii = 0; ii < TextureFormat::Count; ++ii) |
| 500 | 500 | { |
| 501 | | g_caps.formats[ii] = SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter |
| 501 | uint8_t support = 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 | | ) ) ? 1 : 0; |
| 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; |
| 508 | 518 | } |
| 509 | 519 | } |
| 510 | 520 | |
| r244773 | r244774 | |
| 1236 | 1246 | { |
| 1237 | 1247 | for (uint32_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage) |
| 1238 | 1248 | { |
| 1239 | | m_samplerFlags[stage] = UINT32_MAX; |
| 1249 | m_samplerFlags[stage][0] = UINT32_MAX; |
| 1250 | m_samplerFlags[stage][1] = UINT32_MAX; |
| 1240 | 1251 | } |
| 1241 | 1252 | } |
| 1242 | 1253 | |
| 1243 | | void setSamplerState(uint8_t _stage, uint32_t _flags) |
| 1254 | void setSamplerState(uint8_t _stage, uint32_t _flags, bool _vertex = false) |
| 1244 | 1255 | { |
| 1245 | 1256 | const uint32_t flags = _flags&( (~BGFX_TEXTURE_RESERVED_MASK) | BGFX_TEXTURE_SAMPLER_BITS_MASK); |
| 1246 | | if (m_samplerFlags[_stage] != flags) |
| 1257 | BX_CHECK(_stage < BX_COUNTOF(m_samplerFlags), ""); |
| 1258 | if (m_samplerFlags[_stage][_vertex] != flags) |
| 1247 | 1259 | { |
| 1248 | | m_samplerFlags[_stage] = flags; |
| 1260 | m_samplerFlags[_stage][_vertex] = flags; |
| 1249 | 1261 | IDirect3DDevice9* device = m_device; |
| 1250 | 1262 | D3DTEXTUREADDRESS tau = s_textureAddress[(_flags&BGFX_TEXTURE_U_MASK)>>BGFX_TEXTURE_U_SHIFT]; |
| 1251 | 1263 | D3DTEXTUREADDRESS tav = s_textureAddress[(_flags&BGFX_TEXTURE_V_MASK)>>BGFX_TEXTURE_V_SHIFT]; |
| r244773 | r244774 | |
| 1253 | 1265 | D3DTEXTUREFILTERTYPE minFilter = s_textureFilter[(_flags&BGFX_TEXTURE_MIN_MASK)>>BGFX_TEXTURE_MIN_SHIFT]; |
| 1254 | 1266 | D3DTEXTUREFILTERTYPE magFilter = s_textureFilter[(_flags&BGFX_TEXTURE_MAG_MASK)>>BGFX_TEXTURE_MAG_SHIFT]; |
| 1255 | 1267 | D3DTEXTUREFILTERTYPE mipFilter = s_textureFilter[(_flags&BGFX_TEXTURE_MIP_MASK)>>BGFX_TEXTURE_MIP_SHIFT]; |
| 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) ); |
| 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) ); |
| 1263 | 1278 | } |
| 1264 | 1279 | } |
| 1265 | 1280 | |
| r244773 | r244774 | |
| 1699 | 1714 | UniformRegistry m_uniformReg; |
| 1700 | 1715 | void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; |
| 1701 | 1716 | |
| 1702 | | uint32_t m_samplerFlags[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS]; |
| 1717 | uint32_t m_samplerFlags[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS][1]; |
| 1703 | 1718 | |
| 1704 | 1719 | TextureD3D9* m_updateTexture; |
| 1705 | 1720 | uint8_t* m_updateTextureBits; |
| r244773 | r244774 | |
| 2514 | 2529 | { |
| 2515 | 2530 | s_renderD3D9->setSamplerState(_stage, 0 == (BGFX_SAMPLER_DEFAULT_FLAGS & _flags) ? _flags : m_flags); |
| 2516 | 2531 | 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) ); |
| 2517 | 2535 | } |
| 2518 | 2536 | |
| 2519 | 2537 | void TextureD3D9::resolve() const |
trunk/3rdparty/bgfx/src/renderer_gl.cpp
| r244773 | r244774 | |
| 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 | |
| 239 | 292 | static GLenum s_imageFormat[] = |
| 240 | 293 | { |
| 241 | 294 | GL_ZERO, // BC1 |
| r244773 | r244774 | |
| 1115 | 1168 | { |
| 1116 | 1169 | setTextureFormat(TextureFormat::D32, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT); |
| 1117 | 1170 | |
| 1118 | | if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 30) ) |
| 1171 | if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES < 30) ) |
| 1119 | 1172 | { |
| 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 | | { |
| 1125 | 1173 | setTextureFormat(TextureFormat::RGBA16F, GL_RGBA, GL_RGBA, GL_HALF_FLOAT); |
| 1126 | 1174 | |
| 1127 | 1175 | if (BX_ENABLED(BX_PLATFORM_IOS) ) |
| r244773 | r244774 | |
| 1132 | 1180 | } |
| 1133 | 1181 | } |
| 1134 | 1182 | |
| 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 | |
| 1135 | 1194 | if (s_extension[Extension::EXT_texture_format_BGRA8888 ].m_supported |
| 1136 | 1195 | || s_extension[Extension::EXT_bgra ].m_supported |
| 1137 | 1196 | || s_extension[Extension::IMG_texture_format_BGRA8888 ].m_supported |
| r244773 | r244774 | |
| 3140 | 3199 | if (0 == msaaQuality) |
| 3141 | 3200 | { |
| 3142 | 3201 | GL_CHECK(glRenderbufferStorage(GL_RENDERBUFFER |
| 3143 | | , s_textureFormat[m_textureFormat].m_internalFmt |
| 3202 | , s_rboFormat[m_textureFormat] |
| 3144 | 3203 | , _width |
| 3145 | 3204 | , _height |
| 3146 | 3205 | ) ); |
| r244773 | r244774 | |
| 3149 | 3208 | { |
| 3150 | 3209 | GL_CHECK(glRenderbufferStorageMultisample(GL_RENDERBUFFER |
| 3151 | 3210 | , msaaQuality |
| 3152 | | , s_textureFormat[m_textureFormat].m_internalFmt |
| 3211 | , s_rboFormat[m_textureFormat] |
| 3153 | 3212 | , _width |
| 3154 | 3213 | , _height |
| 3155 | 3214 | ) ); |