1 // 2 // Copyright 2015 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // StateManager11.h: Defines a class for caching D3D11 state 8 9 #ifndef LIBANGLE_RENDERER_D3D11_STATEMANAGER11_H_ 10 #define LIBANGLE_RENDERER_D3D11_STATEMANAGER11_H_ 11 12 #include <array> 13 14 #include "libANGLE/State.h" 15 #include "libANGLE/angletypes.h" 16 #include "libANGLE/renderer/d3d/IndexDataManager.h" 17 #include "libANGLE/renderer/d3d/RendererD3D.h" 18 #include "libANGLE/renderer/d3d/d3d11/InputLayoutCache.h" 19 #include "libANGLE/renderer/d3d/d3d11/Query11.h" 20 #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" 21 22 namespace rx 23 { 24 class Buffer11; 25 class DisplayD3D; 26 class Framebuffer11; 27 struct RenderTargetDesc; 28 struct Renderer11DeviceCaps; 29 class VertexArray11; 30 31 class ShaderConstants11 : angle::NonCopyable 32 { 33 public: 34 ShaderConstants11(); 35 ~ShaderConstants11(); 36 37 void init(const gl::Caps &caps); 38 size_t getRequiredBufferSize(gl::ShaderType shaderType) const; 39 void markDirty(); 40 41 void setComputeWorkGroups(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ); 42 void setMultiviewWriteToViewportIndex(GLfloat index); 43 void onViewportChange(const gl::Rectangle &glViewport, 44 const D3D11_VIEWPORT &dxViewport, 45 bool is9_3, 46 bool presentPathFast); 47 bool onFirstVertexChange(GLint firstVertex, GLint baseVertex); 48 void onImageLayerChange(gl::ShaderType shaderType, unsigned int imageIndex, int layer); 49 void onSamplerChange(gl::ShaderType shaderType, 50 unsigned int samplerIndex, 51 const gl::Texture &texture, 52 const gl::SamplerState &samplerState); 53 void onImageChange(gl::ShaderType shaderType, 54 unsigned int imageIndex, 55 const gl::ImageUnit &imageUnit); 56 57 angle::Result updateBuffer(const gl::Context *context, 58 Renderer11 *renderer, 59 gl::ShaderType shaderType, 60 const ProgramD3D &programD3D, 61 const d3d11::Buffer &driverConstantBuffer); 62 63 private: 64 struct Vertex 65 { VertexVertex66 Vertex() 67 : depthRange{.0f}, 68 viewAdjust{.0f}, 69 viewCoords{.0f}, 70 viewScale{.0f}, 71 multiviewWriteToViewportIndex{.0f}, 72 firstVertex{0} 73 {} 74 75 float depthRange[4]; 76 float viewAdjust[4]; 77 float viewCoords[4]; 78 float viewScale[2]; 79 // multiviewWriteToViewportIndex is used to select either the side-by-side or layered 80 // code-path in the GS. It's value, if set, is either 0.0f or 1.0f. The value is updated 81 // whenever a multi-view draw framebuffer is made active. 82 float multiviewWriteToViewportIndex; 83 84 uint32_t firstVertex; 85 }; 86 87 struct Pixel 88 { PixelPixel89 Pixel() 90 : depthRange{.0f}, 91 viewCoords{.0f}, 92 depthFront{.0f}, 93 viewScale{.0f}, 94 multiviewWriteToViewportIndex(0), 95 padding(0) 96 {} 97 98 float depthRange[4]; 99 float viewCoords[4]; 100 float depthFront[4]; 101 float viewScale[2]; 102 // multiviewWriteToViewportIndex is used to select either the side-by-side or layered 103 // code-path in the GS. It's value, if set, is either 0.0f or 1.0f. The value is updated 104 // whenever a multi-view draw framebuffer is made active. 105 float multiviewWriteToViewportIndex; 106 107 // Added here to manually pad the struct. 108 float padding; 109 }; 110 111 struct Compute 112 { ComputeCompute113 Compute() : numWorkGroups{0u}, padding(0u) {} 114 unsigned int numWorkGroups[3]; 115 unsigned int padding; // This just pads the struct to 16 bytes 116 }; 117 118 struct SamplerMetadata 119 { SamplerMetadataSamplerMetadata120 SamplerMetadata() 121 : baseLevel(0), internalFormatBits(0), wrapModes(0), padding(0), intBorderColor{0} 122 {} 123 124 int baseLevel; 125 int internalFormatBits; 126 int wrapModes; 127 int padding; // This just pads the struct to 32 bytes 128 int intBorderColor[4]; 129 }; 130 131 static_assert(sizeof(SamplerMetadata) == 32u, 132 "Sampler metadata struct must be two 4-vec --> 32 bytes."); 133 134 struct ImageMetadata 135 { ImageMetadataImageMetadata136 ImageMetadata() : layer(0), level(0), padding{0} {} 137 138 int layer; 139 unsigned int level; 140 int padding[2]; // This just pads the struct to 16 bytes 141 }; 142 static_assert(sizeof(ImageMetadata) == 16u, 143 "Image metadata struct must be one 4-vec --> 16 bytes."); 144 145 static size_t GetShaderConstantsStructSize(gl::ShaderType shaderType); 146 147 // Return true if dirty. 148 bool updateSamplerMetadata(SamplerMetadata *data, 149 const gl::Texture &texture, 150 const gl::SamplerState &samplerState); 151 152 // Return true if dirty. 153 bool updateImageMetadata(ImageMetadata *data, const gl::ImageUnit &imageUnit); 154 155 Vertex mVertex; 156 Pixel mPixel; 157 Compute mCompute; 158 gl::ShaderBitSet mShaderConstantsDirty; 159 160 gl::ShaderMap<std::vector<SamplerMetadata>> mShaderSamplerMetadata; 161 gl::ShaderMap<int> mNumActiveShaderSamplers; 162 gl::ShaderMap<std::vector<ImageMetadata>> mShaderReadonlyImageMetadata; 163 gl::ShaderMap<int> mNumActiveShaderReadonlyImages; 164 gl::ShaderMap<std::vector<ImageMetadata>> mShaderImageMetadata; 165 gl::ShaderMap<int> mNumActiveShaderImages; 166 }; 167 168 class StateManager11 final : angle::NonCopyable 169 { 170 public: 171 StateManager11(Renderer11 *renderer); 172 ~StateManager11(); 173 174 void deinitialize(); 175 176 void syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits); 177 178 angle::Result updateStateForCompute(const gl::Context *context, 179 GLuint numGroupsX, 180 GLuint numGroupsY, 181 GLuint numGroupsZ); 182 183 void updateStencilSizeIfChanged(bool depthStencilInitialized, unsigned int stencilSize); 184 185 // These invalidations methods are called externally. 186 187 // Called from TextureStorage11. 188 void invalidateBoundViews(); 189 190 // Called from VertexArray11::updateVertexAttribStorage. 191 void invalidateCurrentValueAttrib(size_t attribIndex); 192 193 // Checks are done on a framebuffer state change to trigger other state changes. 194 // The Context is allowed to be nullptr for these methods, when called in EGL init code. 195 void invalidateRenderTarget(); 196 197 // Called by instanced point sprite emulation. 198 void invalidateVertexBuffer(); 199 200 // Called by Framebuffer11::syncState for the default sized viewport. 201 void invalidateViewport(const gl::Context *context); 202 203 // Called by TextureStorage11::markLevelDirty. 204 void invalidateSwizzles(); 205 206 // Called by the Framebuffer11 and VertexArray11. 207 void invalidateShaders(); 208 209 // Called by the Program on Uniform Buffer change. Also called internally. 210 void invalidateProgramUniformBuffers(); 211 212 // Called by TransformFeedback11. 213 void invalidateTransformFeedback(); 214 215 // Called by VertexArray11. 216 void invalidateInputLayout(); 217 218 // Called by VertexArray11 element array buffer sync. 219 void invalidateIndexBuffer(); 220 221 // Called by TextureStorage11. Also called internally. 222 void invalidateTexturesAndSamplers(); 223 224 void setRenderTarget(ID3D11RenderTargetView *rtv, ID3D11DepthStencilView *dsv); 225 void setRenderTargets(ID3D11RenderTargetView **rtvs, UINT numRtvs, ID3D11DepthStencilView *dsv); 226 227 void onBeginQuery(Query11 *query); 228 void onDeleteQueryObject(Query11 *query); 229 angle::Result onMakeCurrent(const gl::Context *context); 230 231 void setInputLayout(const d3d11::InputLayout *inputLayout); 232 233 void setSingleVertexBuffer(const d3d11::Buffer *buffer, UINT stride, UINT offset); 234 235 angle::Result updateState(const gl::Context *context, 236 gl::PrimitiveMode mode, 237 GLint firstVertex, 238 GLsizei vertexOrIndexCount, 239 gl::DrawElementsType indexTypeOrInvalid, 240 const void *indices, 241 GLsizei instanceCount, 242 GLint baseVertex); 243 244 void setShaderResourceShared(gl::ShaderType shaderType, 245 UINT resourceSlot, 246 const d3d11::SharedSRV *srv); 247 void setShaderResource(gl::ShaderType shaderType, 248 UINT resourceSlot, 249 const d3d11::ShaderResourceView *srv); 250 void setPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY primitiveTopology); 251 252 void setDrawShaders(const d3d11::VertexShader *vertexShader, 253 const d3d11::GeometryShader *geometryShader, 254 const d3d11::PixelShader *pixelShader); 255 void setVertexShader(const d3d11::VertexShader *shader); 256 void setGeometryShader(const d3d11::GeometryShader *shader); 257 void setPixelShader(const d3d11::PixelShader *shader); 258 void setComputeShader(const d3d11::ComputeShader *shader); 259 void setVertexConstantBuffer(unsigned int slot, const d3d11::Buffer *buffer); 260 void setPixelConstantBuffer(unsigned int slot, const d3d11::Buffer *buffer); 261 void setDepthStencilState(const d3d11::DepthStencilState *depthStencilState, UINT stencilRef); 262 void setSimpleBlendState(const d3d11::BlendState *blendState); 263 void setRasterizerState(const d3d11::RasterizerState *rasterizerState); 264 void setSimpleViewport(const gl::Extents &viewportExtents); 265 void setSimpleViewport(int width, int height); 266 void setSimplePixelTextureAndSampler(const d3d11::SharedSRV &srv, 267 const d3d11::SamplerState &samplerState); 268 void setSimpleScissorRect(const gl::Rectangle &glRect); 269 void setScissorRectD3D(const D3D11_RECT &d3dRect); 270 271 void setIndexBuffer(ID3D11Buffer *buffer, DXGI_FORMAT indexFormat, unsigned int offset); 272 273 angle::Result updateVertexOffsetsForPointSpritesEmulation(const gl::Context *context, 274 GLint startVertex, 275 GLsizei emulatedInstanceId); 276 277 // TODO(jmadill): Should be private. 278 angle::Result applyComputeUniforms(const gl::Context *context, ProgramD3D *programD3D); 279 280 // Only used in testing. getInputLayoutCache()281 InputLayoutCache *getInputLayoutCache() { return &mInputLayoutCache; } 282 getCullEverything()283 bool getCullEverything() const { return mCullEverything; } getVertexDataManager()284 VertexDataManager *getVertexDataManager() { return &mVertexDataManager; } 285 getProgramD3D()286 ProgramD3D *getProgramD3D() const { return mProgramD3D; } 287 288 private: 289 angle::Result ensureInitialized(const gl::Context *context); 290 291 template <typename SRVType> 292 void setShaderResourceInternal(gl::ShaderType shaderType, 293 UINT resourceSlot, 294 const SRVType *srv); 295 template <typename UAVType> 296 void setUnorderedAccessViewInternal(gl::ShaderType shaderType, 297 UINT resourceSlot, 298 const UAVType *uav); 299 300 void unsetConflictingView(gl::PipelineType pipeline, ID3D11View *view, bool isRenderTarget); 301 void unsetConflictingSRVs(gl::PipelineType pipeline, 302 gl::ShaderType shaderType, 303 uintptr_t resource, 304 const gl::ImageIndex *index, 305 bool isRenderTarget); 306 void unsetConflictingUAVs(gl::PipelineType pipeline, 307 gl::ShaderType shaderType, 308 uintptr_t resource, 309 const gl::ImageIndex *index); 310 void unsetConflictingRTVs(uintptr_t resource); 311 312 void unsetConflictingAttachmentResources(const gl::FramebufferAttachment &attachment, 313 ID3D11Resource *resource); 314 315 angle::Result syncBlendState(const gl::Context *context, 316 const gl::BlendStateArray &blendStateArray, 317 const gl::ColorF &blendColor, 318 unsigned int sampleMask, 319 bool sampleAlphaToCoverage, 320 bool emulateConstantAlpha); 321 322 angle::Result syncDepthStencilState(const gl::Context *context); 323 324 angle::Result syncRasterizerState(const gl::Context *context, gl::PrimitiveMode mode); 325 326 void syncScissorRectangle(const gl::Rectangle &scissor, bool enabled); 327 328 void syncViewport(const gl::Context *context); 329 330 void checkPresentPath(const gl::Context *context); 331 332 angle::Result syncFramebuffer(const gl::Context *context); 333 angle::Result syncProgram(const gl::Context *context, gl::PrimitiveMode drawMode); 334 angle::Result syncProgramForCompute(const gl::Context *context); 335 336 angle::Result syncTextures(const gl::Context *context); 337 angle::Result applyTexturesForSRVs(const gl::Context *context, gl::ShaderType shaderType); 338 angle::Result applyTexturesForUAVs(const gl::Context *context, gl::ShaderType shaderType); 339 angle::Result syncTexturesForCompute(const gl::Context *context); 340 341 angle::Result setSamplerState(const gl::Context *context, 342 gl::ShaderType type, 343 int index, 344 gl::Texture *texture, 345 const gl::SamplerState &sampler); 346 angle::Result setTextureForSampler(const gl::Context *context, 347 gl::ShaderType type, 348 int index, 349 gl::Texture *texture, 350 const gl::SamplerState &sampler); 351 angle::Result setImageState(const gl::Context *context, 352 gl::ShaderType type, 353 int index, 354 const gl::ImageUnit &imageUnit); 355 angle::Result setTextureForImage(const gl::Context *context, 356 gl::ShaderType type, 357 int index, 358 bool readonly, 359 const gl::ImageUnit &imageUnit); 360 361 void handleMultiviewDrawFramebufferChange(const gl::Context *context); 362 363 angle::Result syncCurrentValueAttribs( 364 const gl::Context *context, 365 const std::vector<gl::VertexAttribCurrentValueData> ¤tValues); 366 367 angle::Result generateSwizzle(const gl::Context *context, gl::Texture *texture); 368 angle::Result generateSwizzlesForShader(const gl::Context *context, gl::ShaderType type); 369 angle::Result generateSwizzles(const gl::Context *context); 370 371 angle::Result applyDriverUniforms(const gl::Context *context); 372 angle::Result applyDriverUniformsForShader(const gl::Context *context, 373 gl::ShaderType shaderType); 374 angle::Result applyUniforms(const gl::Context *context); 375 angle::Result applyUniformsForShader(const gl::Context *context, gl::ShaderType shaderType); 376 377 angle::Result syncShaderStorageBuffersForShader(const gl::Context *context, 378 gl::ShaderType shaderType); 379 380 angle::Result syncUniformBuffers(const gl::Context *context); 381 angle::Result syncUniformBuffersForShader(const gl::Context *context, 382 gl::ShaderType shaderType); 383 angle::Result syncAtomicCounterBuffers(const gl::Context *context); 384 angle::Result syncAtomicCounterBuffersForShader(const gl::Context *context, 385 gl::ShaderType shaderType); 386 angle::Result syncShaderStorageBuffers(const gl::Context *context); 387 angle::Result syncTransformFeedbackBuffers(const gl::Context *context); 388 389 // These are currently only called internally. 390 void invalidateDriverUniforms(); 391 void invalidateProgramUniforms(); 392 void invalidateConstantBuffer(unsigned int slot); 393 void invalidateProgramAtomicCounterBuffers(); 394 void invalidateProgramShaderStorageBuffers(); 395 396 // Called by the Framebuffer11 directly. 397 void processFramebufferInvalidation(const gl::Context *context); 398 399 bool syncIndexBuffer(ID3D11Buffer *buffer, DXGI_FORMAT indexFormat, unsigned int offset); 400 angle::Result syncVertexBuffersAndInputLayout(const gl::Context *context, 401 gl::PrimitiveMode mode, 402 GLint firstVertex, 403 GLsizei vertexOrIndexCount, 404 gl::DrawElementsType indexTypeOrInvalid, 405 GLsizei instanceCount); 406 407 bool setInputLayoutInternal(const d3d11::InputLayout *inputLayout); 408 409 angle::Result applyVertexBuffers(const gl::Context *context, 410 gl::PrimitiveMode mode, 411 gl::DrawElementsType indexTypeOrInvalid, 412 GLint firstVertex); 413 // TODO(jmadill): Migrate to d3d11::Buffer. 414 bool queueVertexBufferChange(size_t bufferIndex, 415 ID3D11Buffer *buffer, 416 UINT stride, 417 UINT offset); 418 void applyVertexBufferChanges(); 419 bool setPrimitiveTopologyInternal(D3D11_PRIMITIVE_TOPOLOGY primitiveTopology); 420 void syncPrimitiveTopology(const gl::State &glState, gl::PrimitiveMode currentDrawMode); 421 422 // Not handled by an internal dirty bit because it isn't synced on drawArrays calls. 423 angle::Result applyIndexBuffer(const gl::Context *context, 424 GLsizei indexCount, 425 gl::DrawElementsType indexType, 426 const void *indices); 427 428 enum DirtyBitType 429 { 430 DIRTY_BIT_RENDER_TARGET, 431 DIRTY_BIT_VIEWPORT_STATE, 432 DIRTY_BIT_SCISSOR_STATE, 433 DIRTY_BIT_RASTERIZER_STATE, 434 DIRTY_BIT_BLEND_STATE, 435 DIRTY_BIT_DEPTH_STENCIL_STATE, 436 // DIRTY_BIT_SHADERS and DIRTY_BIT_TEXTURE_AND_SAMPLER_STATE should be dealt before 437 // DIRTY_BIT_PROGRAM_UNIFORM_BUFFERS for update image layers. 438 DIRTY_BIT_SHADERS, 439 // DIRTY_BIT_GRAPHICS_SRVUAV_STATE and DIRTY_BIT_COMPUTE_SRVUAV_STATE should be lower 440 // bits than DIRTY_BIT_TEXTURE_AND_SAMPLER_STATE. 441 DIRTY_BIT_GRAPHICS_SRVUAV_STATE, 442 DIRTY_BIT_COMPUTE_SRVUAV_STATE, 443 DIRTY_BIT_TEXTURE_AND_SAMPLER_STATE, 444 DIRTY_BIT_PROGRAM_UNIFORMS, 445 DIRTY_BIT_DRIVER_UNIFORMS, 446 DIRTY_BIT_PROGRAM_UNIFORM_BUFFERS, 447 DIRTY_BIT_PROGRAM_ATOMIC_COUNTER_BUFFERS, 448 DIRTY_BIT_PROGRAM_SHADER_STORAGE_BUFFERS, 449 DIRTY_BIT_CURRENT_VALUE_ATTRIBS, 450 DIRTY_BIT_TRANSFORM_FEEDBACK, 451 DIRTY_BIT_VERTEX_BUFFERS_AND_INPUT_LAYOUT, 452 DIRTY_BIT_PRIMITIVE_TOPOLOGY, 453 DIRTY_BIT_INVALID, 454 DIRTY_BIT_MAX = DIRTY_BIT_INVALID, 455 }; 456 457 using DirtyBits = angle::BitSet<DIRTY_BIT_MAX>; 458 459 Renderer11 *mRenderer; 460 461 // Internal dirty bits. 462 DirtyBits mInternalDirtyBits; 463 DirtyBits mGraphicsDirtyBitsMask; 464 DirtyBits mComputeDirtyBitsMask; 465 466 bool mCurSampleAlphaToCoverage; 467 468 // Blend State 469 gl::BlendStateArray mCurBlendStateArray; 470 gl::ColorF mCurBlendColor; 471 unsigned int mCurSampleMask; 472 473 // Currently applied depth stencil state 474 gl::DepthStencilState mCurDepthStencilState; 475 int mCurStencilRef; 476 int mCurStencilBackRef; 477 unsigned int mCurStencilSize; 478 Optional<bool> mCurDisableDepth; 479 Optional<bool> mCurDisableStencil; 480 481 // Currently applied rasterizer state 482 gl::RasterizerState mCurRasterState; 483 484 // Currently applied scissor rectangle state 485 bool mCurScissorEnabled; 486 gl::Rectangle mCurScissorRect; 487 488 // Currently applied viewport state 489 gl::Rectangle mCurViewport; 490 float mCurNear; 491 float mCurFar; 492 493 // Things needed in viewport state 494 ShaderConstants11 mShaderConstants; 495 496 // Render target variables 497 gl::Extents mViewportBounds; 498 bool mRenderTargetIsDirty; 499 500 // EGL_ANGLE_experimental_present_path variables 501 bool mCurPresentPathFastEnabled; 502 int mCurPresentPathFastColorBufferHeight; 503 504 // Queries that are currently active in this state 505 std::set<Query11 *> mCurrentQueries; 506 507 // Currently applied textures 508 template <typename DescType> 509 struct ViewRecord 510 { 511 uintptr_t view; 512 uintptr_t resource; 513 DescType desc; 514 }; 515 516 // A cache of current Views that also tracks the highest 'used' (non-NULL) View. 517 // We might want to investigate a more robust approach that is also fast when there's 518 // a large gap between used Views (e.g. if View 0 and 7 are non-NULL, this approach will 519 // waste time on Views 1-6.) 520 template <typename ViewType, typename DescType> 521 class ViewCache : angle::NonCopyable 522 { 523 public: 524 ViewCache(); 525 ~ViewCache(); 526 initialize(size_t size)527 void initialize(size_t size) { mCurrentViews.resize(size); } 528 size()529 size_t size() const { return mCurrentViews.size(); } highestUsed()530 size_t highestUsed() const { return mHighestUsedView; } 531 532 const ViewRecord<DescType> &operator[](size_t index) const { return mCurrentViews[index]; } 533 void clear(); 534 void update(size_t resourceIndex, ViewType *view); 535 536 private: 537 std::vector<ViewRecord<DescType>> mCurrentViews; 538 size_t mHighestUsedView; 539 }; 540 541 using SRVCache = ViewCache<ID3D11ShaderResourceView, D3D11_SHADER_RESOURCE_VIEW_DESC>; 542 using UAVCache = ViewCache<ID3D11UnorderedAccessView, D3D11_UNORDERED_ACCESS_VIEW_DESC>; 543 using RTVCache = ViewCache<ID3D11RenderTargetView, D3D11_RENDER_TARGET_VIEW_DESC>; 544 gl::ShaderMap<SRVCache> mCurShaderSRVs; 545 UAVCache mCurComputeUAVs; 546 RTVCache mCurRTVs; 547 548 SRVCache *getSRVCache(gl::ShaderType shaderType); 549 550 // A block of NULL pointers, cached so we don't re-allocate every draw call 551 std::vector<ID3D11ShaderResourceView *> mNullSRVs; 552 std::vector<ID3D11UnorderedAccessView *> mNullUAVs; 553 554 // Current translations of "Current-Value" data - owned by Context, not VertexArray. 555 gl::AttributesMask mDirtyCurrentValueAttribs; 556 std::vector<TranslatedAttribute> mCurrentValueAttribs; 557 558 // Current applied input layout. 559 ResourceSerial mCurrentInputLayout; 560 561 // Current applied vertex states. 562 // TODO(jmadill): Figure out how to use ResourceSerial here. 563 gl::AttribArray<ID3D11Buffer *> mCurrentVertexBuffers; 564 gl::AttribArray<UINT> mCurrentVertexStrides; 565 gl::AttribArray<UINT> mCurrentVertexOffsets; 566 gl::RangeUI mDirtyVertexBufferRange; 567 568 // Currently applied primitive topology 569 D3D11_PRIMITIVE_TOPOLOGY mCurrentPrimitiveTopology; 570 gl::PrimitiveMode mLastAppliedDrawMode; 571 bool mCullEverything; 572 573 // Currently applied shaders 574 gl::ShaderMap<ResourceSerial> mAppliedShaders; 575 576 // Currently applied sampler states 577 gl::ShaderMap<std::vector<bool>> mForceSetShaderSamplerStates; 578 gl::ShaderMap<std::vector<gl::SamplerState>> mCurShaderSamplerStates; 579 580 // Special dirty bit for swizzles. Since they use internal shaders, must be done in a pre-pass. 581 bool mDirtySwizzles; 582 583 // Currently applied index buffer 584 ID3D11Buffer *mAppliedIB; 585 DXGI_FORMAT mAppliedIBFormat; 586 unsigned int mAppliedIBOffset; 587 bool mIndexBufferIsDirty; 588 589 // Vertex, index and input layouts 590 VertexDataManager mVertexDataManager; 591 IndexDataManager mIndexDataManager; 592 InputLayoutCache mInputLayoutCache; 593 std::vector<const TranslatedAttribute *> mCurrentAttributes; 594 Optional<GLint> mLastFirstVertex; 595 596 // ANGLE_multiview. 597 bool mIsMultiviewEnabled; 598 599 bool mIndependentBlendStates; 600 601 // Driver Constants. 602 gl::ShaderMap<d3d11::Buffer> mShaderDriverConstantBuffers; 603 604 ResourceSerial mCurrentComputeConstantBuffer; 605 ResourceSerial mCurrentGeometryConstantBuffer; 606 607 d3d11::Buffer mPointSpriteVertexBuffer; 608 d3d11::Buffer mPointSpriteIndexBuffer; 609 610 template <typename T> 611 using VertexConstantBufferArray = 612 std::array<T, gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS>; 613 614 VertexConstantBufferArray<ResourceSerial> mCurrentConstantBufferVS; 615 VertexConstantBufferArray<GLintptr> mCurrentConstantBufferVSOffset; 616 VertexConstantBufferArray<GLsizeiptr> mCurrentConstantBufferVSSize; 617 618 template <typename T> 619 using FragmentConstantBufferArray = 620 std::array<T, gl::IMPLEMENTATION_MAX_FRAGMENT_SHADER_UNIFORM_BUFFERS>; 621 622 FragmentConstantBufferArray<ResourceSerial> mCurrentConstantBufferPS; 623 FragmentConstantBufferArray<GLintptr> mCurrentConstantBufferPSOffset; 624 FragmentConstantBufferArray<GLsizeiptr> mCurrentConstantBufferPSSize; 625 626 template <typename T> 627 using ComputeConstantBufferArray = 628 std::array<T, gl::IMPLEMENTATION_MAX_COMPUTE_SHADER_UNIFORM_BUFFERS>; 629 630 ComputeConstantBufferArray<ResourceSerial> mCurrentConstantBufferCS; 631 ComputeConstantBufferArray<GLintptr> mCurrentConstantBufferCSOffset; 632 ComputeConstantBufferArray<GLsizeiptr> mCurrentConstantBufferCSSize; 633 634 // Currently applied transform feedback buffers 635 Serial mAppliedTFSerial; 636 637 Serial mEmptySerial; 638 639 // These objects are cached to avoid having to query the impls. 640 ProgramD3D *mProgramD3D; 641 VertexArray11 *mVertexArray11; 642 Framebuffer11 *mFramebuffer11; 643 }; 644 645 } // namespace rx 646 #endif // LIBANGLE_RENDERER_D3D11_STATEMANAGER11_H_ 647